From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Garnier Subject: Re: Re: [PATCH v9 1/4] syscalls: Verify address limit before returning to user-mode Date: Fri, 12 May 2017 10:05:58 -0700 Message-ID: References: <20170508073352.caqe3fqf7nuxypgi@gmail.com> <20170508075209.7aluvpwildw325rf@gmail.com> <1494256932.1167.1.camel@gmail.com> <20170509065619.wmqa6z6w3n6xpvrw@gmail.com> <20170509111007.GA14702@kroah.com> <20170512065818.mw7yqcdck7alqlzi@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: List-Post: List-Help: List-Unsubscribe: List-Subscribe: In-Reply-To: <20170512065818.mw7yqcdck7alqlzi@gmail.com> To: Ingo Molnar Cc: Linus Torvalds , Greg KH , Kees Cook , Daniel Micay , Martin Schwidefsky , Heiko Carstens , Dave Hansen , Arnd Bergmann , Thomas Gleixner , David Howells , =?UTF-8?Q?Ren=C3=A9_Nyffenegger?= , Andrew Morton , "Paul E . McKenney" , "Eric W . Biederman" , Oleg Nesterov , Pavel Tikhomirov , Ingo Molnar , "H . Peter Anvin" , Andy Lutomirski , Paolo Bonzini , Rik van Riel , Josh Poimboeuf , Borisla List-Id: linux-api@vger.kernel.org On Thu, May 11, 2017 at 11:58 PM, Ingo Molnar wrote: > > * Linus Torvalds wrote: > >> On Thu, May 11, 2017 at 4:17 PM, Thomas Garnier wrote: >> > >> > Ingo: Do you want the change as-is? Would you like it to be optional? >> > What do you think? >> >> I'm not ingo, but I don't like that patch. It's in the wrong place - >> that system call return code is too timing-critical to add address >> limit checks. >> >> Now what I think you *could* do is: >> >> - make "set_fs()" actually set a work flag in the current thread flags >> >> - do the test in the slow-path (syscall_return_slowpath). >> >> Yes, yes, that ends up being architecture-specific, but it's fairly simple. >> >> And it only slows down the system calls that actually use "set_fs()". >> Sure, it will slow those down a fair amount, but they are hopefully a >> small subset of all cases. >> >> How does that sound to people? Thats' where we currently do that >> >> if (IS_ENABLED(CONFIG_PROVE_LOCKING) && >> WARN(irqs_disabled(), "syscall %ld left IRQs disabled", >> regs->orig_ax)) >> local_irq_enable(); >> >> check too, which is a fairly similar issue. > > I really like that idea and I'd be perfectly fine with that solution, because it > puts the overhead where the problem comes from, and adds an extra incentive for > code to move away from set_fs() facilities. Win-win. Great, I will adapt the patch for that. > > Thanks, > > Ingo -- Thomas