From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753888AbdASXok (ORCPT ); Thu, 19 Jan 2017 18:44:40 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:58860 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753361AbdASXoh (ORCPT ); Thu, 19 Jan 2017 18:44:37 -0500 Date: Fri, 20 Jan 2017 00:04:17 +0100 (CET) From: Thomas Gleixner To: "Frank Ch. Eigler" cc: David Smith , Peter Zijlstra , Linus Torvalds , Andy Lutomirski , Ingo Molnar , "H. Peter Anvin" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC][PATCH] x86: Verify access_ok() context In-Reply-To: <20170119212718.GC20931@redhat.com> Message-ID: 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> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Frank. On Thu, 19 Jan 2017, Frank Ch. Eigler wrote: > > 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 current is always accessible no matter in which context you are - task, softirq, hardirq, nmi ... > running with preemption and/or interrupts and/or pagefaults disabled > at that point, so in_task() objects. As Peter explained, neither preempt disable nor interrupt disable not pagefault disabled have any influence on in_task(). It merily checks the context: !in_softirq() && !in_hardirq() && !in_nmi(). So that warning happens definitely not from task context. Care to share the code? Thanks, tglx