All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] android: Shutdown if IPC command for unregistered service is received
@ 2013-11-13 14:47 Szymon Janc
  2013-11-13 14:47 ` [PATCH 2/2] android: Core service should be always registered Szymon Janc
  2013-11-13 17:50 ` [PATCH 1/2] android: Shutdown if IPC command for unregistered service is received Johan Hedberg
  0 siblings, 2 replies; 3+ messages in thread
From: Szymon Janc @ 2013-11-13 14:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Sending commands to not registered services is violation of IPC spec
and should result in daemon shutdown.
---
 android/main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/android/main.c b/android/main.c
index 36cc8aa..12284f7 100644
--- a/android/main.c
+++ b/android/main.c
@@ -252,6 +252,12 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 	DBG("service_id %u opcode %u len %u", msg->service_id, msg->opcode,
 								msg->len);
 
+	if (msg->service_id > HAL_SERVICE_ID_MAX ||
+						!services[msg->service_id]) {
+		error("HAL command of not registered service, terminating");
+		goto fail;
+	}
+
 	switch (msg->service_id) {
 	case HAL_SERVICE_ID_CORE:
 		handle_service_core(msg->opcode, msg->payload, msg->len);
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] android: Core service should be always registered
  2013-11-13 14:47 [PATCH 1/2] android: Shutdown if IPC command for unregistered service is received Szymon Janc
@ 2013-11-13 14:47 ` Szymon Janc
  2013-11-13 17:50 ` [PATCH 1/2] android: Shutdown if IPC command for unregistered service is received Johan Hedberg
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2013-11-13 14:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Core service is used to register other services and shall be always
consider registered.
---
 android/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/android/main.c b/android/main.c
index 12284f7..03720e8 100644
--- a/android/main.c
+++ b/android/main.c
@@ -74,7 +74,8 @@ static guint adapter_timeout = 0;
 static GIOChannel *hal_cmd_io = NULL;
 static GIOChannel *hal_notif_io = NULL;
 
-static bool services[HAL_SERVICE_ID_MAX + 1] = { false };
+/* Core Service (ID=0) should be always consider registered */
+static bool services[HAL_SERVICE_ID_MAX + 1] = { true, false };
 
 static void service_register(void *buf, uint16_t len)
 {
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] android: Shutdown if IPC command for unregistered service is received
  2013-11-13 14:47 [PATCH 1/2] android: Shutdown if IPC command for unregistered service is received Szymon Janc
  2013-11-13 14:47 ` [PATCH 2/2] android: Core service should be always registered Szymon Janc
@ 2013-11-13 17:50 ` Johan Hedberg
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hedberg @ 2013-11-13 17:50 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth

Hi Szymon,

On Wed, Nov 13, 2013, Szymon Janc wrote:
> Sending commands to not registered services is violation of IPC spec
> and should result in daemon shutdown.
> ---
>  android/main.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Both patches have been applied (with some minor tweaks). Thanks.

Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-13 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 14:47 [PATCH 1/2] android: Shutdown if IPC command for unregistered service is received Szymon Janc
2013-11-13 14:47 ` [PATCH 2/2] android: Core service should be always registered Szymon Janc
2013-11-13 17:50 ` [PATCH 1/2] android: Shutdown if IPC command for unregistered service is received Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.