Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755298AbbHFIYe (ORCPT ); Thu, 6 Aug 2015 04:24:34 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:37816 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754689AbbHFIWA (ORCPT ); Thu, 6 Aug 2015 04:22:00 -0400 From: David Herrmann To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Daniel Mack , Djalal Harouni , David Herrmann Subject: [PATCH 5/9] kdbus: perform accounting on proxied uids Date: Thu, 6 Aug 2015 10:21:24 +0200 Message-Id: <1438849288-18112-6-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438849288-18112-1-git-send-email-dh.herrmann@gmail.com> References: <1438849288-18112-1-git-send-email-dh.herrmann@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1757 Lines: 48 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 --- 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/