Re: [systemd-devel] [PATCH] connection: fix kernel oop when conn_name not set

2014-05-12 Thread Jacek Janczyk

On 05/12/2014 04:20 PM, Kay Sievers wrote:

On Mon, May 12, 2014 at 3:24 PM, Jacek Janczyk  wrote:

kernel oops when connection name (kdbus_conn.name) not set via HELLO
message but requested with attach flags KDBUS_ATTACH_CONN_NAME.

Hmm, here does it crash? Seems the code that attaches the string
checks for the string being set:
   if ((mask & KDBUS_ATTACH_CONN_NAME) && conn && conn->name)

My fault. I have brought the patch from older version of the code
that we're working on. It is not relevant any more.

JJ




As conn.name is defined as "for debug purposes" I find it more
convenient to return generic name than to strip the field from
requested metadata or raise an error on request.

I prefer if we just return nothing when we miss non-essential data.
The kernel and its magic strings, which which can also just be
supplied by users like the " (deleted)" for file names, are generally
not a good idea.

Kay



___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] connection: fix kernel oop when conn_name not set

2014-05-12 Thread Kay Sievers
On Mon, May 12, 2014 at 3:24 PM, Jacek Janczyk  wrote:
> kernel oops when connection name (kdbus_conn.name) not set via HELLO
> message but requested with attach flags KDBUS_ATTACH_CONN_NAME.

Hmm, here does it crash? Seems the code that attaches the string
checks for the string being set:
  if ((mask & KDBUS_ATTACH_CONN_NAME) && conn && conn->name)

> As conn.name is defined as "for debug purposes" I find it more
> convenient to return generic name than to strip the field from
> requested metadata or raise an error on request.

I prefer if we just return nothing when we miss non-essential data.
The kernel and its magic strings, which which can also just be
supplied by users like the " (deleted)" for file names, are generally
not a good idea.

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] connection: fix kernel oop when conn_name not set

2014-05-12 Thread Jacek Janczyk
kernel oops when connection name (kdbus_conn.name) not set via HELLO
message but requested with attach flags KDBUS_ATTACH_CONN_NAME.

As conn.name is defined as "for debug purposes" I find it more
convenient to return generic name than to strip the field from
requested metadata or raise an error on request.

Signed-off-by: Jacek Janczyk 
---
 connection.c |   10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/connection.c b/connection.c
index 40cf133..5ae9d99 100644
--- a/connection.c
+++ b/connection.c
@@ -1941,12 +1941,10 @@ int kdbus_conn_new(struct kdbus_ep *ep,
goto exit_free_conn;
}
 
-   if (conn_name) {
-   conn->name = kstrdup(conn_name, GFP_KERNEL);
-   if (!conn->name) {
-   ret = -ENOMEM;
-   goto exit_free_conn;
-   }
+   conn->name = kstrdup(conn_name ? conn_name : "UNDEFINED", GFP_KERNEL);
+   if (!conn->name) {
+   ret = -ENOMEM;
+   goto exit_free_conn;
}
 
kref_init(&conn->kref);
-- 
1.7.9.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel