Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3096262imb; Tue, 5 Mar 2019 00:23:58 -0800 (PST) X-Google-Smtp-Source: APXvYqz5YTlrsiG1Ube2W+9zzEX4TMlR9apmOiNAJArN0al1Kkui1scQlThRddz14FlnARzVjOO6 X-Received: by 2002:a17:902:7b85:: with SMTP id w5mr25351512pll.288.1551774238167; Tue, 05 Mar 2019 00:23:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551774238; cv=none; d=google.com; s=arc-20160816; b=XOFtScrKgpfLIoK/VLqihQWwrqoa2hlpXnl4EEPbGKiPj5Zky1FBCtugdwDLYW6ehw nS1OtTAkf09lHSZl13t132YuRVdkrqkN9Ef8eq9XLTjHADGNgsdQrn7VX15naC3z3mKJ rUfVduoFiQngk+nW1Bwn1r49OzUCun8ICw8f+aTXM6Yfs4CLL99o+T21S9+J+X5WXr+t xyMJJi9w9Ctoz7FrTA6cLAuhx/tWrkMEPeTLydqfFnBuWkPfxHfZloweqQv5X8JCHr1B fL8cL9DVwhkPxOxoFCaOObr4XZXtBodGYAwUihha2fECfwigAxQPFLrIJ4SIp7V78Lod flfg== 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=RciQy51RNlOJ9P482TNrOQ778KvMKnmUx8Q25kt3fZI=; b=XcEa6hmXNqoEsRXxVGAb5kWHMvljX7FfUxL7BIMz3SkQKW7EbehYQFJ8KTw0QBXeXc dS+Zto1dsCdjLYixRffQ/0COKWQ7fFREHoeyJjD/l51M5/tALKtsZ1ZXben42uhoLfqu FaNfQL1T8iRfnOP6ygX7AG2eVTLDddWs4KZj8Yv67I228R4ojgNotDCHIG/RVeFA63qP SCd7BaZIbJLX9NQP1zhm6xSoIkK7hpqKztS95sE8Y7X2kH3Q8O2LRuabnaCnnbueTzm7 XhJtILayaHwpdLf07spFjwcKrenPik5EXKoOvgqNP4q5oGgGWDFcfKfvhXDPCoVmSfOR AD4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n3J2auzM; 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 f22si7048032pgv.578.2019.03.05.00.23.42; Tue, 05 Mar 2019 00:23:58 -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=pass header.i=@kernel.org header.s=default header.b=n3J2auzM; 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 S1727112AbfCEIWr (ORCPT + 99 others); Tue, 5 Mar 2019 03:22:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:46512 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726995AbfCEIWr (ORCPT ); Tue, 5 Mar 2019 03:22:47 -0500 Received: from devnote (p218086-mobac01.tokyo.ocn.ne.jp [153.233.209.86]) (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 C3BC9206DD; Tue, 5 Mar 2019 08:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551774166; bh=Xyq8EGBEULgsSRBn/tVhdClVUK+CL2ExTD94fLkdPak=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=n3J2auzM3LFuPtNXAm77yrAK/EbBlgYHNj6uZi0AOnpJBn9kGkPEG5LWkSzU9nqtM 7U8w+llYVrnH0HBq58dOK0AgaPMunB1dru06roHSNgpire1VmgsoNZJIFYJCb/wHiW BJ51cFeLl6TNgEuSeVpUQErtunewzFKGiStNGw1s= Date: Tue, 5 Mar 2019 17:22:41 +0900 From: Masami Hiramatsu To: Masami Hiramatsu Cc: Linus Torvalds , Peter Zijlstra , kernel test robot , Steven Rostedt , Shuah Khan , Linux List Kernel Mailing , Andy Lutomirski , Ingo Molnar , Andrew Morton , Changbin Du , Jann Horn , Kees Cook , Andy Lutomirski , Alexei Starovoitov , Nadav Amit , Joel Fernandes , yhs@fb.com, lkp@01.org Subject: Re: [uaccess] 780464aed0: WARNING:at_arch/x86/include/asm/uaccess.h:#strnlen_user/0x Message-Id: <20190305172241.2eef39c6ca74d09120bbbcad@kernel.org> In-Reply-To: <20190305113635.18f80ea3b1f4fca54b9d21e4@kernel.org> References: <155136980507.2968.15165201054223875356.stgit@devbox> <20190303173954.kliegojbuigqi5tn@inn2.lkp.intel.com> <20190304101434.8429ffffb17813c0e7930130@kernel.org> <20190304180610.2d4f6f08d9ad89d6abae3597@kernel.org> <20190305113635.18f80ea3b1f4fca54b9d21e4@kernel.org> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; 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 Tue, 5 Mar 2019 11:36:35 +0900 Masami Hiramatsu wrote: > On Mon, 4 Mar 2019 10:59:22 -0800 > Linus Torvalds wrote: > > I think the better way to do this is allowing strncpy_from_user() > if some conditions are match, like > > - strncpy_from_user() will be able to copy user memory with set_fs(USER_DS) > - strncpy_from_user() can copy kernel memory with set_fs(KERNEL_DS) > - strncpy_from_user() can access unsafe memory in IRQ context if > pagefault is disabled. > > This is almost done, except for CONFIG_DEBUG_ATOMIC_SLEEP=y on x86. > > So, what about adding a condition to WARN_ON_IN_IRQ() like below > instead of introducing user_access_ok() ? > > diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h > index 780f2b42c8ef..ec0f0b74c9ab 100644 > --- a/arch/x86/include/asm/uaccess.h > +++ b/arch/x86/include/asm/uaccess.h > @@ -70,7 +70,7 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un > }) > > #ifdef CONFIG_DEBUG_ATOMIC_SLEEP > -# define WARN_ON_IN_IRQ() WARN_ON_ONCE(!in_task()) > +# define WARN_ON_IN_IRQ() WARN_ON_ONCE(pagefault_disabled() && !in_task()) Oops, I meant !pagefault_disabled() && !in_task(). > #else > # define WARN_ON_IN_IRQ() > #endif > > Of course we have to move pagefault_disabled() macro in somewhere better place. And I think we don't need it. anyway the macro is referenced via linux/uaccess.h. Thank you, -- Masami Hiramatsu