Received: by 2002:ac2:5a04:0:0:0:0:0 with SMTP id q4csp950322lfn; Fri, 18 Feb 2022 01:25:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwraHy1fptYPw1V5MjGrtI0PG466pbUTYXU+aa9NP7KkdyAsbjWmC2tEhX7R6mRHOhGgsZn X-Received: by 2002:a17:906:8a5b:b0:6ce:2a05:813b with SMTP id gx27-20020a1709068a5b00b006ce2a05813bmr5722281ejc.589.1645176341131; Fri, 18 Feb 2022 01:25:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645176341; cv=none; d=google.com; s=arc-20160816; b=wBJHKKmCtn9PSfoxSF8yxjDPkTtYtPrWrdKu0LRJA+ARFTRcFUw1PTT3c3YRkCdkxM ISEiLSZwlUsk2S4riWN+rYkeoqUzGdP+ynKw8iH6hm/LGpu+j1L/1fxbiAI1FzMCPbAB raLf9xnjJIVCkSwoDp0Rvpl4EZ1w+Knh+ETr1vlKZy9uYU9ZoTVXzgUJdIPYx8/S255V MVqFCgp4pYOkANYXDjOjyjgBtj26KPyxpwS07Vu5IkGGkPZMq/gB45hN64xHWYW5kxb8 0WBXFD7rnbPyu1aBZooJdbNYhsxxWPUdUdmx5AjRynImcv9eS1J8obCiPj0fQ1Gg0XVL xi1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=PuyWdNt7E53vPgI1lZLvKTUut2bNACfNkxpc83Dke5E=; b=gmnkvORsXkQDSkupHipZsmriIUIAXkuHWnVQhsqIk4txuZ+b0frg6FtSYUqmz56ZhQ Shb3smnx/hLyrbQFtONkwOpa7WNalF+r5mUudhiE1ZFePEZx3k7QsUB5V50yHgQ3dlUb PW7G9TLRPVoMTs0ntEg6pVJI8rB9hLnhq+S9NHFn4O4Ts9P5ntkM6DEZ/7HGJSZCOTeh vsWUSAG3wn7MH+rcSYOXFduVs01OohWAVYmt4PiUZTCo5zJqZCoplarYHwnKQeqHAPT5 8xDqgMKaTfh39FexfdJVsFKOwFR1f4Prr5DvTaQ5N5H8MxGJbwYOhWeioHGUrtaeb8vW vOaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e13si5353016edj.526.2022.02.18.01.25.15; Fri, 18 Feb 2022 01:25:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233104AbiBRJFW (ORCPT + 99 others); Fri, 18 Feb 2022 04:05:22 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229974AbiBRJFT (ORCPT ); Fri, 18 Feb 2022 04:05:19 -0500 Received: from mail-vs1-f50.google.com (mail-vs1-f50.google.com [209.85.217.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FFC22B3AE9; Fri, 18 Feb 2022 01:05:03 -0800 (PST) Received: by mail-vs1-f50.google.com with SMTP id i27so9182541vsr.10; Fri, 18 Feb 2022 01:05:03 -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=zUYJ8DyJR0XAKhK2aW0V9Dz5HZK8N2AShWYfXed/095wWvB9CTROSnVccH2xxl8401 OPOFsY3QwwjlpYOa49V1SKWTw8JZxF5a6UmpldbN+uZpVHnyFxRdTj6BBXt7N+CNzZeC HF492QU03VheHV2E3rONZNDiLjSAiCIrHZ65/B8DovbOlnqsUQ8DnoofWhRGwBf9SPkc 2NritbCd9BwcCt6KnbiqtErwN1OBcznH2H+kPYUloePwmFwuh67k1afILANcpie/yjs3 C9IRul6X2QmwCiP0Qs5eJoESDoyzR/bBCqps66NALqwZjgltxqK3+wsRZHvZpFYK6M+T dw0A== X-Gm-Message-State: AOAM5338XgfM7ilE8sEUHCOp2zT4J3li4HDjCc5KHJ81iqWywcfCNh+G Mhiym2eKnAH3MdNcIa05ebFa73cuomOP2w== X-Received: by 2002:a67:e113:0:b0:30e:303d:d1d6 with SMTP id d19-20020a67e113000000b0030e303dd1d6mr3157595vsl.38.1645175102120; Fri, 18 Feb 2022 01:05:02 -0800 (PST) Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com. [209.85.217.47]) by smtp.gmail.com with ESMTPSA id 187sm7012763vsi.12.2022.02.18.01.04.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Feb 2022 01:05:00 -0800 (PST) Received: by mail-vs1-f47.google.com with SMTP id u10so9172361vsu.13; Fri, 18 Feb 2022 01:04:59 -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-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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