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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E942C433F5 for ; Fri, 18 Feb 2022 09:05:41 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K0QlR6qMYz3cZC for ; Fri, 18 Feb 2022 20:05:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=209.85.210.176; helo=mail-pf1-f176.google.com; envelope-from=geert.uytterhoeven@gmail.com; receiver=) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K0Qkx5nQrz2ywt for ; Fri, 18 Feb 2022 20:05:13 +1100 (AEDT) Received: by mail-pf1-f176.google.com with SMTP id i6so1829650pfc.9 for ; Fri, 18 Feb 2022 01:05:13 -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=aLaQ2dcYQjRjpg9ceUt0fsC8iZlRwy+ZKBR0xZa9XOwiaI9DuO+zNzIfvjrX/Ed57u Gh7iPToy3AOTOjhIDaByGPwHH47w1S5QR0xXJzzHtB+N6DXYXKfBVbIbNsJDyiL65E3b 9jHnqYw4ebkpXadeqZ19cCDZ4Q7AvqL0wc09Iuj9OQ/Cy0K8VZi8BoruYBjGAliman6u D7Pid3Qq9uKwJ+5mwTNuVjKUqd37cD++DllYgem1IDFmfpq0PHuca6hHxoCIqi35wc6X j5J36eVFAtnH8H7ZppK2UUaucD4jZ2tyY0BIHeEcXmv/wiYIBVrRa+yLB5E4p84NIy04 yRVA== X-Gm-Message-State: AOAM530YieVdZCw/GQ0iPRKIiavebnGLBzVzsI/F94F58ckpAFu/EQtn YOmQ67O4Z2Mkim9umP3LKlpXX+4RfI9UfQ== X-Google-Smtp-Source: ABdhPJyO0gCg35HYeiq3Bq5+I4XhGcvplY+7neKp4s+0XoXpWCfFRle41oDyV6HywsffmwG0reCAbA== X-Received: by 2002:a63:200d:0:b0:373:a7d1:75d4 with SMTP id g13-20020a63200d000000b00373a7d175d4mr5210829pgg.547.1645175111058; Fri, 18 Feb 2022 01:05:11 -0800 (PST) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com. [209.85.210.170]) by smtp.gmail.com with ESMTPSA id l8sm2379128pfc.187.2022.02.18.01.05.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Feb 2022 01:05:10 -0800 (PST) Received: by mail-pf1-f170.google.com with SMTP id x18so1845183pfh.5 for ; Fri, 18 Feb 2022 01:05:10 -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 Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Rich Felker , "linux-ia64@vger.kernel.org" , Linux-sh list , Peter Zijlstra , "open list:BROADCOM NVRAM DRIVER" , Linux MM , Guo Ren , sparclinux , "open list:QUALCOMM HEXAGON..." , linux-riscv , Will Deacon , Christoph Hellwig , Linux-Arch , linux-s390 , Brian Cain , Helge Deller , the arch/x86 maintainers , Russell King , linux-csky@vger.kernel.org, Ard Biesheuvel , Ingo Molnar , arcml , "open list:TENSILICA XTENSA PORT \(xtensa\)" , Arnd Bergmann , Heiko Carstens , alpha , linux-um , linuxppc-dev , linux-m68k , Openrisc , Al Viro , Stafford Horne , Michal Simek , Thomas Bogendoerfer , Parisc List , Nick Hu , Max Filippov , Linux API , Linux Kernel Mailing List , Dinh Nguyen , "Eric W. Biederman" , Richard Weinberger , Andrew Morton , Linus Torvalds , "David S. Miller" , Greentime Hu Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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