Re: [PATCH 1/2] security: safesetid: use real GID for GID policy lookup
From: Paul Moore
Date: Fri Nov 20 2026 - 17:42:50 EST
On Fri, Nov 20, 2026 at 1:44 PM Micah Morton <mortonm@xxxxxxxxxxxx> wrote:
> On Thu, Nov 5, 2026 at 4:26 PM Paul Moore <paul@xxxxxxxxxxxxxx> wrote:
> > On Sun, Oct 4, 2026 at 6:05 PM Serge E. Hallyn <serge@xxxxxxxxxx> wrote:
> > > On Sat, Oct 03, 2026 at 07:34:15PM +0900, tjdqudcks0424@xxxxxxxxx wrote:
> > > > From: Sung Byeongchan <tjdqudcks0424@xxxxxxxxx>
> > > >
> > > > SafeSetID policies constrain the ID transitions available to a task for
> > > > each source ID. id_permitted_for_cred() always builds that source key
> > > > from the old real UID, even when it is checking a GID transition. If the
> > > > real UID and real GID differ, the policy attached to the real GID is
> > > > therefore missed and the lookup can return the unconstrained default.
> > > >
> > > > On current mainline, a test task with real UID 1000, real GID 2000 and
> > > > only CAP_SETGID obtained non-allowlisted GID 2002 despite a 2000:2001 GID
> > > > policy. The bypass reproduced for setgid(), setegid(), setregid(),
> > > > setresgid(), setfsgid() and setgroups() across three clean QEMU boots,
> > > > and enabled access to a synthetic group-protected resource. This shows
> > > > a SafeSetID GID policy bypass and group privilege expansion; it does not
> > > > show direct UID 0 elevation or a universal local privilege escalation.
> > > >
> > > > Build the source key from the old real UID for UID policy checks and the
> > > > old real GID for GID policy checks. In three fixed-kernel boots, all
> > > > tested non-allowlisted transitions were blocked while the allowed target,
> > > > existing-ID, no-policy and UID-policy controls, and the existing SafeSetID
> > > > selftest continued to pass.
> > > >
> > > > Fixes: 5294bac97e12 ("LSM: SafeSetID: Add GID security policy handling")
> > > > Cc: stable@xxxxxxxxxxxxxxx
> > > > Assisted-by: OpenAI Codex
> > > > Signed-off-by: Sung Byeongchan <tjdqudcks0424@xxxxxxxxx>
> > >
> > > Seems obviously correct. Thanks for the find and the fix.
> > >
> > > Reviewed-by: Serge Hallyn <serge@xxxxxxxxxx>
> >
> > Looks good to me too, thanks!
> >
> > Reviewed-by: Paul Moore <paul@xxxxxxxxxxxxxx>
> >
> > Micah, assuming this looks good to you, are you planning to pick this
> > up? If you would like me to take this via the LSM tree, please let me
> > know.
>
> Hi guys,
>
> Sorry for the delay! Yes this patch looks good to me -- thanks for
> catching this, Sung!
>
> It's been a really long time since I sent any pull requests to Linus,
> so it might be a good idea for this to come from the LSM tree if you
> are up for it, Paul.
>
> Let me know, if you think its better for me to dust off my old GitHub
> repo and pull request etiquette I'm fine to do so as well :)
I guess it's up to you Micah. If you want an excuse to get current on
merging patches and sending pull requests to Linus this would be a
good one. However, I also understand that it can be a non-trivial
amount of work for one patch (which is why I made the offer).
Let me know what you would like to do; both options are fine with me.
If you need some help on the administrative side, e.g. sending stuff
to Linus, let me know and I'll do my best to help you out. If you
would prefer me to include this in the LSM tree, please reply with an
ACK tag so I can include that in the merge.
Thanks!
--
paul-moore.com