From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B01C4C433EF for ; Fri, 18 Feb 2022 09:12:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B9236B0074; Fri, 18 Feb 2022 04:12:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 268A36B0075; Fri, 18 Feb 2022 04:12:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 130536B0078; Fri, 18 Feb 2022 04:12:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id 043546B0074 for ; Fri, 18 Feb 2022 04:12:29 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id AD0981815B7CF for ; Fri, 18 Feb 2022 09:12:28 +0000 (UTC) X-FDA: 79155334776.07.07D183B Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf11.hostedemail.com (Postfix) with ESMTP id 203AF40003 for ; Fri, 18 Feb 2022 09:12:27 +0000 (UTC) Received: by mail-pl1-f174.google.com with SMTP id l8so6689295pls.7 for ; Fri, 18 Feb 2022 01:12:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PuyWdNt7E53vPgI1lZLvKTUut2bNACfNkxpc83Dke5E=; b=I1KLKxh7FDmV+wCAKB+hm7m1+DynwHO0EeshqIOJZrxjh26SIP+JVYRdcx46nKKULx 7WF7e3o8XeCdNZaKaW/dBy2ljMQolv9pWtoOp6c8HgUFZqFEbMdiuoxJ4mA3Wjlvn429 +tIaUIBkP/NoqGmFU7PBgFkw1I5sSPnX2oRB7hT3kKZRLhA1kzGZAIAOhwxc/l6mJwSE 6S014M4o1bNL52Crk4DVbDfMjWX24DycedFV5kqjhI92XTpxCceF+mqu1NikccQSaj80 VvCWSZwpIH0oFGnRRl0Wpwr4Y02c4BK9AngL/bVLIqzOC9/1zv+romwGn9WexImcsLOe kmhQ== X-Gm-Message-State: AOAM530q4aDf+jlsy2qzwMxQmwF+cRnvcDz0W9odZ3QDCZPHzkSdZcw0 faTdF3rvqWlhFrhUWdIqKHI2wptV+g04Kw== X-Google-Smtp-Source: ABdhPJyJNyDxhet5hepthwTtmiBbiFjn5XIgCAadX3SUavvUmYSNyTQnkIy507++FRetJcaLOXtw2g== X-Received: by 2002:a17:902:7296:b0:14b:4bc6:e81 with SMTP id d22-20020a170902729600b0014b4bc60e81mr6666312pll.132.1645175546827; Fri, 18 Feb 2022 01:12:26 -0800 (PST) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com. [209.85.214.176]) by smtp.gmail.com with ESMTPSA id ml19sm4080241pjb.52.2022.02.18.01.12.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Feb 2022 01:12:26 -0800 (PST) Received: by mail-pl1-f176.google.com with SMTP id w20so6668936plq.12 for ; Fri, 18 Feb 2022 01:12:26 -0800 (PST) X-Received: by 2002:a67:b00e:0:b0:30d:dc98:6024 with SMTP id z14-20020a67b00e000000b0030ddc986024mr3285076vse.57.1645175099822; Fri, 18 Feb 2022 01:04:59 -0800 (PST) MIME-Version: 1.0 References: <20220216131332.1489939-1-arnd@kernel.org> <20220216131332.1489939-14-arnd@kernel.org> In-Reply-To: <20220216131332.1489939-14-arnd@kernel.org> From: Geert Uytterhoeven Date: Fri, 18 Feb 2022 10:04:48 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 13/18] uaccess: generalize access_ok() To: Arnd Bergmann Cc: Linus Torvalds , Christoph Hellwig , Linux-Arch , Linux MM , Linux API , Arnd Bergmann , Linux Kernel Mailing List , Al Viro , Russell King , Will Deacon , Guo Ren , Brian Cain , Michal Simek , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Dinh Nguyen , Stafford Horne , Helge Deller , Michael Ellerman , Peter Zijlstra , Ingo Molnar , Mark Rutland , Heiko Carstens , Rich Felker , "David S. Miller" , Richard Weinberger , "the arch/x86 maintainers" , Max Filippov , "Eric W. Biederman" , Andrew Morton , Ard Biesheuvel , alpha , arcml , linux-csky@vger.kernel.org, "open list:QUALCOMM HEXAGON..." , "linux-ia64@vger.kernel.org" , linux-m68k , "open list:BROADCOM NVRAM DRIVER" , Openrisc , Parisc List , linuxppc-dev , linux-riscv , linux-s390 , Linux-sh list , sparclinux , linux-um , "open list:TENSILICA XTENSA PORT (xtensa)" Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 203AF40003 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com; dmarc=none X-Stat-Signature: sk8kixypd34erw64fxitg9kju91dxs1s X-HE-Tag: 1645175547-875545 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Feb 16, 2022 at 2:17 PM Arnd Bergmann wrote: > From: Arnd Bergmann > > There are many different ways that access_ok() is defined across > architectures, but in the end, they all just compare against the > user_addr_max() value or they accept anything. > > Provide one definition that works for most architectures, checking > against TASK_SIZE_MAX for user processes or skipping the check inside > of uaccess_kernel() sections. > > For architectures without CONFIG_SET_FS(), this should be the fastest > check, as it comes down to a single comparison of a pointer against a > compile-time constant, while the architecture specific versions tend to > do something more complex for historic reasons or get something wrong. > > Type checking for __user annotations is handled inconsistently across > architectures, but this is easily simplified as well by using an inline > function that takes a 'const void __user *' argument. A handful of > callers need an extra __user annotation for this. > > Some architectures had trick to use 33-bit or 65-bit arithmetic on the > addresses to calculate the overflow, however this simpler version uses > fewer registers, which means it can produce better object code in the > end despite needing a second (statically predicted) branch. > > Reviewed-by: Christoph Hellwig > Acked-by: Mark Rutland [arm64, asm-generic] > Signed-off-by: Arnd Bergmann > arch/m68k/Kconfig.cpu | 1 + > arch/m68k/include/asm/uaccess.h | 19 +-------- Acked-by: Geert Uytterhoeven Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds