From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 178783C0A15 for ; Thu, 14 May 2026 20:44:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778791453; cv=none; b=mYQZCTijGTD8iNePfNc8ewdrFMSIbbXG4sTsxSHJAykylwQCKIZwN5sVB3P87Wlsxhvfv5sj18LjwppOBaRhpSn6DQ1tio/f/82y3ifX6z8moIg+1Km4xGhowUZm6q08Pnw+LQHVc0R7ljMIZYTab3IFAWqY2ETopca6Kka7nv0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778791453; c=relaxed/simple; bh=bhsOuUIaNixFGUNouO+flDtH1Ol7OJbIIYt+9nRn+ow=; h=Date:Message-ID:MIME-Version:Content-Type:From:To:Cc:Subject: References:In-Reply-To; b=f62nP7qGWrYMn9Nh+kNGTalopTmnA1btAtPFcTd2xYYzkC6TOKD60rli4mcHO2BhvMiHz967xcSVVx33KUGmaJaAiceqK2uMyc2/BqQZ0ADFWUpaybIF9h9WSfArH9kdXoNwDnhhs9/HK60PMmhEJAOp6ugLYPrNSpWax3uKFos= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=OSc1CYb0; arc=none smtp.client-ip=209.85.219.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="OSc1CYb0" Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-8b7105dfb35so83232116d6.3 for ; Thu, 14 May 2026 13:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1778791451; x=1779396251; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :mime-version:message-id:date:from:to:cc:subject:date:message-id :reply-to; bh=iIn517qMFa/72Ee/XGTDeeK9Cq6VJiGDpV2GCDJOS7E=; b=OSc1CYb0LA2hDiDhS0KeITKEVBykeYFWm5mB0F2ke+6PQDCnTZXwjSXfPcFZ2NjxZh Ud8DZ2Pn80kJgStc5aPzDIhYLMhcN1gBuV634XDMewUMWFm1C4TCCf85M8NSRiX1eLv7 zr2glp2nDXnD4JkJPtYxTMuKBslrojKLiTEHAcm3EH6FwxYhOdc0MwS1z8EnASGXUNdh qhqkOHGuzzpUceCeCbvLtRLmYW42xUzlK1M6PLl6EmmgsVevWHKple3NmFdra+FfED0d w7cz8MNWx7gA9pA1tPMPQc/OFjkj/Fy1Lz2cu5g15GIezPqAP5ftUK5m0p3AWAzVxQZa 4dLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778791451; x=1779396251; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :mime-version:message-id:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iIn517qMFa/72Ee/XGTDeeK9Cq6VJiGDpV2GCDJOS7E=; b=UtrYjp52LjYwQDpBqHFxfvlJnOLBsSY1AYfM4aGUsXYWARGTxt1Dy1HClF0j3Fl7EG +lcqqmuVq5WogPR+OIpgpM2JyK2tGxbn9Y+YF3ZavSwzxY0gqgrP0BvnXjLOk1eVce5/ 8ARemDBb1O5bCP8AHJ2fJtNy1U9IDkcYrf2oYhBhwyfn80EuESS+W+CdfEPpE8nmXIME Uld8Cj0gwPmEJBGqIPEId81f3miNnli3YjHIqckq/djgdQEu+qP4NN+7LI6xIFxtihFV bpvekrQgCyyCEi1s2gTPYb5MglBsi4xwKnB+/F5b4uOCmbNJdXTHGSbqS20kqw2f/EVL flWQ== X-Forwarded-Encrypted: i=1; AFNElJ+p/VFS4dC+9gfdtmZp1penKWCv/8r2XBUUyZ1M8kMsL7XlbED2LDWY+GV2CNEhkdriiYmikw6+eAEtqy4=@vger.kernel.org X-Gm-Message-State: AOJu0YyLFjKlKJiceRtM5jYQr27EUi9xGt7KDPXzldisnwXL+awtp2D6 JSpFUcmucj5JbEWjUFkxKIU0UB1NwbtQvxTPVeR3PBW5PKWJ2LTw8Q+IpQNEmJtlkQ== X-Gm-Gg: Acq92OFC0B+KlMiLPW82+49116C3uynZGNx9kcuh2rk8iduFQDJMRAZGE+ESbLHIqSO 8L2gYlOUd6gOGRRiSFNL5nL3ClBaOsIDTaETZQR93P41gG3EQ0p/LnzIY+K3uPDB5/bxjIMDCJJ JmWLTzYkprbGTNMWhHVoYqb/IwinXyMnLg0oqE1bWIvUfWNlEiLG8sbhE6GCoj3T6EbO9KawTLb +IfEoiYX61e3ANZiGxJKtvwk8N6WhmXABqZVUpCiqh/dy6Wnsn6XbnqMR8WLiBxI+0beobQIZs2 71UfQxItaMDAoamkTmu/ezqK8Rnh+FHKuOu3N5XJpoIqcHPkFkuVd05UDoEq1ZKQhfaKx7yBAQk vATeU2Gbe6MtHcZg7EghDVvV20Up7RfD9Bahmr2G1uNmxIQbm+R64IBrl+BousnZstbJ+rUdTY4 42SI062aMefmAHVJQHs+zYP0Y9xRAAzD7wd3/N6rxxNF5y9qHD6MAUFq0Xp+wdrxVrhOXgALnaO 9hjvtg= X-Received: by 2002:ad4:5e88:0:b0:8ac:b70c:8a9b with SMTP id 6a1803df08f44-8ca0f70f697mr20146116d6.44.1778791451056; Thu, 14 May 2026 13:44:11 -0700 (PDT) Received: from localhost (pool-71-126-255-178.bstnma.fios.verizon.net. [71.126.255.178]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8c90c358539sm32474826d6.41.2026.05.14.13.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2026 13:44:10 -0700 (PDT) Date: Thu, 14 May 2026 16:44:09 -0400 Message-ID: <16093a0278a6d7d1a0a8bc055c228bed@paul-moore.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailer: pstg-pwork:20260514_1634/pstg-lib:20260514_1359/pstg-pwork:20260514_1634 From: Paul Moore To: Albert Esteve , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , Christian Brauner , James Morris , "Serge E. Hallyn" , Stephen Smalley , Ondrej Mosnacek , Shuah Khan Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-kselftest@vger.kernel.org, Albert Esteve , mripard@kernel.org, echanude@redhat.com Subject: Re: [PATCH RFC 4/5] selinux: Restrict cross-cgroup dma-heap charging References: <20260512-v2_20230123_tjmercier_google_com-v1-4-6326701c3691@redhat.com> In-Reply-To: <20260512-v2_20230123_tjmercier_google_com-v1-4-6326701c3691@redhat.com> On May 12, 2026 Albert Esteve wrote: > > The security_dma_heap_alloc() hook allows security modules > to control which processes may charge dma-buf allocations > to another process's cgroup via the charge_pid_fd field of > DMA_HEAP_IOCTL_ALLOC. Without a policy implementation, the > hook is a no-op and the restriction is not enforced. > > On SELinux-managed systems any domain with access to a > dma-heap device node can therefore exhaust another cgroup's > memory budget without restriction. > > Implement selinux_dma_heap_alloc() using avc_has_perm() with > a new dma_heap object class and a charge_to permission. Policy > authors can then grant cross-cgroup charging selectively, > for example: > > allow allocator_app_t client_app_t:dma_heap charge_to; > > Signed-off-by: Albert Esteve > --- > security/selinux/hooks.c | 7 +++++++ > security/selinux/include/classmap.h | 1 + > 2 files changed, 8 insertions(+) > > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index 0f704380a8c81..ea1f410b9f619 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -2189,6 +2189,12 @@ static int selinux_capable(const struct cred *cred, struct user_namespace *ns, > return cred_has_capability(cred, cap, opts, ns == &init_user_ns); > } > > +static int selinux_dma_heap_alloc(const struct cred *from, const struct cred *to) > +{ > + return avc_has_perm(cred_sid(from), cred_sid(to), > + SECCLASS_DMA_HEAP, DMA_HEAP__CHARGE_TO, NULL); > +} > + > static int selinux_quotactl(int cmds, int type, int id, const struct super_block *sb) > { > const struct cred *cred = current_cred(); > @@ -7541,6 +7547,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = { > LSM_HOOK_INIT(capget, selinux_capget), > LSM_HOOK_INIT(capset, selinux_capset), > LSM_HOOK_INIT(capable, selinux_capable), > + LSM_HOOK_INIT(dma_heap_alloc, selinux_dma_heap_alloc), > LSM_HOOK_INIT(quotactl, selinux_quotactl), > LSM_HOOK_INIT(quota_on, selinux_quota_on), > LSM_HOOK_INIT(syslog, selinux_syslog), > diff --git a/security/selinux/include/classmap.h b/security/selinux/include/classmap.h > index 90cb61b164256..d232f7808f6b8 100644 > --- a/security/selinux/include/classmap.h > +++ b/security/selinux/include/classmap.h > @@ -181,6 +181,7 @@ const struct security_class_mapping secclass_map[] = { > { "user_namespace", { "create", NULL } }, > { "memfd_file", > { COMMON_FILE_PERMS, "execute_no_trans", "entrypoint", NULL } }, > + { "dma_heap", { "charge_to", NULL } }, > /* last one */ { NULL, {} } > }; While we have seen some one-off patches to add specific resource/cgroups controls in the past, much like this one, we've yet to see a patchset that provides a more comprehensive set of resource/cgroup access controls for SELinux. I'm not opposed to a patch like this, but I would like to see it as part of a larger effort to introduce access controls across all of the existing cgroup control points where it makes sense. In other words, let's see a design for cgroup access controls so that we can ensure we have something that is meaningful and makes sense from a policy developer's perspective. -- paul-moore.com