From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752675AbdASWU0 (ORCPT ); Thu, 19 Jan 2017 17:20:26 -0500 Received: from imslp-west.kjsl.com ([65.50.211.133]:44330 "EHLO bombadil.infradead.org" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751719AbdASWUZ (ORCPT ); Thu, 19 Jan 2017 17:20:25 -0500 Date: Thu, 19 Jan 2017 23:20:08 +0100 From: Peter Zijlstra To: "Frank Ch. Eigler" Cc: Thomas Gleixner , David Smith , Linus Torvalds , Andy Lutomirski , Ingo Molnar , "H. Peter Anvin" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC][PATCH] x86: Verify access_ok() context Message-ID: <20170119222008.GI6515@twins.programming.kicks-ass.net> References: <20161122193720.GA3045@worktop.programming.kicks-ass.net> <20161205102747.GT3092@twins.programming.kicks-ass.net> <8758e5b4-050d-a5dd-2e58-e4f9dccc734b@redhat.com> <20170119202218.GB20931@redhat.com> <20170119212718.GC20931@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170119212718.GC20931@redhat.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 19, 2017 at 04:27:18PM -0500, Frank Ch. Eigler wrote: > Hi, Thomas - > > > Well, if you are not in thread context then the check is pointless: > > __range_not_ok(addr, size, user_addr_max()) > > and: > > #define user_addr_max() (current->thread.addr_limit.seg) > > > > So what guarantees when you are not in context of current, i.e. in thread > > context, that the addr/size which is checked against the limits of current > > actually belongs to current? > > We're probably in task context in that there is a valid current(), but > running with preemption and/or interrupts and/or pagefaults disabled > at that point, so in_task() objects. Think of it like from a kprobes > handler callback, except maybe more temporary preemption blocking. #define in_task() (!(preempt_count() & \ (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET))) So it doesn't care about preempt_disable(), and it doesn't care about local_irq_disable(), it also doesn't care about local_bh_disable(). What it does care about are nmi_enter(), irq_enter() and __do_softirq().