platform/core/system/kdbus-bus.git
9 years agoBump version to 0.20140911.160207utc sandbox/lstelmach/kdbus-integration-systemd-216 submit/kdbus-integration/20141211.130918
Łukasz Stelmach [Mon, 17 Nov 2014 15:04:07 +0000 (16:04 +0100)]
Bump version to 0.20140911.160207utc

Change-Id: I0dada209f1ae7271fc4c1934ec024ed5791536e6
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
9 years agospec: fix unifdef exit status detection
Łukasz Stelmach [Mon, 17 Nov 2014 15:04:35 +0000 (16:04 +0100)]
spec: fix unifdef exit status detection

Change-Id: I6b6507d1fe362d0f8b91a07be2c9a3697c01edf6
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
9 years agoAdd a script to update Version automatically
Łukasz Stelmach [Mon, 17 Nov 2014 15:04:16 +0000 (16:04 +0100)]
Add a script to update Version automatically

The script derives the package version from the upstream commit used as
a base for the package release. Proper upstream/ tag is also created.

Change-Id: I66987c225bb4a994c0312f4cf6a3f537cd8130f0
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
9 years agoRevert "metadata: drop support for kernels < v3.15"
Łukasz Stelmach [Wed, 12 Nov 2014 11:44:21 +0000 (12:44 +0100)]
Revert "metadata: drop support for kernels < v3.15"

This reverts commit 53711b606ed83f9b8dd7dc1f3832a01bd6409d79.

9 years agoRevert "metadata: follow 3.17 changes for current->start_time"
Łukasz Stelmach [Wed, 12 Nov 2014 11:07:57 +0000 (12:07 +0100)]
Revert "metadata: follow 3.17 changes for current->start_time"

This reverts commit 47971994 to make kdbus work on 3.14 again.

Conflicts:
metadata.c

Change-Id: I6999069a4e4b0bb8632cdbe86e25bacdbcfc8742

9 years agoUpdate to 0.20140325.112233cet
Maciej Wereski [Thu, 8 May 2014 11:31:19 +0000 (13:31 +0200)]
Update to 0.20140325.112233cet

Change-Id: I09d20fe82a92eb0b9cda81b882d622b496b9cc6b
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
9 years agoUpdate to 0.20140224.202407cet
Maciej Wereski [Wed, 5 Mar 2014 08:51:02 +0000 (09:51 +0100)]
Update to 0.20140224.202407cet

Change-Id: Ie211816178580e54b84af375e74f2bcb0e30b1d6
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
9 years agoUpdate to 0.20140221.145534cet
Maciej Wereski [Tue, 25 Feb 2014 11:48:50 +0000 (12:48 +0100)]
Update to 0.20140221.145534cet

Change-Id: I4be4430dcdbc7d2bba288906d377a912f14c11a5
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
9 years agopackaging: Use date-based version string
Karol Lewandowski [Mon, 27 Jan 2014 13:22:22 +0000 (14:22 +0100)]
packaging: Use date-based version string

kdbus doesn't have any release version we could use, fall back
to 0.<DATE>.<TIME> format for packaging purposes.

9 years agopackaging: Bump release
Karol Lewandowski [Fri, 24 Jan 2014 16:10:52 +0000 (17:10 +0100)]
packaging: Bump release

9 years agopackaging: Rename .spec to match real package name
Karol Lewandowski [Fri, 24 Jan 2014 16:09:48 +0000 (17:09 +0100)]
packaging: Rename .spec to match real package name

9 years agopackaging: Fix various rpmlint errors
Karol Lewandowski [Fri, 24 Jan 2014 16:09:22 +0000 (17:09 +0100)]
packaging: Fix various rpmlint errors

9 years agopackaging: Bump version
Karol Lewandowski [Fri, 24 Jan 2014 15:45:52 +0000 (16:45 +0100)]
packaging: Bump version

9 years agoBring task_cgroup_path_from_hierarchy() back for pre-3.11 compatiblity
Karol Lewandowski [Mon, 28 Oct 2013 15:09:04 +0000 (16:09 +0100)]
Bring task_cgroup_path_from_hierarchy() back for pre-3.11 compatiblity

This commit partially reverts ea2b8c798cd34149fa13010d24 ("message.c:
task_cgroup_path_from_hierarchy is now in 3.11-rc1, so remove it from
here").

We still require it for pre-3.11 kernels that Tizen is shipping.

Change-Id: I05568c5d8d473bb5257d3aa64f8a84b03e6da117
Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
9 years agoRebase to newest upstream and bump version
Karol Lewandowski [Wed, 22 Jan 2014 17:53:03 +0000 (18:53 +0100)]
Rebase to newest upstream and bump version

Rebased on top of 761aff75b ("connection: kill unneeded include").

9 years agopackaging: Provide -devel package with kdbus.h
Karol Lewandowski [Wed, 22 Jan 2014 16:49:11 +0000 (17:49 +0100)]
packaging: Provide -devel package with kdbus.h

9 years agopackaging: Fix spec to make kdbus work on ivi
Karol Lewandowski [Fri, 3 Jan 2014 17:28:24 +0000 (18:28 +0100)]
packaging: Fix spec to make kdbus work on ivi

9 years agoAdd packaging to kdbus-bus package to be build from obs/gbs.
Karol Lewandowski [Fri, 3 Jan 2014 14:25:40 +0000 (15:25 +0100)]
Add packaging to kdbus-bus package to be build from obs/gbs.

Change-Id: I3b630841956115d20e3d12a2d7dad45f21a2d75e
Signed-off-by: Jacek Pielaszkiewicz <j.pielaszkie@samsung.com>
[ Rebased to newest upstream ]
Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
10 years agokdbus.txt: document wildcard policy entries upstream/0.20140911.160207utc
Daniel Mack [Thu, 11 Sep 2014 16:02:07 +0000 (18:02 +0200)]
kdbus.txt: document wildcard policy entries

10 years agomatch: make kdbus_match_db_remove() void
Daniel Mack [Thu, 11 Sep 2014 15:34:52 +0000 (17:34 +0200)]
match: make kdbus_match_db_remove() void

10 years agoconnection: allow wildcard matches for policy holders
Daniel Mack [Thu, 11 Sep 2014 15:34:52 +0000 (17:34 +0200)]
connection: allow wildcard matches for policy holders

10 years agoconnection: reformat
Daniel Mack [Thu, 11 Sep 2014 15:32:42 +0000 (17:32 +0200)]
connection: reformat

10 years agoendpoint: cosmetics
Daniel Mack [Thu, 11 Sep 2014 15:32:11 +0000 (17:32 +0200)]
endpoint: cosmetics

10 years agoconnection: check return value of kdbus_meta_append()
Daniel Mack [Thu, 11 Sep 2014 15:10:29 +0000 (17:10 +0200)]
connection: check return value of kdbus_meta_append()

10 years agoconnection: return -EOPNOTSUPP if the connection has already died
Daniel Mack [Thu, 11 Sep 2014 14:38:35 +0000 (16:38 +0200)]
connection: return -EOPNOTSUPP if the connection has already died

10 years agokdbus.txt: add more documentation
Daniel Mack [Wed, 10 Sep 2014 12:45:21 +0000 (14:45 +0200)]
kdbus.txt: add more documentation

10 years agomatch: don't fail on invalid item types
Daniel Mack [Wed, 10 Sep 2014 16:03:52 +0000 (18:03 +0200)]
match: don't fail on invalid item types

10 years agonotify: explictly set payload_type = KDBUS_PAYLOAD_KERNEL
Daniel Mack [Wed, 10 Sep 2014 12:26:19 +0000 (14:26 +0200)]
notify: explictly set payload_type = KDBUS_PAYLOAD_KERNEL

10 years agokdbus.txt: kill reference to sd-memfd.h
Daniel Mack [Tue, 9 Sep 2014 12:38:02 +0000 (14:38 +0200)]
kdbus.txt: kill reference to sd-memfd.h

10 years agopolicy: make policy checks work across user namespaces
Djalal Harouni [Mon, 8 Sep 2014 13:18:26 +0000 (14:18 +0100)]
policy: make policy checks work across user namespaces

Use the global kuid_t and kgid_t to store uid/gid values, this way we
our policy checks will work across user namespaces.

Note that currently we ignore that the user is privileged in its own
namespaces and the policy access kuid_t and kgid_t were mapped into that
namespace. If this is requested we can add it later a la:
fs/inode.c:inode_owner_or_capable()

Add kdbus_policy_make_access() to convert the user provided info to the
current user namespace. Userspace struct is not changed, only the kernel
one.

This patch fixes test #8 of test-kdbus-policy

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
[daniel: group kdbus_policy_db_entry_access->{uid,gid} in a union]

10 years agoconnection: factor out queue management code to queue.c
Daniel Mack [Mon, 8 Sep 2014 15:14:46 +0000 (17:14 +0200)]
connection: factor out queue management code to queue.c

Move code that deals with the message queue and its items into queue.c.
This way, we can work towards a cleaner structure and cut down connection.c
which has grown too big.

The sepearation is not really strict at this point, and might see some
more cleanups in the future.

10 years agoconnection: rename 'entry' variable in kdbus_conn_kmsg_send()
Daniel Mack [Mon, 8 Sep 2014 13:54:38 +0000 (15:54 +0200)]
connection: rename 'entry' variable in kdbus_conn_kmsg_send()

10 years agotest: update policy tests to handle user namespaces
Djalal Harouni [Mon, 8 Sep 2014 13:18:25 +0000 (14:18 +0100)]
test: update policy tests to handle user namespaces

Upstream kernels allow unprivileged users to create user namespaces
and change their uid/gid.

These patches update kdbus policy logic to handle this case and
improve our current checks across user namespaces.

So this patch adds:

* kdbus_test_waitpid() to get exit code of childs.
* kdbus_clone_userns_test() that performs the test inside a new
  user namespace.
* Converts all the other tests to return CHECK_OK, CHECK_SKIP or
  CHECK_ERR so we are consistent.

Currently we fail at kdbus_clone_userns_test() test #8. The next patch
will fix this issue.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agopolicy: indent
Daniel Mack [Fri, 5 Sep 2014 16:44:07 +0000 (18:44 +0200)]
policy: indent

10 years agoconnection: check policy for reply-awaiting messages as well
Daniel Mack [Fri, 5 Sep 2014 16:39:57 +0000 (18:39 +0200)]
connection: check policy for reply-awaiting messages as well

The current logic in bogus. We need to call kdbus_conn_check_access()
for messages that require a message as well. Also, teach
kdbus_conn_check_access() a mode in which not to look up expected
replies of a connection.

10 years agoconnection: drop unused argument of kdbus_conn_payload_add()
Daniel Mack [Sun, 24 Aug 2014 16:17:46 +0000 (18:17 +0200)]
connection: drop unused argument of kdbus_conn_payload_add()

10 years agometadata: kdbus_meta_append_auxgroups(): actually set the group ids
Daniel Mack [Wed, 20 Aug 2014 20:53:48 +0000 (22:53 +0200)]
metadata: kdbus_meta_append_auxgroups(): actually set the group ids

As we need metadata in other context than queue items, we don't want
to rely on the queue item logic to clean up after us and fix up the
values. For now, add back the code to actually fill the payload. We
might add code to make the queue patching conditional later.

10 years agotest: use audit.loginuid and audit.sessionid when dumping the audit item
Djalal Harouni [Wed, 20 Aug 2014 16:41:03 +0000 (17:41 +0100)]
test: use audit.loginuid and audit.sessionid when dumping the audit item

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agokdbus: do the audit loginuid translation as late as possible
Djalal Harouni [Wed, 20 Aug 2014 15:58:57 +0000 (16:58 +0100)]
kdbus: do the audit loginuid translation as late as possible

Do the namespace translation just before pushing into the receiver's
slice, so we map to the receiver's user namespace.

Patch tested.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agometadata: add back code to fill creds data
Daniel Mack [Tue, 19 Aug 2014 17:04:42 +0000 (19:04 +0200)]
metadata: add back code to fill creds data

It was overlooked that metadata is also used for connection info calls.
Until we find a nicer way, just do the creds assigment in this item twice:
once at metadata creation time, and again when we deliver the message.

10 years agoRevert "test/Makefile: only look at $(KERNELDIR)/usr/include for files with quotes"
Daniel Mack [Tue, 19 Aug 2014 14:22:53 +0000 (16:22 +0200)]
Revert "test/Makefile: only look at $(KERNELDIR)/usr/include for files with quotes"

This reverts commit baeb2d8bbf2360524d4104ea851407a14085cef9.

Turns out this confuses cpp even more.

For now, people have to to 'make headers_install' in the kernel dir before
building kdbus.

10 years agotest/Makefile: only look at $(KERNELDIR)/usr/include for files with quotes
Daniel Mack [Tue, 19 Aug 2014 13:19:40 +0000 (15:19 +0200)]
test/Makefile: only look at $(KERNELDIR)/usr/include for files with quotes

This is a hack to make cpp look at system include files first, and then
consult $(KERNELDIR)/usr/include. For this to work, include directives
referring to files in uapi have to be addressed with quotes.

10 years agoMakefile: deal with realtive paths in test/
Daniel Mack [Tue, 19 Aug 2014 12:50:06 +0000 (14:50 +0200)]
Makefile: deal with realtive paths in test/

Invoke realpath to convert a possible relative path into an absolute one.

10 years agoMakefile: export KERNELDIR for tests
Daniel Mack [Tue, 19 Aug 2014 11:42:53 +0000 (13:42 +0200)]
Makefile: export KERNELDIR for tests

We include linux/memfd.h now, make sure it's searched for in $KERNELDIR.

10 years agotest: add the metadata tests inside new namespaces
Djalal Harouni [Mon, 18 Aug 2014 16:59:20 +0000 (17:59 +0100)]
test: add the metadata tests inside new namespaces

Currently this only handles user namespace. Use it to inspect the
dumped metadata/credentials.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agotest: add conn_recv() that use poll() and msg_recv()
Djalal Harouni [Mon, 18 Aug 2014 16:13:10 +0000 (17:13 +0100)]
test: add conn_recv() that use poll() and msg_recv()

Will be used by tests.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agotest: move shared definitions to kdbus-util.h to use them in other tests
Djalal Harouni [Mon, 18 Aug 2014 10:59:59 +0000 (11:59 +0100)]
test: move shared definitions to kdbus-util.h to use them in other tests

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agotest: add helpers for user namespace mapping
Djalal Harouni [Mon, 18 Aug 2014 14:38:03 +0000 (15:38 +0100)]
test: add helpers for user namespace mapping

Will be used by other tests.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agoconnection: move the install creds into the slice to its own function
Djalal Harouni [Tue, 19 Aug 2014 01:43:57 +0000 (02:43 +0100)]
connection: move the install creds into the slice to its own function

Move the install creds into the receiver's slice to its own function
kdbus_conn_creds_install().

Use from_kuid_munged(), so the uid mapping never fails.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agometadata: document creds_item_off and auxgrps_item_off fields
Djalal Harouni [Tue, 19 Aug 2014 01:43:56 +0000 (02:43 +0100)]
metadata: document creds_item_off and auxgrps_item_off fields

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agohandle: return POLLOUT | POLLWRNORM from kdbus_handle_poll()
Daniel Mack [Mon, 18 Aug 2014 15:07:49 +0000 (17:07 +0200)]
handle: return POLLOUT | POLLWRNORM from kdbus_handle_poll()

Also return POLLOUT | POLLWRNORM from kdbus_handle_poll() when a message
arrived. IOW: in all non-error conditions.

10 years agometadata: drop support for kernels < v3.15
Daniel Mack [Tue, 12 Aug 2014 10:35:50 +0000 (12:35 +0200)]
metadata: drop support for kernels < v3.15

10 years agoKconfig: depend on TMPFS
Daniel Mack [Mon, 11 Aug 2014 09:31:25 +0000 (11:31 +0200)]
Kconfig: depend on TMPFS

10 years agotest: adopt new memfd interface
Daniel Mack [Mon, 12 May 2014 22:28:19 +0000 (00:28 +0200)]
test: adopt new memfd interface

10 years agoswitch to upstream kernel memfd implementation (ABI+API break)
Daniel Mack [Mon, 12 May 2014 12:39:59 +0000 (14:39 +0200)]
switch to upstream kernel memfd implementation (ABI+API break)

Now that a generic memfd solution is merged upstream, drop our own
implementation and switch over.

10 years agometadata: follow 3.17 changes for current->start_time
Daniel Mack [Sat, 9 Aug 2014 08:19:35 +0000 (10:19 +0200)]
metadata: follow 3.17 changes for current->start_time

As of Linux kernel commit 57e0be041d9e21a73 ("sched: Make
task->real_start_time nanoseconds based"), current->start_time is
stored in nanoseconds, so we don't need to do convert anymore.

10 years agometadata: set item->size in kdbus_meta_append_item()
Daniel Mack [Sun, 17 Aug 2014 19:43:25 +0000 (21:43 +0200)]
metadata: set item->size in kdbus_meta_append_item()

This saves us some logic on the call sites.

10 years agometadata: remove kdbus_meta_find_item()
Daniel Mack [Sun, 17 Aug 2014 19:36:22 +0000 (21:36 +0200)]
metadata: remove kdbus_meta_find_item()

Remove kdbus_meta_find_item(), and store offsets of items inside the
metadata in the metadata itself. This is nicer than walking the list again
in order to find a specific element.

10 years agoconnection: drop unused paramenter to kdbus_conn_*_install
Daniel Mack [Sat, 16 Aug 2014 09:58:28 +0000 (11:58 +0200)]
connection: drop unused paramenter to kdbus_conn_*_install

The connection parameter is not used, so drop it from the function's
parameters.

10 years agoconnection: address possible auxgrp count mismatch
Daniel Mack [Sat, 16 Aug 2014 08:54:08 +0000 (10:54 +0200)]
connection: address possible auxgrp count mismatch

The number of auxgrps could theoretically change between the preparation of
the the meta data item and the scan in kdbus_conn_queue_alloc().

Solve this by clamping the number of group elements we look at.

10 years agoutil: introduce KDBUS_ITEM_PAYLOAD_SIZE
Daniel Mack [Sat, 16 Aug 2014 08:53:28 +0000 (10:53 +0200)]
util: introduce KDBUS_ITEM_PAYLOAD_SIZE

Add a simple macro to determine an item's payload size, and use it in
message.c.

10 years agometadata: rename kdbus_meta_offset_of() to kdbus_meta_find_item()
Daniel Mack [Sat, 16 Aug 2014 08:41:09 +0000 (10:41 +0200)]
metadata: rename kdbus_meta_offset_of() to kdbus_meta_find_item()

Return a pointer to the item itself, so we can as well use its size.

10 years agohandle: Return POLLOUT | POLLWRNORM mask when no messages are pending
Marcel Holtmann [Fri, 15 Aug 2014 19:43:37 +0000 (21:43 +0200)]
handle: Return POLLOUT | POLLWRNORM mask when no messages are pending

To facility the feature of doing an asynchronous sending of messages
when the bus is idle, make sure to return POLLOUT | POLLWRNORM from
kdbus_handle_poll.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
10 years agoconnection: fix error rewind exit path in kdbus_conn_msg_install()
Daniel Mack [Fri, 15 Aug 2014 20:08:08 +0000 (22:08 +0200)]
connection: fix error rewind exit path in kdbus_conn_msg_install()

10 years agoconnection, metadata: convert auxgrp information as late as possible
Daniel Mack [Fri, 15 Aug 2014 19:45:10 +0000 (21:45 +0200)]
connection, metadata: convert auxgrp information as late as possible

Same as with the cred block - do the from_kgid() conversion shortly before
installing the message in the receiver's task.

10 years agometadata: allow NULL pointers in kdbus_meta_append_data()
Daniel Mack [Fri, 15 Aug 2014 17:46:10 +0000 (19:46 +0200)]
metadata: allow NULL pointers in kdbus_meta_append_data()

Allow NULL pointers to be passed as data argument to
kdbus_meta_append_data(), so users can use the function to only make space
in the metadata without actually copying any payload.

10 years agoconnection, metadata: do namespace translation as late as possible
Daniel Mack [Fri, 15 Aug 2014 17:22:43 +0000 (19:22 +0200)]
connection, metadata: do namespace translation as late as possible

We have to do the namespace translation just before a message is
installed into the receiver's task, so we actually know about the
currently used pid and user namespaces.

To achive this, store the byte offset pointer in the message in
kdbus_conn_queue_alloc(), and patch the values over from
kdbus_conn_msg_install().

Thanks to Djalal Harouni for pointing this out.

10 years agometadata: add kdbus_meta_offset_of()
Daniel Mack [Fri, 15 Aug 2014 17:20:51 +0000 (19:20 +0200)]
metadata: add kdbus_meta_offset_of()

kdbus_meta_offset_of() will iterate over the given metadata and return
the offset of the item of type @type, if it exists.

10 years agopolicy, connection: rename policy cache related functions
Daniel Mack [Thu, 14 Aug 2014 20:20:54 +0000 (22:20 +0200)]
policy, connection: rename policy cache related functions

Just so they reflect a little better what they're doing.

10 years agopolicy: rename send_access_hash to talk_access_hash
Daniel Mack [Thu, 14 Aug 2014 20:14:49 +0000 (22:14 +0200)]
policy: rename send_access_hash to talk_access_hash

We've already renamed the SEND policy to TALK for more clarity,
so let's do the same with the access hash.

10 years agonames: flush policy TALK cache when a connection loses a name
Daniel Mack [Thu, 14 Aug 2014 14:36:40 +0000 (16:36 +0200)]
names: flush policy TALK cache when a connection loses a name

When a connection loses a name, make sure cache entries that allow
TALK access to it are properly removed. Upon the next TALK query,
the connection's names will be iterated and checked again.

10 years agotest: test-kdbus: fix monitor and byebye tests
Daniel Mack [Thu, 14 Aug 2014 14:14:33 +0000 (16:14 +0200)]
test: test-kdbus: fix monitor and byebye tests

Since commit 7015a1e6 ("prevent special-purpose connections from
owning names or exchanging messages"), ioctl() calls return
-EOPNOTSUPP they are issued to a handle of a inapproprate type.
Follow this change in the test as well.

10 years agobus.h: add missing include to linux/kref.h
Alban Crequy [Thu, 14 Aug 2014 11:13:46 +0000 (12:13 +0100)]
bus.h: add missing include to linux/kref.h

Symptoms:
> kdbus/bus.h:56:14: error: field ‘kref’ has incomplete type
>   struct kref kref;

Signed-off-by: Alban Crequy <alban.crequy@collabora.co.uk>
10 years agopool: remove unneeded semicolon
Daniel Mack [Tue, 12 Aug 2014 13:02:31 +0000 (15:02 +0200)]
pool: remove unneeded semicolon

10 years agometadata: return -EFAULT if get_task_mm(current) fails
Daniel Mack [Sat, 9 Aug 2014 13:00:20 +0000 (15:00 +0200)]
metadata: return -EFAULT if get_task_mm(current) fails

10 years agotest: add test code for KDBUS_ITEM_AUXGROUPS
Daniel Mack [Sat, 9 Aug 2014 12:13:57 +0000 (14:13 +0200)]
test: add test code for KDBUS_ITEM_AUXGROUPS

10 years agometadata: add new item type KDBUS_ITEM_AUXGROUPS (ABI break)
Daniel Mack [Sat, 9 Aug 2014 12:12:51 +0000 (14:12 +0200)]
metadata: add new item type KDBUS_ITEM_AUXGROUPS (ABI break)

Add new data type to dump the auxiliary groups the sending task is a member
of.

10 years agotest: split conn_update() into update attach-flags and update policy
Djalal Harouni [Tue, 5 Aug 2014 01:46:08 +0000 (02:46 +0100)]
test: split conn_update() into update attach-flags and update policy

Since ordinary connections are only interested in the attach-flags and
policy holders in policies, split conn_update() into:
1) conn_update_attach_flags()
2) conn_update_policy()

This way we use the conn_update_policy() function in test-kdbus-policy
with a policy-holding connection and we pass all the tests. This
prevents messing up with the attach-flags.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agoconnection: improve kdbus_cmd_conn_update() connection type checks
Djalal Harouni [Tue, 5 Aug 2014 01:46:07 +0000 (02:46 +0100)]
connection: improve kdbus_cmd_conn_update() connection type checks

Do another round of connection type checks inside the KDBUS_ITEM
iterator.

We need this since we do not want to allow ordinary connections to
update policy entries that belong to another policy holder connection.

We also do it for the attach flags since only ordinary connections are
interessted in it.

And update a kdbus_policy_set() call to only pass a one name per
policy-holding connection

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agohandle: allow KDBUS_CMD_CONN_UPDATE ioctl for policy holders
Djalal Harouni [Tue, 5 Aug 2014 01:46:06 +0000 (02:46 +0100)]
handle: allow KDBUS_CMD_CONN_UPDATE ioctl for policy holders

Allow KDBUS_CMD_CONN_UPDATE for KDBUS_CONN_POLICY_HOLDER connections.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agohandle: return -EOPNOTSUPP instead of -EPERM if an operation is not supported
Djalal Harouni [Tue, 5 Aug 2014 01:09:09 +0000 (02:09 +0100)]
handle: return -EOPNOTSUPP instead of -EPERM if an operation is not supported

If userspace calls in with the wrong connection type, just return
-EOPNOTSUPP instead of -EPERM.

This will not confuse unprivileged and privileged processes, and permits
to identify legitimate -EPERM errors.

This just converts errors introduced in commit 7015a1e6746

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agotest: sync the policy tests with the recent activators and policy holders changes
Djalal Harouni [Tue, 5 Aug 2014 01:09:08 +0000 (02:09 +0100)]
test: sync the policy tests with the recent activators and policy holders changes

Recent commit 7015a1e6746e0c2 prevents special-purpose connections from
owning names, so update the test-kdbus-policy tests to follow and test
these changes.

Create a new policy holder connection which will register the policy for
an X name, and make the first conn_db[0] connection own that name.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agouse conn->type instead of conn->flags where possible
Kay Sievers [Mon, 4 Aug 2014 14:18:08 +0000 (16:18 +0200)]
use conn->type instead of conn->flags where possible

10 years agoprevent special-purpose connections from owning names or exchanging messages
Kay Sievers [Mon, 4 Aug 2014 14:05:39 +0000 (16:05 +0200)]
prevent special-purpose connections from owning names or exchanging messages

10 years agokdbus.h: clarify policy holder docs
Kay Sievers [Thu, 31 Jul 2014 21:02:54 +0000 (23:02 +0200)]
kdbus.h: clarify policy holder docs

10 years agodo not use __ prefix for ordinary functions
Kay Sievers [Thu, 31 Jul 2014 15:15:13 +0000 (17:15 +0200)]
do not use __ prefix for ordinary functions

10 years agodomain: add BUG_ON()
Kay Sievers [Thu, 31 Jul 2014 14:59:27 +0000 (16:59 +0200)]
domain: add BUG_ON()

10 years agodo not use __ prefix for ordinary functions
Kay Sievers [Thu, 31 Jul 2014 14:52:50 +0000 (16:52 +0200)]
do not use __ prefix for ordinary functions

10 years agotest: do not use __ prefix for ordinary functions
Kay Sievers [Thu, 31 Jul 2014 14:51:08 +0000 (16:51 +0200)]
test: do not use __ prefix for ordinary functions

10 years agodomain: remove dead kdbus_domain_user_find_or_new()
Djalal Harouni [Wed, 30 Jul 2014 20:11:58 +0000 (21:11 +0100)]
domain: remove dead kdbus_domain_user_find_or_new()

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agoconnection: fix user quota accounting corruption
Djalal Harouni [Wed, 30 Jul 2014 20:11:57 +0000 (21:11 +0100)]
connection: fix user quota accounting corruption

First use kzalloc to allocate the users array, so we do not reference
unintialized values.

And free the old conn->msg_users array not the newly allocated 'users'
one.

Patch tested, and users will hit the KDBUS_CONN_MAX_MSGS_PER_USER limit
and fail with -ENOBUFS

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agobus: improve user quota accounting and domain locking
Djalal Harouni [Wed, 30 Jul 2014 20:11:56 +0000 (21:11 +0100)]
bus: improve user quota accounting and domain locking

Currently kdbus_bus_new() execution path might take the domain lock
three times on success, four times on failure.

kdbus_bus_new():
  => kdbus_domain_user_find_or_new(): takes it 2 times (and it is racy)
  +
  kdbus_bus_new(): take it an extra time to account the user and link
  the bus into the domain bus_list.

And as discussed in the previous patch kdbus_domain_user_find_or_new()
is racy, so convert to __kdbus_domain_user_account()

This allows also to improve the execution path to take the domain lock
only one time in case of success. On failure the domain lock will be
taken two times.

kdbus_bus_new():
  => take domain lock
  => check if domain is still active/connected
     => __kdbus_domain_user_account()
  ...

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agokdbus: improve user quota accounting by using kdbus_domain_user_account()
Djalal Harouni [Wed, 30 Jul 2014 20:11:55 +0000 (21:11 +0100)]
kdbus: improve user quota accounting by using kdbus_domain_user_account()

Currently kdbus_domain_user_find_or_new() is used to find a user
domain or create a new one and link it into the domain.

kdbus_domain_user_find_or_new() may fail due to memory allocation
errors or if the domain was shutdown, but since callers will
receive only a NULL pointer on failure, they assume -ENOMEM and
ignore -ESHUTDOWN. Fix this in kdbus_domain_user_account() by returning
the appropriate error code.

There are also some races with kdbus_domain_user_find_or_new(), if it is
called with the same parameters and if we do not find a previously
linked domain user, then both threads will race to assign a different ID
for the same uid, thus, invalidating the users array. We fix this in the
new kdbus_domain_user_account() and __kdbus_domain_user_account() by
taking the domain lock only one time.

Replace some kdbus_domain_user_find_or_new() calls with
kdbus_domain_user_account(). The last one in bus.c is updated in the
next patch.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agodomain: add kdbus_domain_user_account()
Djalal Harouni [Wed, 30 Jul 2014 20:11:54 +0000 (21:11 +0100)]
domain: add kdbus_domain_user_account()

Add kdbus_domain_user_account() to account and link users into a
domain.

This function will take the domain lock, and it will be used as a
replacement for kdbus_domain_user_find_or_new().

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agodomain: add __kdbus_domain_user_account() to account domain users
Djalal Harouni [Wed, 30 Jul 2014 20:11:53 +0000 (21:11 +0100)]
domain: add __kdbus_domain_user_account() to account domain users

Add __kdbus_domain_user_account() to account and link users into a
domain.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agodomain: add kdbus_domain_user_assign_id() to assign IDs to domain users
Djalal Harouni [Wed, 30 Jul 2014 20:11:52 +0000 (21:11 +0100)]
domain: add kdbus_domain_user_assign_id() to assign IDs to domain users

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agotest: correctly set the 'ret' variable
Djalal Harouni [Wed, 23 Jul 2014 16:34:32 +0000 (17:34 +0100)]
test: correctly set the 'ret' variable

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
10 years agoMerge pull request #21 from torstehu/fix-warning
Greg Kroah-Hartman [Wed, 2 Jul 2014 05:46:39 +0000 (22:46 -0700)]
Merge pull request #21 from torstehu/fix-warning

Fix annoying compile warning due to missing cast

10 years agoFix annoying compile warning due to missing cast
Torstein Husebø [Sun, 29 Jun 2014 15:41:31 +0000 (17:41 +0200)]
Fix annoying compile warning due to missing cast

10 years agoconnection: don't append to uninitialized metadata
Daniel Mack [Tue, 24 Jun 2014 13:41:47 +0000 (15:41 +0200)]
connection: don't append to uninitialized metadata

kmsg->meta is only valid if conn_src != NULL.