Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp729162ybi; Fri, 21 Jun 2019 07:13:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuVbeKM9DyeZVmnpXhsC2+X2nLhDe5TZrcxWx4wUndT2vsroAH7kthzJQROG2dHbqomRtw X-Received: by 2002:a65:4946:: with SMTP id q6mr5625999pgs.323.1561126385166; Fri, 21 Jun 2019 07:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561126385; cv=none; d=google.com; s=arc-20160816; b=ToqLsq9lqMtsYBLlEMO5Y4YiRHSJ6Lr3otzFy6S2opb96BnVjm+z2W8E8Lt6+xbuAc M1EXOVR0ouZsdhH1cAbYIh5CSY1qvDuUVeVdvSLCNyfyKGbYF4MKvG6c/GKyhVh5EY0w /YI7mCOktVrhX8G2Q7DVgkSAcpNFSBBbdCRNuZsoOLsWXIbbDTzILZ87h9fkEYDxGqFP pJ0BeV2WleuL8CyuT9TlJWNO03zyJZV6hIAZzpTnfVeH/BMq5I9m4gM1ZZ6oZTHxvvGi yeECHRKAy6LULtCdbjvNSMn95XVf5wfXOUy3H6LkgXQnQFfrvHGPnXTz7t9KPOePkRQL 9Z2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=SBis0+CdGzTF2ggh6HwIAfSPlZFLlvefKWhQmXOuH/I=; b=nfnUWnTGiEZ8/WyiHhb7twNKJWDQqFLDIO564Ip3phnFzjKMCCpCJDFwTMhRlZ5lOz nuBjWPph1iSAN+bupTkYUM4vHdifZ2593Y4AWkXqcyY4Y3i2UobM4H/Ajf1ngGhKcGCa /zJVXmcBPAriFaq/oQCJjuayI0kUpK3SQuZRdfJuZIroojumHsEeqG4wjiLDhrnprfun b05On4pXsWEc81AzEiSsWj2rek2IAsqB53Ot0ekl1XPF/qs42nal8CdnI9nsKrKqgC2U fMpBfxLFFlPZfa6pQCchkiH7aDvDvWx+peJP1RMfwUb7mGP4tDO0252Ku1l5yznUSln/ +Jsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iWxgDadI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay3si2808523plb.174.2019.06.21.07.12.49; Fri, 21 Jun 2019 07:13:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iWxgDadI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726178AbfFUOMi (ORCPT + 99 others); Fri, 21 Jun 2019 10:12:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:43292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725985AbfFUOMi (ORCPT ); Fri, 21 Jun 2019 10:12:38 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B003B20679; Fri, 21 Jun 2019 14:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561126357; bh=G84cVl5U5XlLByeL5a0wTKaDWpH+c8GB7sbMdafSIyM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iWxgDadIIMQNr42MRK4sNX1lV++z1lT0Tex5UZtMnkMExk7i5Q4ZfzPJz6ip5stCQ UnzWAGwftOy6ujrpdIQbZJHOe6P2e7GE9bWBW3hNpqhrTpwL1ZqjYcwrZIQTcanN/k qsc/lS+UOYx7/A8Q4wm5ecSjXRJL4Vep+aw9qPLc= Date: Fri, 21 Jun 2019 23:12:32 +0900 From: Masami Hiramatsu To: Steven Rostedt Cc: Thomas Gleixner , LKML , Peter Zijlstra , Ingo Molnar , Clark Williams , Juri Lelli , Masami Hiramatsu , Linus Torvalds Subject: Re: WARN_ON: userstacktrace on irq events Message-Id: <20190621231232.259536faeea4b19cf39a7688@kernel.org> In-Reply-To: <20190405093209.7a5c5133@gandalf.local.home> References: <20190403121640.70128095@gandalf.local.home> <20190405093209.7a5c5133@gandalf.local.home> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 5 Apr 2019 09:32:09 -0400 Steven Rostedt wrote: > On Fri, 5 Apr 2019 10:12:27 +0200 (CEST) > Thomas Gleixner wrote: > > > > BOOM! Warn on. > > > > > > Can we make that access_ok() call in the copy_stack_frame not trigger > > > the warning just if we are in an interrupt? > > > > You really want to have access_ok_atomic() or such which does not have the > > WARN and use that in copy_stack_frame(). That's fine here because the > > actual copy is inside a pagefault disabled region. > > I was thinking the same. > > Masami, did you post patches to do something like this? > "access_ok_inatomic()" or something? Yeah, last month I sent "x86/uaccess: Allow access_ok() in irq context if pagefault_disabled" If you correctly disables the pagefault, access_ok() shouldn't warn it. Ah, I see. copy_stack_frame(const void __user *fp, struct stack_frame_user *frame) { int ret; if (!access_ok(fp, sizeof(*frame))) <== this is out of pagefault_disable()! return 0; ret = 1; pagefault_disable(); if (__copy_from_user_inatomic(frame, fp, sizeof(*frame))) ret = 0; pagefault_enable(); return ret; } How is below patch? --- diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c index 2abf27d7df6b..36ff77c801f7 100644 --- a/arch/x86/kernel/stacktrace.c +++ b/arch/x86/kernel/stacktrace.c @@ -98,14 +98,11 @@ struct stack_frame_user { static int copy_stack_frame(const void __user *fp, struct stack_frame_user *frame) { - int ret; + int ret = 1; - if (!access_ok(fp, sizeof(*frame))) - return 0; - - ret = 1; pagefault_disable(); - if (__copy_from_user_inatomic(frame, fp, sizeof(*frame))) + if (!access_ok(fp, sizeof(*frame)) || + __copy_from_user_inatomic(frame, fp, sizeof(*frame))) ret = 0; pagefault_enable(); -- Masami Hiramatsu