From: stsp <stsp2@yandex.ru>
To: Oleg Nesterov <oleg@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Jens Axboe <axboe@kernel.dk>,
Andrew Morton <akpm@linux-foundation.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Florent Revest <revest@chromium.org>, Kees Cook <kees@kernel.org>,
Palmer Dabbelt <palmer@rivosinc.com>,
Charlie Jenkins <charlie@rivosinc.com>,
Benjamin Gray <bgray@linux.ibm.com>, Helge Deller <deller@gmx.de>,
Zev Weiss <zev@bewilderbeest.net>,
Samuel Holland <samuel.holland@sifive.com>,
linux-fsdevel@vger.kernel.org,
Eric Biederman <ebiederm@xmission.com>,
Andy Lutomirski <luto@kernel.org>,
Josh Triplett <josh@joshtriplett.org>
Subject: Re: [PATCH v3] add group restriction bitmap
Date: Tue, 1 Oct 2024 16:29:37 +0300 [thread overview]
Message-ID: <62362149-c550-490f-bd7a-0fd7a5cd22bc@yandex.ru> (raw)
In-Reply-To: <20241001130236.GB23907@redhat.com>
01.10.2024 16:02, Oleg Nesterov пишет:
> On 10/01, stsp wrote:
>> 01.10.2024 14:15, Oleg Nesterov пишет:
>>> Suppose we change groups_search()
>>>
>>> --- a/kernel/groups.c
>>> +++ b/kernel/groups.c
>>> @@ -104,8 +104,11 @@ int groups_search(const struct group_info *group_info, kgid_t grp)
>>> left = mid + 1;
>>> else if (gid_lt(grp, group_info->gid[mid]))
>>> right = mid;
>>> - else
>>> - return 1;
>>> + else {
>>> + bool r = mid < BITS_PER_LONG &&
>>> + test_bit(mid, &group_info->restrict_bitmap);
>>> + return r ? -1 : 1;
>>> + }
>>> }
>>> return 0;
>>> }
>>>
>>> so that it returns, say, -1 if the found grp is restricted.
>>>
>>> Then everything else can be greatly simplified, afaics...
>> This will mean updating all callers
>> of groups_search(), in_group_p(),
>> in_egroup_p(), vfsxx_in_group_p()
> Why? I think with this change you do not need to touch in_group_p/etc at all.
>
>> if in_group_p() returns -1 for not found
>> and 0 for gid,
> With the the change above in_group_p() returns 0 if not found, !0 otherwise.
> It returns -1 if grp != cred->fsgid and the found grp is restricted.
in_group_p() doesn't check if the
group is restricted or not.
acl_permission_check() does, but
in your example it doesn't as well.
I think you mean to move the
restrict_bitmap check upwards to
in_group_p()?
Anyway, suppose you don't mean that.
In this case:
1. in_group_p() and in_egroup_p()
should be changed:
- int retval = 1;
+ int retval = -1;
But their callers should not.
There are also the callers of groups_search()
in kernel/auditsc.c and they should
be updated. But they are few.
Just to be clear, is this what you suggest?
> So acl_permission_check() can simply do
>
> if (mask & (mode ^ (mode >> 3))) {
> vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
> int xxx = vfsgid_in_group_p(vfsgid);
>
> if (xxx) {
> if (mask & ~(mode >> 3))
> return -EACCES;
> if (xxx > 0)
> return 0;
> /* If we hit restrict_bitmap, then check Others. */
> }
> }
Well, in my impl it should check
the bitmap right here, but you removed
that. Maybe you want the check elsewhere?
next prev parent reply other threads:[~2024-10-01 13:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-30 19:59 Stas Sergeev
2024-10-01 11:15 ` Oleg Nesterov
2024-10-01 11:37 ` stsp
2024-10-01 13:02 ` Oleg Nesterov
2024-10-01 13:29 ` stsp [this message]
2024-10-01 15:02 ` Oleg Nesterov
2024-10-01 15:28 ` stsp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=62362149-c550-490f-bd7a-0fd7a5cd22bc@yandex.ru \
--to=stsp2@yandex.ru \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bgray@linux.ibm.com \
--cc=brauner@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=charlie@rivosinc.com \
--cc=deller@gmx.de \
--cc=ebiederm@xmission.com \
--cc=jack@suse.cz \
--cc=josh@joshtriplett.org \
--cc=kees@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=oleg@redhat.com \
--cc=palmer@rivosinc.com \
--cc=revest@chromium.org \
--cc=samuel.holland@sifive.com \
--cc=viro@zeniv.linux.org.uk \
--cc=zev@bewilderbeest.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®