|
Message-ID: <CA+55aFwHUw+6xEc-M+mZvwOxCsBD6zZDwyAQ-a_xupaH8py7cA@mail.gmail.com> Date: Thu, 23 Jun 2016 10:44:08 -0700 From: Linus Torvalds <torvalds@...ux-foundation.org> To: Oleg Nesterov <oleg@...hat.com> Cc: Andy Lutomirski <luto@...capital.net>, Andy Lutomirski <luto@...nel.org>, "the arch/x86 maintainers" <x86@...nel.org>, Linux Kernel Mailing List <linux-kernel@...r.kernel.org>, "linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>, Borislav Petkov <bp@...en8.de>, Nadav Amit <nadav.amit@...il.com>, Kees Cook <keescook@...omium.org>, Brian Gerst <brgerst@...il.com>, "kernel-hardening@...ts.openwall.com" <kernel-hardening@...ts.openwall.com>, Josh Poimboeuf <jpoimboe@...hat.com>, Jann Horn <jann@...jh.net>, Heiko Carstens <heiko.carstens@...ibm.com> Subject: Re: [PATCH v3 00/13] Virtually mapped stacks with guard pages (x86, core) On Thu, Jun 23, 2016 at 10:03 AM, Oleg Nesterov <oleg@...hat.com> wrote: > > Let me quote my previous email ;) > > And we can't free/nullify it when the parent/debuger reaps a zombie, > say, mark_oom_victim() expects that get_task_struct() protects > thread_info as well. > > probably we can fix all such users though... TIF_MEMDIE is indeed a potential problem, but I don't think mark_oom_victim() is actually problematic. mark_oom_victim() is called with either "current", or with a victim that still has its mm and signal pointer (and the task is locked). So the lifetime is already guaranteed - or that code is already very very buggy, since it follows tsk->signal and tsk->mm So as far as I can tell, that's all fine. That said, by now it would actually in many ways be great if we could get rid of thread_info entirely. The historical reasons for thread_info have almost all been subsumed by the percpu area. The reason for thread_info originally was - we used to find the task_struct by just masking the stack pointer (long long ago). When the task struct grew too big, we kept just the critical pieces and some arch-specific stuff and , called it "thread_info", and moved the rest to an external allocation and added the pointer to it. - the really crticial stuff we didn't want to follow a pointer for, so things like preempt_count etc were in thread_info - but they were *so* critical that PeterZ (at my prodding) moved those things to percpu caches that get updated at schedule time instead so these days, thread_info has almost nothing really critical in it any more. There's the thread-local flags, yes, but they could stay or easily be moved to the task_struct or get similar per-cpu fixup as preempt_count did a couple of years ago. The only annoyance is the few remaining entry code assembly sequences, but I suspect they would actually become simpler with a per-cpu thing, and with Andy's cleanups they are pretty insignificant these days. There seems to be exactly two uses of ASM_THREAD_INFO(TI_flags,.. left. So I suspect that it would (a) already be possible to just free the stack and thread info at release time, because any rcu users will already be doing task_lock() and check mm etc. (b) it probably would be a nice cleanup to try to make it even more obviously safe by just shrinking thread_info more (or even getting rid of it entirely, but that may be too painful because there are other architectures that may depend on it more). I dunno. Looking at what remains of thread_info, it really doesn't seem very critical. The thread_info->tsk pointer, that was one of the most critical issues and the main raison d'ĂȘtre of the thread_info, has been replaced on x86 by just using the per-cpu "current_task". Yes,.there are probably more than a few "ti->task" users left for legacy reasons, harking back to when the thread-info was cheaper to access, but it shouldn't be a big deal. Linus
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.