Thread (7 messages) 7 messages, 3 authors, 2022-06-16

Re: [PATCH 2/2] LSM: SafeSetID: Add setgroups() security policy handling

flat view

From: Micah Morton <mortonm@chromium.org>
Date: 2022-06-14 17:37:16
Also in: lkml

On Mon, Jun 13, 2022 at 4:46 PM Kees Cook [off-list ref] wrote:
On Mon, Jun 13, 2022 at 02:00:03PM -0700, Micah Morton wrote:
quoted
On Mon, Jun 13, 2022 at 1:28 PM Micah Morton [off-list ref] wrote:
[...]
quoted
+static int safesetid_task_fix_setgroups(struct cred *new, const struct cred *old)
+{
+       int i;
+
+       /* Do nothing if there are no setgid restrictions for our old RGID. */
+       if (setid_policy_lookup((kid_t){.gid = old->gid}, INVALID_ID, GID) == SIDPOL_DEFAULT)
+               return 0;
+
+       get_group_info(new->group_info);
+       for (i = 0; i < new->group_info->ngroups; i++) {
+               if (!id_permitted_for_cred(old, (kid_t){.gid = group_info->gid[i]}, GID)) {
Oops, should be:

!id_permitted_for_cred(old, (kid_t){.gid = new->group_info->gid[i]}, GID)

Guess I won't send a whole new patch just for that one line
This begs the question: are there self-tests for this LSM somewhere?
It'd be really nice to add them to tool/testing/selftests ...
There actually is tools/testing/selftests/safesetid/ but I haven't
updated it since v1 of SafeSetID that only accommodated UIDs. I've
been relying on integration testing we have out of tree on the Chrome
OS side but I suppose its reasonable to bring the selftest up to date
as well :)

Also both patches are a couple lines off from the ones I was finished
developing/testing with.. some kind of screw up happened when I copied
from my dev machine to another where I could get git-send-email
working properly. I'll just resend these 2 patches along with the
update to the selftest.

Thanks
--
Kees Cook
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help