platform/core/system/kdbus-bus.git
9 years agodoc: annotate more strings, break more lines ... upstream upstream/0.20150129.081441utc
Daniel Mack [Wed, 28 Jan 2015 23:14:41 +0000 (00:14 +0100)]
doc: annotate more strings, break more lines ...

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: KDBUS_MSG_PAYLOAD_{VEC|MEMFD} => KDBUS_ITEM_PAYLOAD_{VEC|MEMDF}
Djalal Harouni [Wed, 28 Jan 2015 22:43:31 +0000 (23:43 +0100)]
doc: KDBUS_MSG_PAYLOAD_{VEC|MEMFD} => KDBUS_ITEM_PAYLOAD_{VEC|MEMDF}

KDBUS_MSG_PAYLOAD_{VEC|MEMFD} were renamed to KDBUS_ITEM_PAYLOAD_{VEC|MEMDF}

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agodoc: assorted fixup
Daniel Mack [Wed, 28 Jan 2015 20:18:40 +0000 (21:18 +0100)]
doc: assorted fixup

Closed some TODOs in kdbus.item and lots of reformatting.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: more return value section cleanups
Daniel Mack [Wed, 28 Jan 2015 16:37:10 +0000 (17:37 +0100)]
doc: more return value section cleanups

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: more <varname> tag cleanups
Daniel Mack [Wed, 28 Jan 2015 16:26:13 +0000 (17:26 +0100)]
doc: more <varname> tag cleanups

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: turn some <varname> into <constant>
Daniel Mack [Wed, 28 Jan 2015 11:34:06 +0000 (12:34 +0100)]
doc: turn some <varname> into <constant>

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: error code section cleanups
Daniel Mack [Wed, 28 Jan 2015 10:59:12 +0000 (11:59 +0100)]
doc: error code section cleanups

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: minor changes to kdbus.connection(7)
Tom Gundersen [Tue, 27 Jan 2015 18:46:05 +0000 (19:46 +0100)]
doc: minor changes to kdbus.connection(7)

Signed-off-by: Tom Gundersen <teg@jklm.no>
9 years agodoc: kdbus.pool.xml cleanups
Daniel Mack [Tue, 27 Jan 2015 18:16:00 +0000 (19:16 +0100)]
doc: kdbus.pool.xml cleanups

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: kdbus.fs.xml cleanups
Daniel Mack [Tue, 27 Jan 2015 17:32:08 +0000 (18:32 +0100)]
doc: kdbus.fs.xml cleanups

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: reformat the "return value" sections in all man pages
Daniel Mack [Tue, 27 Jan 2015 17:11:35 +0000 (18:11 +0100)]
doc: reformat the "return value" sections in all man pages

Also fix some more TODOs.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: more work on kdbus.endpoint.xml
Daniel Mack [Tue, 27 Jan 2015 16:49:35 +0000 (17:49 +0100)]
doc: more work on kdbus.endpoint.xml

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: enable html output
Daniel Mack [Tue, 27 Jan 2015 15:56:27 +0000 (16:56 +0100)]
doc: enable html output

Type 'make htmldoc' to get doc/*.html

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoDissolve kdbus.txt
Daniel Mack [Tue, 27 Jan 2015 14:27:03 +0000 (15:27 +0100)]
Dissolve kdbus.txt

The information in kdbus.txt has been transferred to man pages, except
for informtaion about the internal object relationship.

Remove kdbus.txt and transfer the rest as comment into main.c.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: cleanup kdbus.bus
Daniel Mack [Tue, 27 Jan 2015 14:20:58 +0000 (15:20 +0100)]
doc: cleanup kdbus.bus

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodocs: assorted cleanups
Daniel Mack [Tue, 27 Jan 2015 14:03:15 +0000 (15:03 +0100)]
docs: assorted cleanups

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: restructure kdbus.item
Daniel Mack [Tue, 27 Jan 2015 13:42:21 +0000 (14:42 +0100)]
doc: restructure kdbus.item

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: some more work on kdbus.item
Daniel Mack [Tue, 27 Jan 2015 12:29:03 +0000 (13:29 +0100)]
doc: some more work on kdbus.item

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: some more information on items
Daniel Mack [Tue, 27 Jan 2015 11:49:08 +0000 (12:49 +0100)]
doc: some more information on items

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: add kdbus.match.xml
Daniel Mack [Tue, 27 Jan 2015 10:02:28 +0000 (11:02 +0100)]
doc: add kdbus.match.xml

Not finished yet.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: minor fixes and new TODOs
Tom Gundersen [Mon, 26 Jan 2015 23:59:41 +0000 (00:59 +0100)]
doc: minor fixes and new TODOs

Signed-off-by: Tom Gundersen <teg@jklm.no>
9 years agodoc: add kdbus.policy.7
Daniel Mack [Mon, 26 Jan 2015 20:40:39 +0000 (21:40 +0100)]
doc: add kdbus.policy.7

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agotest: add check for pointer arithmetic overflow
Daniel Mack [Mon, 26 Jan 2015 18:24:12 +0000 (19:24 +0100)]
test: add check for pointer arithmetic overflow

It's not crucial to have this in the test suite, but we should follow
our own examples.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: convert documentation to docbook-xml
Daniel Mack [Fri, 23 Jan 2015 19:25:47 +0000 (20:25 +0100)]
doc: convert documentation to docbook-xml

This is work in progress and not finished yet.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: replace KDBUS_MSG_PAYLOAD_{VEC|MEMFD} with KDBUS_ITEM_PAYLOAD_{VEC|MEMFD}
Djalal Harouni [Sat, 24 Jan 2015 21:42:19 +0000 (22:42 +0100)]
doc: replace KDBUS_MSG_PAYLOAD_{VEC|MEMFD} with KDBUS_ITEM_PAYLOAD_{VEC|MEMFD}

Replace KDBUS_MSG_PAYLOAD_VEC and KDBUS_MSG_PAYLOAD_MEMFD with
KDBUS_ITEM_PAYLOAD_VEC and KDBUS_ITEM_PAYLOAD_MEMFD respectively.

This is a documentation fix.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agodoc: KDBUS_MSG_SYNC_REPLY was replaced by KDBUS_SEND_SYNC_REPLY
Djalal Harouni [Sat, 24 Jan 2015 21:37:47 +0000 (22:37 +0100)]
doc: KDBUS_MSG_SYNC_REPLY was replaced by KDBUS_SEND_SYNC_REPLY

There is no more KDBUS_MSG_SYNC_REPLY, it was replaced by
KDBUS_SEND_SYNC_REPLY. This is only a documentation fix.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agotest: decrease memfd_count by 1 because all fds take one item
Sheng Yong [Wed, 21 Jan 2015 13:38:21 +0000 (21:38 +0800)]
test: decrease memfd_count by 1 because all fds take one item

When test E2BIG using memfd_count, we should consider that all fds
will take one item. So the number of left item, which will trigger
E2BIG is (KDBUG_MSG_MAX_ITEMs - 1).

Signed-off-by: Sheng Yong <shyodx@gmail.com>
Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agomatch: for KDBUS_CMD_MATCH_REMOVE fail with EBADSLT for invalid match entries
Djalal Harouni [Wed, 21 Jan 2015 12:33:37 +0000 (13:33 +0100)]
match: for KDBUS_CMD_MATCH_REMOVE fail with EBADSLT for invalid match entries

For KDBUS_CMD_MATCH_REMOVE, if a match entry is not found or invalid
fail with EBADSLT

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agokdbus.txt: add better description about priority dequeuing
Daniel Mack [Tue, 20 Jan 2015 17:49:14 +0000 (18:49 +0100)]
kdbus.txt: add better description about priority dequeuing

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agokdbus.txt: Incorporate changes proposed by Michael Kerrisk
Daniel Mack [Tue, 20 Jan 2015 17:16:12 +0000 (18:16 +0100)]
kdbus.txt: Incorporate changes proposed by Michael Kerrisk

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agodoc: Assorted typo fixes
Rémi Audebert [Mon, 19 Jan 2015 09:46:23 +0000 (10:46 +0100)]
doc: Assorted typo fixes

Signed-off-by: Rémi Audebert <halfr@lse.epita.fr>
Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agoconnection: kdbus_conn_entry_insert(): fix typo in comment
Sergei Zviagintsev [Wed, 14 Jan 2015 15:30:40 +0000 (18:30 +0300)]
connection: kdbus_conn_entry_insert(): fix typo in comment

Signed-off-by: Sergei Zviagintsev <sergei@s15v.net>
9 years agoconnection: fix typo in kdbus_conn_entry_insert() kernel-doc
Sergei Zviagintsev [Wed, 14 Jan 2015 15:04:02 +0000 (18:04 +0300)]
connection: fix typo in kdbus_conn_entry_insert() kernel-doc

Signed-off-by: Sergei Zviagintsev <sergei@s15v.net>
9 years agohandle: remove useless statement
Rui Miguel Silva [Wed, 14 Jan 2015 11:16:14 +0000 (11:16 +0000)]
handle: remove useless statement

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agohandle: fix memleak on error path
Rui Miguel Silva [Wed, 14 Jan 2015 11:09:35 +0000 (11:09 +0000)]
handle: fix memleak on error path

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agometadata: fix kerneldoc
Daniel Mack [Wed, 14 Jan 2015 11:23:32 +0000 (12:23 +0100)]
metadata: fix kerneldoc

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agokdbus.h: fix kernel-doc for struct kdbus_cmd_recv
Sergei Zviagintsev [Tue, 13 Jan 2015 13:52:21 +0000 (16:52 +0300)]
kdbus.h: fix kernel-doc for struct kdbus_cmd_recv

Update kernel-doc according to 'reply' to 'msg' member name change which
has been done in 9eec4fcfbbc7 ("kdbus.h: rename 'reply' to 'msg' in
struct kdbus_cmd_recv").

9 years agodoc: update kdbus.txt
Lukasz Skalski [Tue, 13 Jan 2015 10:44:01 +0000 (11:44 +0100)]
doc: update kdbus.txt

9 years agokdbus.h: rename 'reply' to 'msg' in struct kdbus_cmd_recv
Daniel Mack [Mon, 12 Jan 2015 17:09:05 +0000 (18:09 +0100)]
kdbus.h: rename 'reply' to 'msg' in struct kdbus_cmd_recv

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agometadata: two trivial checkpatch.pl fixes
Daniel Mack [Mon, 12 Jan 2015 15:31:55 +0000 (16:31 +0100)]
metadata: two trivial checkpatch.pl fixes

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoChangelog: add entry about namespaces support in the test framework
Djalal Harouni [Mon, 12 Jan 2015 15:12:41 +0000 (16:12 +0100)]
Changelog: add entry about namespaces support in the test framework

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agokdbus: add myself to copyright
Djalal Harouni [Mon, 12 Jan 2015 14:51:57 +0000 (15:51 +0100)]
kdbus: add myself to copyright

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agoChangelog: document kdbus-test --tap
Daniel Mack [Mon, 12 Jan 2015 14:19:36 +0000 (15:19 +0100)]
Changelog: document kdbus-test --tap

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agokdbus: drop KDBUS_HELLO_UNPRIVILEGED (API break)
David Herrmann [Mon, 12 Jan 2015 13:29:55 +0000 (14:29 +0100)]
kdbus: drop KDBUS_HELLO_UNPRIVILEGED (API break)

This flag is unused and we have no real use-case for it. Drop it.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoconnection: fix dead-lock on policy-removal
David Herrmann [Mon, 12 Jan 2015 11:39:03 +0000 (12:39 +0100)]
connection: fix dead-lock on policy-removal

If we clear the policy-db on last kdbus_conn_unref(), we have to take the
policy semaphore. However, we allow calling kdbus_conn_unref() while
holding a connection lock. This might deadlock against normal policy-db
modifications.

Therefore, we move policy-setup _after_ kdbus_conn_connect() and ensure
the connection is active. Then we can move the policy-removal into
kdbus_conn_disconnect(), which itself must never be called while holding
any lock.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agometadata: fix ATTACH_EXE without exe_file
David Herrmann [Mon, 12 Jan 2015 11:17:25 +0000 (12:17 +0100)]
metadata: fix ATTACH_EXE without exe_file

It's possible that processes don't have exe_file set. Make sure we don't
fail then.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agobus: dont broadcast process-metadata on faked credentials
David Herrmann [Sun, 11 Jan 2015 11:39:05 +0000 (12:39 +0100)]
bus: dont broadcast process-metadata on faked credentials

For unicasts, we correctly suppress process metadata if they are faked.
They ought to be read via GET_CONN_INFO. However, for broadcasts and
eavesdropping we didn't do this, yet. Fix that!

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agometadata: major overhaul to fix several bugs
David Herrmann [Sun, 11 Jan 2015 01:16:19 +0000 (02:16 +0100)]
metadata: major overhaul to fix several bugs

The current metadata implementation suffers from several bugs:

1) If we run GET_CONN_INFO, we take the metadata object of the connection
and try to augment it with owned-names and the connection-description. We
do this unlocked on a _shared_ metadata object. This breaks parallel
GET_CONN_INFO calls as someone else might be calling kdbus_meta_export()
in parallel.

2) If we send a broadcast, we create a new metadata object that we fill
with information. Then, for each target, we collect further information
and queue it on the target. However, if a message is queued on target A
and it already tries to dequeue it while the broadcast still continues on
target B, we again get a collect vs. export race.

As I assumed we use faked-metadata as base for messages, too, I started to
split the metadata object into meta_proc and meta_conn. This turned out to
be not needed, but I thought it's a nice split and allows us to reduce
bus->meta and conn->meta to meta_proc, instead of meta_conn. If people
don't like it, we can revert it again. But the added code is minimal.

Anyway, the real fixes of this commit are:
 * meta objects have a lock now. This lock is held during updates *only*.
   During export, we only retrieve the "collected" flag and then can be
   sure that we can access the properly collected fields without races and
   without holding the lock.
 * meta objects distinguish "collected" and "valid" flags now. This fixes
   a race where we try to add owned-names, but a connection doesn't own
   names. On the next broadcast target, we try again and at this time the
   connection owns names. Thus, we would send the message with different
   information to different targets. To avoid this, we now set "collected"
   when we collected a flag without errors, but we only set "valid" if we
   collected it *AND* it is non-empty.
   This way, we will never collect a field twice, even if it was empty the
   first time.
 * get-conn-info now uses a temporary kdbus_meta_conn object to collect
   the connection related metadata. This is a one-time object, as the data
   is no longer valid afterwards.
 * Lots of random error-path fixes I was too lazy to commit separately (as
   they were mostly overwritten by further rewrites).
 * Reduce "struct file *exe" to "struct path exe". We really only ever
   accessed exe->f_path, so no need to pin the whole file. It's enough to
   pin the underlying inode via the path.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoitem: improve kdbus_item_set()
David Herrmann [Sun, 11 Jan 2015 01:09:02 +0000 (02:09 +0100)]
item: improve kdbus_item_set()

Two improvements:
 - Return the next item as return value
 - Clear padding even if @data is given

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agometadata: warn if collected names are ill-formatted
David Herrmann [Sat, 10 Jan 2015 12:38:48 +0000 (13:38 +0100)]
metadata: warn if collected names are ill-formatted

Make sure we properly collect owned-names items, just like we verify all
our other item generators.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agotest-attach-flags: make sure to restore kdbus attach_flags_mask on errors
Djalal Harouni [Fri, 9 Jan 2015 22:18:45 +0000 (23:18 +0100)]
test-attach-flags: make sure to restore kdbus attach_flags_mask on errors

If one of the test fails, then always restore
/sys/module/kdbus/parameters/attach_flags_mask to its previous saved
value.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agotest: set /proc/$pid/setgroups to 'deny' before writing to .../gid_map
Daniel Mack [Fri, 9 Jan 2015 19:09:40 +0000 (20:09 +0100)]
test: set /proc/$pid/setgroups to 'deny' before writing to .../gid_map

Since Linux 3.19-rc1, it is necessary to disable setgroups permissions
before writing to gid_map. Silently ignore if 'setgroups' can't be
opened or written to.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoconnection: provide kdbus_conn_assert_active() wrapper
David Herrmann [Fri, 9 Jan 2015 18:05:42 +0000 (19:05 +0100)]
connection: provide kdbus_conn_assert_active() wrapper

Avoid depending on lockdep internals everywhere. Use
kdbus_conn_assert_active() to check whether the caller holds an active
reference.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agonames: fix total length of kvecs
Daniel Mack [Fri, 9 Jan 2015 18:03:34 +0000 (19:03 +0100)]
names: fix total length of kvecs

Don't let kdbus_pool_slice_alloc() copy the kvecs along with allocating
the slice. The problem is that we only want to copy the header of the
block in this case, which doesn't work when the implicit behavior is
used.

Hence, open-code the functionality. Fixes an Ooops on 3.19-rc3.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agokdbus-util: all_ids_are_mapped() do not leak an fd
Djalal Harouni [Fri, 9 Jan 2015 15:19:18 +0000 (16:19 +0100)]
kdbus-util: all_ids_are_mapped() do not leak an fd

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agomessage: simplify -EMSGSIZE test
Daniel Mack [Fri, 9 Jan 2015 14:12:39 +0000 (15:12 +0100)]
message: simplify -EMSGSIZE test

Simplify the code a bit and check for pool size overflows after we did
the modulo operation.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agometadata: cosmetics
Daniel Mack [Fri, 9 Jan 2015 14:07:03 +0000 (15:07 +0100)]
metadata: cosmetics

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoAssorted spelling fixes
Daniel Mack [Fri, 9 Jan 2015 14:02:18 +0000 (15:02 +0100)]
Assorted spelling fixes

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoconnection, reply: move worker function to reply.h
Daniel Mack [Fri, 9 Jan 2015 12:52:10 +0000 (13:52 +0100)]
connection, reply: move worker function to reply.h

Change kdbus_reply_list_scan() so it becomes the worker callback, so we
can remove the the glue from connection.c.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoconnection: simplify kdbus_conn_lock2()
David Herrmann [Fri, 9 Jan 2015 00:21:37 +0000 (01:21 +0100)]
connection: simplify kdbus_conn_lock2()

Drop 6 lines again and move the conditions directly before the lock
invokations.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agomessage: allow bloom filters with unicast signals
David Herrmann [Thu, 8 Jan 2015 23:58:26 +0000 (00:58 +0100)]
message: allow bloom filters with unicast signals

Make sure unicast signals can have bloom-filters attached.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoconnection: fix kdbus_conn_lock2() for A==B
David Herrmann [Thu, 8 Jan 2015 23:36:38 +0000 (00:36 +0100)]
connection: fix kdbus_conn_lock2() for A==B

In odd cases (eg., sending a message to yourself), you might call
kdbus_conn_lock2() with A==B. Make sure we lock the connection only once
to not dead-lock.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoconnection: simplify kdbus_conn_lock2()
David Herrmann [Thu, 8 Jan 2015 23:16:04 +0000 (00:16 +0100)]
connection: simplify kdbus_conn_lock2()

We can use mutex_lock_nested() in both cases, so simplify the code.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoconnection: silence lockdep on wrongly _nested() calls
David Herrmann [Thu, 8 Jan 2015 23:12:42 +0000 (00:12 +0100)]
connection: silence lockdep on wrongly _nested() calls

If we call lock2() with a==NULL, we call _nested(1), which is wrong. Fix
this so lockdep works correctly.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoconnection: add extra ref to reply while operating on it
Daniel Mack [Thu, 8 Jan 2015 18:58:31 +0000 (19:58 +0100)]
connection: add extra ref to reply while operating on it

kdbus_reply_unlink() potentially destroys the reply, so keep an
extra reference while working with it. Drop the reference after
we're done.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agohandle: properly reset output arguments to 0
David Herrmann [Thu, 8 Jan 2015 16:06:40 +0000 (17:06 +0100)]
handle: properly reset output arguments to 0

Make sure all output arguments are set to 0 so we can copy them once we're
done with the ioctl, regardless whether they were set previously.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agometadata: simplify OOM check for cmdline
Daniel Mack [Thu, 8 Jan 2015 16:34:39 +0000 (17:34 +0100)]
metadata: simplify OOM check for cmdline

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoreply: fix ref-leak
David Herrmann [Thu, 8 Jan 2015 15:57:30 +0000 (16:57 +0100)]
reply: fix ref-leak

Introduce kdbus_reply_link/unlink() which take care of the list-owned
reference to the reply object. Fix all the callsides to use it and
properly let each caller own its own reference now. We no longer have to
be aware of the queue-state at all times, instead, the list-state owns its
own reference.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoconnection: remove redundant variable
David Herrmann [Thu, 8 Jan 2015 15:45:10 +0000 (16:45 +0100)]
connection: remove redundant variable

'allowed' is equivalent to '!!r' so drop it.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agometadata: fix stray blank line
Daniel Mack [Thu, 8 Jan 2015 13:47:03 +0000 (14:47 +0100)]
metadata: fix stray blank line

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agometadata: fix kerneldoc
Daniel Mack [Thu, 8 Jan 2015 13:45:42 +0000 (14:45 +0100)]
metadata: fix kerneldoc

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoreply: add kerneldoc
Daniel Mack [Thu, 8 Jan 2015 13:44:12 +0000 (14:44 +0100)]
reply: add kerneldoc

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoconnection: store reply trackers at reply_dst side
Daniel Mack [Thu, 8 Jan 2015 13:14:14 +0000 (14:14 +0100)]
connection: store reply trackers at reply_dst side

We are currently storing the reply objects at the connection that is
expected to send the reply. This raises some problems with interrupted
system calls when the message receiver name is taken over while the
sender has returned to userspace, before it restarts the syscall. If
the name is not taken over, but the receiver simply dies at this time,
we even leak the kdbus_reply object.

Fix this by storing the replies with the sending (and possibly
blocking) connection, as this is really where they belong. However,
this means that when moving messages, or when a connection dies, we
have to walk all connection on the bus in order to find pending replies
that point back to the connection in question. This can be optimized
with a second list, but I left that for later.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoconnection.h: make kdbus_conn_{un,}lock2() NULL pointer resistant
Daniel Mack [Thu, 8 Jan 2015 13:12:36 +0000 (14:12 +0100)]
connection.h: make kdbus_conn_{un,}lock2() NULL pointer resistant

Allow NULL pointers in both arguments to kdbus_conn_lock2() and
kdbus_conn_unlock2().

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agotest-message: messages that impersonate method replies are rejected
Djalal Harouni [Wed, 7 Jan 2015 23:25:06 +0000 (00:25 +0100)]
test-message: messages that impersonate method replies are rejected

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agoreply: fix kerneldoc indentation
Djalal Harouni [Wed, 7 Jan 2015 23:12:50 +0000 (00:12 +0100)]
reply: fix kerneldoc indentation

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agoreply: coding style cleanup
Daniel Mack [Wed, 7 Jan 2015 20:32:44 +0000 (21:32 +0100)]
reply: coding style cleanup

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoChangelog: update
Daniel Mack [Wed, 7 Jan 2015 20:28:00 +0000 (21:28 +0100)]
Changelog: update

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoFactor out reply related bits to reply.[ch]
Daniel Mack [Wed, 7 Jan 2015 20:02:36 +0000 (21:02 +0100)]
Factor out reply related bits to reply.[ch]

Move some code from connection.c to reply.c for better separation.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agoconnection: rename kdbus_reply → kdbus_conn_reply
Daniel Mack [Wed, 7 Jan 2015 19:44:07 +0000 (20:44 +0100)]
connection: rename kdbus_reply → kdbus_conn_reply

Drop the 'conn' part of the name, as it doesn't make sense.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agokdbus.h: rename kdbus_reply → kdbus_msg_info (API break)
Daniel Mack [Wed, 7 Jan 2015 19:41:08 +0000 (20:41 +0100)]
kdbus.h: rename kdbus_reply → kdbus_msg_info (API break)

Rename struct kdbus_reply and call it kdbus_msg_info, as the old
name didn't describe well what the struct is used for.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agometadata: fix seqnum on kernel notifications
David Herrmann [Wed, 7 Jan 2015 19:38:02 +0000 (20:38 +0100)]
metadata: fix seqnum on kernel notifications

The seqnum ID is passed together with the timestamps. Therefore, move the
"u64 seq" argument to kdbus_meta_add_timestamp(). As the seqnum is not
known at message allocation time, we now also move the
kdbus_meta_add_timestamp() to the time we actually allocate the ID.

This fixes seqnum IDs on kernel notifications.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoconnection: unlock order doesn't matter
David Herrmann [Wed, 7 Jan 2015 17:41:32 +0000 (18:41 +0100)]
connection: unlock order doesn't matter

Make kdbus_conn_unlock2() just unlock both mutices, unlock order never
matters.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoconnection: use current_cred() for sender policy checks
David Herrmann [Wed, 7 Jan 2015 17:23:56 +0000 (18:23 +0100)]
connection: use current_cred() for sender policy checks

This changes the policy-decisions for sender-initiated actions to use
current_cred() instead of conn->cred. This means, policy decisions for
ioctls will use the current credentials, instead of the credentials during
open().

On the other hand, receiver credentials are now bound to the pool used for
retrieval of the messages. Therefore, broadcasts and implicit policies are
checked against the file credentials of the target.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agopolicy: use egid instead of gid
David Herrmann [Wed, 7 Jan 2015 17:18:41 +0000 (18:18 +0100)]
policy: use egid instead of gid

Same as for UIDs, use EGID instead of GID to perform policy checks.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agonames: fix uninitialized return value
David Herrmann [Wed, 7 Jan 2015 16:50:28 +0000 (17:50 +0100)]
names: fix uninitialized return value

A recent commit dropped the initialization of 'ret' so now it is returned
uninitialized. Fix this!

The commit in question is:

    commit de18809ec40380e0d4681141281555f7df35b303
    Author: Daniel Mack <daniel@zonque.org>
    Date:   Wed Jan 7 15:48:54 2015 +0100

        names: ignore return value of kdbus_notify_name_change

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoconnection: introduce kdbus_conn_lock2()
David Herrmann [Wed, 7 Jan 2015 16:44:37 +0000 (17:44 +0100)]
connection: introduce kdbus_conn_lock2()

Lets not hard-code locking behavior of connections somewhere deep down in
names.c. Use kdbus_conn_lock2() to lock 2 connections at the same time.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoChangelog: some more updates
Daniel Mack [Wed, 7 Jan 2015 15:23:52 +0000 (16:23 +0100)]
Changelog: some more updates

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agonames: don't break lines if we don't have to
Daniel Mack [Wed, 7 Jan 2015 14:51:28 +0000 (15:51 +0100)]
names: don't break lines if we don't have to

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agonames: ignore return value of kdbus_notify_name_change
Daniel Mack [Wed, 7 Jan 2015 14:48:54 +0000 (15:48 +0100)]
names: ignore return value of kdbus_notify_name_change

If we cannot notify connections about a lost name, just continue.
Releasing a name with CMD_NAME_RELEASE should never fail because of
such a condition.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agomessage: messages that expect a reply must provide a valid tracking cookie
Djalal Harouni [Wed, 7 Jan 2015 13:33:29 +0000 (14:33 +0100)]
message: messages that expect a reply must provide a valid tracking cookie

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agotest: test case for pending requests quota limit
Djalal Harouni [Wed, 7 Jan 2015 13:16:20 +0000 (14:16 +0100)]
test: test case for pending requests quota limit

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agoRemove TODO
Daniel Mack [Wed, 7 Jan 2015 12:59:44 +0000 (13:59 +0100)]
Remove TODO

These have all been addressed or discussed, so the file can go away.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agokdbus: drop KDBUS_ITEM_SIGMASK
David Herrmann [Wed, 7 Jan 2015 12:30:28 +0000 (13:30 +0100)]
kdbus: drop KDBUS_ITEM_SIGMASK

The sigset_t type is arch-dependent. We really don't want such types in
our kdbus API. Our CANCEL_FD provides a safe alternative, so use it.

If anyone wants SIGMASK support later on, we can always add it again. But
unless someone wants it, we will try hard to keep it out of kdbus.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agoRevert commit f198a45 "kdbus.h: Use #defines rather than an enum..."
David Herrmann [Wed, 7 Jan 2015 11:49:48 +0000 (12:49 +0100)]
Revert commit f198a45 "kdbus.h: Use #defines rather than an enum..."

This reverts commit:

    commit f198a45e3242a4825e1e720c0637a151a6ef5e0d
    Author: Daniel Mack <daniel@zonque.org>
    Date:   Fri Oct 31 09:03:16 2014 +0100

        kdbus.h: Use #defines rather than an enum for ioctl definition

If you want to discover available features, use autoconf.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
9 years agotest: standarize the userns arguments
Djalal Harouni [Tue, 6 Jan 2015 20:55:08 +0000 (21:55 +0100)]
test: standarize the userns arguments

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agoconnection: for KDBUS_MSG_SIGNAL check match db then the policy db
Djalal Harouni [Mon, 5 Jan 2015 19:33:56 +0000 (20:33 +0100)]
connection: for KDBUS_MSG_SIGNAL check match db then the policy db

Minor optimization, before locking the endpoint policy db in order to
check for TALK access, check first that the destination match db is
interested in the signal.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agoconnection: code documentation for the signal access logic
Djalal Harouni [Mon, 5 Jan 2015 14:08:26 +0000 (15:08 +0100)]
connection: code documentation for the signal access logic

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
9 years agoconnection: handle KDBUS_MSG_SIGNAL
Daniel Mack [Mon, 5 Jan 2015 13:32:26 +0000 (14:32 +0100)]
connection: handle KDBUS_MSG_SIGNAL

Add missed hunks for handling KDBUS_MSG_SIGNAL.

Signed-off-by: Daniel Mack <daniel@zonque.org>
9 years agokdbus.h: close ioctl number gap (ABI break)
Daniel Mack [Mon, 5 Jan 2015 12:38:31 +0000 (13:38 +0100)]
kdbus.h: close ioctl number gap (ABI break)

0x32 was used by KDBUS_CMD_CANCEL which was removed.
Close the number gap and reuse that number for CMD_FREE.

Signed-off-by: Daniel Mack <daniel@zonque.org>