Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1201563

[PATCH 5/9] kdbus: perform accounting on proxied uids

From David Herrmann <dh.herrmann@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 5/9] kdbus: perform accounting on proxied uids
Date 2015-08-06 10:30 +0200
Message-ID <pUoIP-3l2-27@gated-at.bofh.it> (permalink)
References <pUoIN-3l2-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


If a connection proxies a uid, we should make sure to perform accounting
on that passed uid. Otherwise, limits will be shared across all proxied
users (or we'd require the proxy to run setuid() and thus require
CAP_SETUID).
However, this is only allowed if the proxy is privileged on the bus. That
is, it must have CAP_IPC_ADMIN on the domain and the passed uid must be
mapped in that domain.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 ipc/kdbus/connection.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c
index 243cbc7..c81888e 100644
--- a/ipc/kdbus/connection.c
+++ b/ipc/kdbus/connection.c
@@ -237,11 +237,21 @@ static struct kdbus_conn *kdbus_conn_new(struct kdbus_ep *ep,
 	 * Note that limits are always accounted against the real UID, not
 	 * the effective UID (cred->user always points to the accounting of
 	 * cred->uid, not cred->euid).
+	 * In case the caller is privileged, we allow changing the accounting
+	 * to the faked user.
 	 */
 	if (ep->user) {
 		conn->user = kdbus_user_ref(ep->user);
 	} else {
-		conn->user = kdbus_user_lookup(ep->bus->domain, current_uid());
+		kuid_t uid;
+
+		if (conn->meta_fake && uid_valid(conn->meta_fake->uid) &&
+		    conn->privileged)
+			uid = conn->meta_fake->uid;
+		else
+			uid = conn->cred->uid;
+
+		conn->user = kdbus_user_lookup(ep->bus->domain, uid);
 		if (IS_ERR(conn->user)) {
 			ret = PTR_ERR(conn->user);
 			conn->user = NULL;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/9] kdbus: set of random fixes David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 7/9] kdbus: consolidate common code David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 4/9] kdbus: move privilege checking in kdbus_conn_new() David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 9/9] kdbus/tests: properly parse KDBUS_CMD_LIST objects David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 1/9] kdbus: return EBADSLT on replies without slot David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 2/9] kdbus: reduce stack buffer to 256 bytes David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 3/9] kdbus: use separate counter for message IDs David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 5/9] kdbus: perform accounting on proxied uids David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200
  [PATCH 6/9] kdbus: inline privilege checks David Herrmann <dh.herrmann@gmail.com> - 2015-08-06 10:30 +0200

csiph-web