msm: ipc: Allow QMI clients to send messages after IRSC is complete
Currently there exists a small time interval during initialization where QMI clients in user-space can communicate with QMI services before the IPC Router Security Configuration(IRSC) is complete. Only allow clients to communicate after IRSC is complete. Change-Id: I773ad5b3cb02c51a725cd60a77466876c1498b64 Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
This commit is contained in:
parent
232fb9f80f
commit
751bbb9017
|
@ -197,12 +197,6 @@ static atomic_t pending_close_count = ATOMIC_INIT(0);
|
|||
static wait_queue_head_t subsystem_restart_wait;
|
||||
static struct workqueue_struct *msm_ipc_router_workqueue;
|
||||
|
||||
enum {
|
||||
CLIENT_PORT,
|
||||
SERVER_PORT,
|
||||
CONTROL_PORT,
|
||||
};
|
||||
|
||||
enum {
|
||||
DOWN,
|
||||
UP,
|
||||
|
@ -2307,6 +2301,11 @@ int msm_ipc_router_close_port(struct msm_ipc_port *port_ptr)
|
|||
mutex_lock(&control_ports_lock);
|
||||
list_del(&port_ptr->list);
|
||||
mutex_unlock(&control_ports_lock);
|
||||
} else if (port_ptr->type == IRSC_PORT) {
|
||||
mutex_lock(&local_ports_lock);
|
||||
list_del(&port_ptr->list);
|
||||
mutex_unlock(&local_ports_lock);
|
||||
signal_irsc_completion();
|
||||
}
|
||||
|
||||
mutex_lock(&port_ptr->port_rx_q_lock);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -55,6 +55,13 @@
|
|||
#define ALL_SERVICE 0xFFFFFFFF
|
||||
#define ALL_INSTANCE 0xFFFFFFFF
|
||||
|
||||
enum {
|
||||
CLIENT_PORT,
|
||||
SERVER_PORT,
|
||||
CONTROL_PORT,
|
||||
IRSC_PORT,
|
||||
};
|
||||
|
||||
union rr_control_msg {
|
||||
uint32_t cmd;
|
||||
struct {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -282,6 +282,9 @@ static int msm_ipc_router_sendmsg(struct kiocb *iocb, struct socket *sock,
|
|||
goto out_sendmsg;
|
||||
}
|
||||
|
||||
if (port_ptr->type == CLIENT_PORT)
|
||||
wait_for_irsc_completion();
|
||||
|
||||
ret = msm_ipc_router_send_to(port_ptr, msg, &dest->address);
|
||||
if (ret == (IPC_ROUTER_HDR_SIZE + total_len))
|
||||
ret = total_len;
|
||||
|
@ -431,6 +434,8 @@ static int msm_ipc_router_ioctl(struct socket *sock,
|
|||
|
||||
case IPC_ROUTER_IOCTL_CONFIG_SEC_RULES:
|
||||
ret = msm_ipc_config_sec_rules((void *)arg);
|
||||
if (ret != -EPERM)
|
||||
port_ptr->type = IRSC_PORT;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -29,6 +29,7 @@
|
|||
#include "ipc_router.h"
|
||||
#include "msm_ipc_router_security.h"
|
||||
|
||||
#define IRSC_COMPLETION_TIMEOUT_MS 30000
|
||||
#define SEC_RULES_HASH_SZ 32
|
||||
struct security_rule {
|
||||
struct list_head list;
|
||||
|
@ -41,6 +42,31 @@ struct security_rule {
|
|||
|
||||
static DEFINE_MUTEX(security_rules_lock);
|
||||
static struct list_head security_rules[SEC_RULES_HASH_SZ];
|
||||
static DECLARE_COMPLETION(irsc_completion);
|
||||
|
||||
/**
|
||||
* wait_for_irsc_completion() - Wait for IPC Router Security Configuration
|
||||
* (IRSC) to complete
|
||||
*/
|
||||
void wait_for_irsc_completion(void)
|
||||
{
|
||||
unsigned long rem_jiffies;
|
||||
do {
|
||||
rem_jiffies = wait_for_completion_timeout(&irsc_completion,
|
||||
msecs_to_jiffies(IRSC_COMPLETION_TIMEOUT_MS));
|
||||
if (rem_jiffies)
|
||||
return;
|
||||
pr_err("%s: waiting for IPC Security Conf.\n", __func__);
|
||||
} while (1);
|
||||
}
|
||||
|
||||
/**
|
||||
* signal_irsc_completion() - Signal the completion of IRSC
|
||||
*/
|
||||
void signal_irsc_completion(void)
|
||||
{
|
||||
complete_all(&irsc_completion);
|
||||
}
|
||||
|
||||
/**
|
||||
* check_permisions() - Check whether the process has permissions to
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -73,6 +73,17 @@ int msm_ipc_check_send_permissions(void *data);
|
|||
*/
|
||||
int msm_ipc_router_security_init(void);
|
||||
|
||||
/**
|
||||
* wait_for_irsc_completion() - Wait for IPC Router Security Configuration
|
||||
* (IRSC) to complete
|
||||
*/
|
||||
void wait_for_irsc_completion(void);
|
||||
|
||||
/**
|
||||
* signal_irsc_completion() - Signal the completion of IRSC
|
||||
*/
|
||||
void signal_irsc_completion(void);
|
||||
|
||||
#else
|
||||
|
||||
static inline int check_permissions(void)
|
||||
|
@ -100,5 +111,10 @@ static inline int msm_ipc_router_security_init(void)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void wait_for_irsc_completion(void) { }
|
||||
|
||||
static inline void signal_irsc_completion(void) { }
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue