Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5704614ybl; Tue, 14 Jan 2020 13:34:24 -0800 (PST) X-Google-Smtp-Source: APXvYqy5GBK1BXHW0qf2sCmvw7SZ6/a5FKfWWnjrvGTrZjO9iuLGxssINa3Q7hQqAd4nxOGiCoxC X-Received: by 2002:aca:4587:: with SMTP id s129mr17693941oia.124.1579037664783; Tue, 14 Jan 2020 13:34:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579037664; cv=none; d=google.com; s=arc-20160816; b=uriu/AX4xWyVFXlS89HfZA+r1hXAC9+34FGT/sIu2U7CkqaoOOMM9Lz7QEM5Crwjuu KTx045+O8m+xgja/kvlQyaEu/kexHhyFFqcBOf9dELaZwtDxQR5Qgv3TU5+J2s+ti6wE KsdqDOtQZ2GsX0pFgMoXI002ugD39TnkknjblCsPJ9BSKHRQZP9IjXjG9aU5Emc+ejT3 uiBhPvDvaVE9S7by4QQMqKB+SeFFFxUAjc7JemEo846zMG51U568sWq1uK/Lo5rxvdqr Dj+QaBZh0+lZF7teVySPjv9Cliuqoxi+EGS7l6lVyCa43QYZsWa4y3osrub1SS5xAOXY E6fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=f5uoKw2YKLElJKDx+jK5wl0K2xjBXMt47XAsAkyAM+o=; b=UytIjs2235Up0hsRF6lUaLWJJdEOQMKs8B6Vt3fWKnSNGuCobxLj3fb+enMYjLGSHM rLz768WfcmSA5xl8H7akgSlbiK3U67HlVLGLC8B4TG6eyecfdkz0aBWRKj9j903WLXwk L6NyAggVx9Z9XMoN4t1FPJZxIxuUKBUDNhzjArIWY6HQQ0Eq6eZ/ahDDCqYk6Pl1blLY fLCplv5dtlkwbwnh7gqc9yGI9dSf/ViENtc9bygMa9UFlZP9VF9/IXZotZ7v2mvsj+df SiViCZfINPl/nO6vPPgWP8cxw7KStaQWOotmenG1P38DdL3w8OwqCj1xwlgMBtt/3UKJ dbZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=gVkyh4tP; 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 f21si9288103otp.56.2020.01.14.13.34.11; Tue, 14 Jan 2020 13:34:24 -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=@linux-foundation.org header.s=google header.b=gVkyh4tP; 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 S1727102AbgANVdM (ORCPT + 99 others); Tue, 14 Jan 2020 16:33:12 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:36519 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbgANVdL (ORCPT ); Tue, 14 Jan 2020 16:33:11 -0500 Received: by mail-lj1-f195.google.com with SMTP id r19so16098653ljg.3 for ; Tue, 14 Jan 2020 13:33:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=f5uoKw2YKLElJKDx+jK5wl0K2xjBXMt47XAsAkyAM+o=; b=gVkyh4tPO8RK11oXNRTkFnFw5qS02VpB8fRn7yuyjXBrIM8r/+uUtu3n5AJSu/v+0r 3KVUAw32daILdFTdwNmZ41g6fmO4U+5YEKf3aZPOaD0BxhRqx8Hhmkwlmzo36zFaxnqP lOdeXPMNVWW1hl8kB5QPM3J99EYMRT9fPNA7w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=f5uoKw2YKLElJKDx+jK5wl0K2xjBXMt47XAsAkyAM+o=; b=UbdQYoF5QXZbRuCqwr9MXqagLzVe7EqAvVcAIXsiKSDp3WDmd3iwQyZFHc/swuEbD4 mQbOXdmDeNRzZvCrfbhKF4n7Sy/77YAhQR+BRBCQXuzzuUq2QWS3kMC72S9G3rztBCoh i0RucJ0ZH7hYdUYlQaymBiRg8hbdnUi3nUXvHLPjhyZb5Sm8TrSI4ho71P1G7lRtM+mA vZ2R9TRzZGw92AOJ/vfwfHWdPqFZMsld1M/jZNGB0AQHNhecjOW8XYtIv2Nv0tRa7QHS 6+t2516r6lipatO3Pc+kOiR28LbZAS79pwGQ1xxqTLmP/wNUCP7vXXv8zd+ESeS20qD8 ZzXg== X-Gm-Message-State: APjAAAXfNx9IffbHaqk4Gl8pdPQrtHqjA2if2/3vO9Jrb+d41CGUAtjP aAya6puOFJOVwEAIBWpmLgpsAteuYoc= X-Received: by 2002:a2e:8646:: with SMTP id i6mr15893316ljj.122.1579037588024; Tue, 14 Jan 2020 13:33:08 -0800 (PST) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com. [209.85.208.172]) by smtp.gmail.com with ESMTPSA id 2sm8127647ljq.38.2020.01.14.13.33.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jan 2020 13:33:07 -0800 (PST) Received: by mail-lj1-f172.google.com with SMTP id w1so16104446ljh.5 for ; Tue, 14 Jan 2020 13:33:06 -0800 (PST) X-Received: by 2002:a2e:9510:: with SMTP id f16mr15481129ljh.249.1579037586642; Tue, 14 Jan 2020 13:33:06 -0800 (PST) MIME-Version: 1.0 References: <20200114200846.29434-1-vgupta@synopsys.com> <20200114200846.29434-2-vgupta@synopsys.com> In-Reply-To: <20200114200846.29434-2-vgupta@synopsys.com> From: Linus Torvalds Date: Tue, 14 Jan 2020 13:32:50 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 1/4] asm-generic/uaccess: don't define inline functions if noinline lib/* in use To: Vineet Gupta Cc: Arnd Bergmann , Khalid Aziz , Andrey Konovalov , Andrew Morton , Peter Zijlstra , Christian Brauner , Kees Cook , Ingo Molnar , Aleksa Sarai , linux-snps-arc@lists.infradead.org, Linux Kernel Mailing List , linux-arch Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 14, 2020 at 12:09 PM Vineet Gupta wrote: > > There are 2 generic varaints of strncpy_from_user() / strnlen_user() > (1). inline version in asm-generic/uaccess.h I think we should get rid of this entirely. It's just a buggy garbage implementation that nobody should ever actually use. It does just about everything wrong that you *can* do, wrong, including doing the NUL-filling termination of standard strncpy() that "strncpy_from_user()" doesn't actually do. So: - the asm-generic/uaccess.h __strncpy_from_user() function is just horribly wrong - the generic/uaccess.h version of strncpy_from_user() shouldn't be an inline function either, since the only thing it can do inline is the bogus one-byte access check that _barely_ makes security work (you also need to have a guard page to _actually_ make it work, and I'm not atr all convinced that people do). the whole thing is just broken and should be removed from a header file. > (2). optimized word-at-a-time version in lib/* That is - outside of the original x86 strncpy_from_user() - the only copy of this function that historically gets all the corner cases right. And even those we've gotten wrong occasionally. I would suggest that anybody who uses asm-generic/uaccess.h needs to simply use the generic library version. Linus