From: Alexey Gladkov <legion@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux Containers <containers@lists.linux.dev>,
Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>,
Andrew Morton <akpm@linux-foundation.org>,
Christian Brauner <christian.brauner@ubuntu.com>,
Daniel Walsh <dwalsh@redhat.com>,
Davidlohr Bueso <dbueso@suse.de>,
Kirill Tkhai <ktkhai@virtuozzo.com>,
Manfred Spraul <manfred@colorfullife.com>,
Serge Hallyn <serge@hallyn.com>,
Varad Gautam <varad.gautam@suse.com>,
Vasily Averin <vvs@virtuozzo.com>
Subject: Re: [GIT PULL] ipc: Bind to the ipc namespace at open time.
Date: Fri, 25 Mar 2022 13:10:56 +0100 [thread overview]
Message-ID: <20220325121056.dcvm3u2fe2bvn6om@example.org> (raw)
In-Reply-To: <CAHk-=wgBB8iPd0W=MQWnQJukMAPAqgsC0QX2wwiSvcct9zu_RA@mail.gmail.com>
On Thu, Mar 24, 2022 at 11:12:21AM -0700, Linus Torvalds wrote:
> On Wed, Mar 23, 2022 at 1:24 PM Eric W. Biederman <ebiederm@xmission.com> wrote:
> >
> > Please pull the per-namespace-ipc-sysctls-for-v5.18 tag from the git tree:
>
> Ugh.
>
> I pulled this. Then I stared at it for a long time.
>
> And then I decided that this is too ugly to live.
>
> I'm sorry. I think Alexey has probably spent a fair amount of time on
> it, but I really think the sysctl code needs to be cleaned up way more
> than this.
Apparently it's my fault that the purpose of these changes is not clear. I
did this refactoring not for the sake of refactoring as such.
In my original patch [1], I was trying to fix the situation where the user
cannot change the /proc/sys/fs/mqueue/* options inside rootless container.
But then I split the changes into refactoring which fixes the hack and
permission changes which I wanted to discuss and propose later.
[1] https://lore.kernel.org/lkml/0f0408bb7fbf3187966a9bf19a98642a5d9669fe.1641225760.git.legion@kernel.org/
> The old code was horribly hacky too, but that setup_ipc_sysctls() (and
> setup_mq_sysctls()) thing that copies the whole sysctls table, and
> then walks it entry by entry to modify it, is just too ugly for words.
>
> And then it hides things in .extra1, and because it does that it can't
> use the normal "extra1 and extra2 contains the limits" so then at
> write() time it copies it into a local one AGAIN only to set the
> limits back so that it can call the normal routines again.
>
> Not ok.
>
> Yes, yes, the old code did some similar things - to set the 'data'
> pointer. That was disgusting too. Don't get me wrong - the existing
> code was nasty too. But this took nasty code, and doubled down on it.
>
> I really think this is a fundamental problem, and needs a more
> fundamental fix than adding more and more of these kinds of nasty
> hacks.
>
> And yes, that fundamental fix is almost certainly to pass in 'struct
> cred *' to all those sysctl helper functions.
>
> Then, when you do the actual 'sysctl()' system calls, you pass in
> 'current_cred()".
>
> And the /proc users would pass in file->f_cred.
>
> And yes, that patch might be quite messy, because we have quite a lot
> of those random .proc_handler users.
>
> But *most* of them by far (at least in random code) use the standard
> proc_dointvec_minmax() and friends, and won't even notice.
>
> And then the ones that are about namespace issues will have to
> continue to do the nasty "make a copy and update the data pointer",
> but *MAYBE* we could also introduce the notion of an "offset" to those
> proc_dointvec_minmax() things to help them out (and at least avoid the
> "make a copy" thing).
>
> Anyway, I really think we must not make that sysctl code even uglier
> than it is today, and I think we need to move towards a model that
> actually makes sense. And that "pass in the right cred" is the only
> sensible model I can see.
>
> I haven't tried to create such a patch, and maybe Alexey already tried
> to do something like that and it turned out to be too ugly for words
> and that's why these nasty patches happened.
>
> But at least for now, I can't with a good conscience pull this.
>
> Sorry,
> Linus
OK. I'll try to come up with some other solution.
--
Rgrds, legion
next prev parent reply other threads:[~2022-03-25 12:11 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 18:18 [PATCH v4 0/2] ipc: Store mq and ipc sysctls in the ipc namespace Alexey Gladkov
2022-02-14 18:18 ` [PATCH v4 1/2] ipc: Store mqueue " Alexey Gladkov
2022-02-14 18:18 ` [PATCH v4 2/2] ipc: Store ipc " Alexey Gladkov
2022-03-23 20:24 ` [GIT PULL] ipc: Bind to the ipc namespace at open time Eric W. Biederman
2022-03-24 18:12 ` Linus Torvalds
2022-03-24 21:48 ` Eric W. Biederman
2022-03-24 22:16 ` Linus Torvalds
2022-03-25 12:10 ` Alexey Gladkov [this message]
2022-04-22 12:53 ` [PATCH v1 0/4] ipc: Remove extra1 field abuse to pass ipc namespace Alexey Gladkov
2022-04-22 12:53 ` [PATCH v1 1/4] " Alexey Gladkov
2022-05-02 16:07 ` Eric W. Biederman
2022-04-22 12:53 ` [PATCH v1 2/4] ipc: Use proper " Alexey Gladkov
2022-05-02 16:09 ` Eric W. Biederman
2022-05-03 13:39 ` Alexey Gladkov
2022-05-03 13:39 ` [PATCH v2 1/4] ipc: Use the same namespace to modify and validate Alexey Gladkov
2022-05-03 13:39 ` [PATCH v2 2/4] ipc: Remove extra1 field abuse to pass ipc namespace Alexey Gladkov
2022-05-03 13:39 ` [PATCH v2 3/4] ipc: Check permissions for checkpoint_restart sysctls at open time Alexey Gladkov
2022-05-03 13:39 ` [PATCH v2 4/4] ipc: Remove extra braces Alexey Gladkov
2022-04-22 12:53 ` [PATCH v1 3/4] ipc: Check permissions for checkpoint_restart sysctls at open time Alexey Gladkov
2022-04-22 12:53 ` [PATCH v1 4/4] ipc: Remove extra braces Alexey Gladkov
2022-04-22 20:44 ` [PATCH v1 0/4] ipc: Remove extra1 field abuse to pass ipc namespace Linus Torvalds
2022-05-04 3:42 ` Philip Rhoades
2022-06-01 13:20 ` [RFC PATCH 0/4] API extension for handling sysctl Alexey Gladkov
2022-06-01 13:20 ` [RFC PATCH 1/4] sysctl: " Alexey Gladkov
2022-06-01 19:19 ` Matthew Wilcox
2022-06-01 19:23 ` Linus Torvalds
2022-06-01 19:25 ` Matthew Wilcox
2022-06-01 19:31 ` Linus Torvalds
2022-06-01 19:32 ` Alexey Gladkov
2022-06-01 13:20 ` [RFC PATCH 2/4] sysctl: ipc: Do not use dynamic memory Alexey Gladkov
2022-06-01 16:45 ` Linus Torvalds
2022-06-01 18:24 ` Alexey Gladkov
2022-06-01 18:34 ` Linus Torvalds
2022-06-01 19:05 ` Alexey Gladkov
2022-06-09 18:51 ` Luis Chamberlain
2022-06-01 13:20 ` [RFC PATCH 3/4] sysctl: userns: " Alexey Gladkov
2022-06-01 13:20 ` [RFC PATCH 4/4] sysctl: mqueue: " Alexey Gladkov
2022-06-09 16:45 ` [RFC PATCH 0/4] API extension for handling sysctl Luis Chamberlain
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=20220325121056.dcvm3u2fe2bvn6om@example.org \
--to=legion@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexander.mikhalitsyn@virtuozzo.com \
--cc=christian.brauner@ubuntu.com \
--cc=containers@lists.linux.dev \
--cc=dbueso@suse.de \
--cc=dwalsh@redhat.com \
--cc=ebiederm@xmission.com \
--cc=ktkhai@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=serge@hallyn.com \
--cc=torvalds@linux-foundation.org \
--cc=varad.gautam@suse.com \
--cc=vvs@virtuozzo.com \
/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;
as well as URLs for NNTP newsgroup(s).