On Wed, Mar 23, 2022 at 1:24 PM Eric W. Biederman <ebiederm@xxxxxxxxxxxx> 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. 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