Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5506609ybf; Thu, 5 Mar 2020 01:55:20 -0800 (PST) X-Google-Smtp-Source: ADFU+vsM4uPFJD76LjBWKLeKyZEDmHVBnIrTvqThq9wS/B2+3T+sQ/9d5rPU8XVMeQl95AHfNuPG X-Received: by 2002:a9d:21c5:: with SMTP id s63mr5820571otb.142.1583402120093; Thu, 05 Mar 2020 01:55:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583402120; cv=none; d=google.com; s=arc-20160816; b=ZHnC+w9B7/5LUT9h/+YmX+4H1P4vF1g1C5j1Q4A8gb2fvjVc9wPwS9aarlNj21G5A8 gdeMhXVqzc1RNZQ7jy9Z+A8DgCBjLA4TipGRDod+KLfCa5zLQXVL6d+NVPPWibG9b6+j D/gn3cTo8vZ6QU0sXVK8SvlYUBmUrGVNGNyXUcp+hDTNdlBCgufSN1TCICd0XiuPEOEi 103oXoBu+PvBWtjgxyWFiRdLfZQqWZJUes/vKR1XPm3grEkHjJDyfcPRGWd/PI1DJYhc 2vtkW7nPwigeJBn44A2kBXnThO4J0XqP0rEHxfTVV1g0rG5Mupy71+AMHad1HH17dbu0 Aljg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gGA7flVCST725vtJqB26uJyaaG/lu1I8Qz42onV745s=; b=zCIw77fl1rWLDXzRMkwuPJl+SYrAh/3saplNUxP1akenUE9n6MpoobClmCxTp1Bx3+ cs8XyfkfbUMrKYV92cUzRE5iVMm+kaCLOOEEeI8HyhvB7ffLMFQiAvx4wMujRGc9EVQs A5c0JJ7evCiQeqrNtZds2IZveOQ7KhPar3EeBd80JWm06nCuxjlkQhGDy4p+0pATmf3J txKY83AwjNVozmgUZ+sUzNOG1up8dpK+p52jvJ7ybwwEjQFht71VMhDfQzgu8dNDUWe1 gD7uBJitvZuUn4WfZwgJe6ukNJ+qlyfns3OsSwI/v5lUfSpHVu2gU0j0+g3e2VCmGldq K73A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XDSFNWk5; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s64si3157068oig.147.2020.03.05.01.55.07; Thu, 05 Mar 2020 01:55:20 -0800 (PST) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XDSFNWk5; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726764AbgCEJyq (ORCPT + 99 others); Thu, 5 Mar 2020 04:54:46 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:44246 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725877AbgCEJyq (ORCPT ); Thu, 5 Mar 2020 04:54:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=gGA7flVCST725vtJqB26uJyaaG/lu1I8Qz42onV745s=; b=XDSFNWk5Ipa30OZfsw2YqPZNqS 0jh9PBOidx9nmuBysUH6767sUR6aNmMdZt4qGxdwR02hSbr1E7usd6xToFhaU0uZL7oPlEuhj3/pv wfTiZbVLTywcNIgleBztTZfHBKOtgF0Sj6/hW120Qik5I8TX252+LoAollcXU0MszWLZ1qXtOdwbS s+3xbMeJhTzJ+GgQf2RLGzzT6xVU+GMtW0uEcBoM8MqcqFCWpaSrMh6KE0r4a8NcUJkadizEhA3ql D9AsIBdHJQuq2dUkboUn+S5cYDknYz2dSIS56y0zcqyI+RQH87x7zbRFWHwfZtVJmPLV+CvhNTMuf 79sRhkpA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9nDC-0008AR-Rr; Thu, 05 Mar 2020 09:54:39 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 92D92300606; Thu, 5 Mar 2020 10:52:37 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2106C23D4FA17; Thu, 5 Mar 2020 10:54:36 +0100 (CET) Date: Thu, 5 Mar 2020 10:54:36 +0100 From: Peter Zijlstra To: Walter Wu Cc: Randy Dunlap , akpm@linux-foundation.org, broonie@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-next@vger.kernel.org, mhocko@suse.cz, mm-commits@vger.kernel.org, sfr@canb.auug.org.au, Josh Poimboeuf , dvyukov@google.com Subject: Re: mmotm 2020-03-03-22-28 uploaded (warning: objtool:) Message-ID: <20200305095436.GV2596@hirez.programming.kicks-ass.net> References: <20200304062843.9yA6NunM5%akpm@linux-foundation.org> <20200305081717.GT2596@hirez.programming.kicks-ass.net> <20200305081842.GB2619@hirez.programming.kicks-ass.net> <1583399782.17146.14.camel@mtksdccf07> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1583399782.17146.14.camel@mtksdccf07> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 05, 2020 at 05:16:22PM +0800, Walter Wu wrote: > On Thu, 2020-03-05 at 09:18 +0100, Peter Zijlstra wrote: > > On Thu, Mar 05, 2020 at 09:17:17AM +0100, Peter Zijlstra wrote: > > > On Wed, Mar 04, 2020 at 09:34:49AM -0800, Randy Dunlap wrote: > > > > > > mm/kasan/common.o: warning: objtool: kasan_report()+0x13: call to report_enabled() with UACCESS enabled > > > > > > I used next/master instead, and found the below broken commit > > > responsible for this. > > > > > @@ -634,12 +637,20 @@ void kasan_free_shadow(const struct vm_struct *vm) > > > #endif > > > > > > extern void __kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip); > > > +extern bool report_enabled(void); > > > > > > -void kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip) > > > +bool kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip) > > > { > > > - unsigned long flags = user_access_save(); > > > + unsigned long flags; > > > + > > > + if (likely(!report_enabled())) > > > + return false; > > > > This adds an explicit call before the user_access_save() and that is a > > straight on bug. > > > Hi Peter, > > Thanks for your help. Unfortunately, I don't reproduce it in our > environment, so I have asked Stephen, if I can reproduce it, then we > will send new patch. The patch is trivial; and all you need is an x86_64 (cross) compiler to reproduce. diff --git a/mm/kasan/common.c b/mm/kasan/common.c index ad2dc0c9cc17..2906358e42f0 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -618,16 +618,17 @@ extern bool report_enabled(void); bool kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip) { - unsigned long flags; + unsigned long flags = user_access_save(); + bool ret = false; - if (likely(!report_enabled())) - return false; + if (likely(report_enabled())) { + __kasan_report(addr, size, is_write, ip); + ret = true; + } - flags = user_access_save(); - __kasan_report(addr, size, is_write, ip); user_access_restore(flags); - return true; + return ret; } #ifdef CONFIG_MEMORY_HOTPLUG