Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp333522pxb; Thu, 17 Feb 2022 05:16:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzs5wJbAyHcwIo+7CRqKmfSdCCPLIRO09UGDSs2Y3grTH4qeIKWsVw06vNouhZXRPJh7hzk X-Received: by 2002:a17:907:8a04:b0:6b4:e098:741a with SMTP id sc4-20020a1709078a0400b006b4e098741amr2315626ejc.550.1645103784442; Thu, 17 Feb 2022 05:16:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645103784; cv=none; d=google.com; s=arc-20160816; b=zJz0mjan4Z10fDo95H+Qjf9n/gi3VKeWWwz7HJBwu1DccS3E63v27FFT/W1vtvoJ53 HW8XlRwQ/gp0EHoLG6ZvsFRGS19NxMMKHAG7M75oyZdWIBO/9c7Cm0vbx88UNTmxbQPM xY/zj/rhT3D11ARx2vaG3gQ1gCAHzFYIe8lmL1OMpwSKwhl9s5ygFbipZQtPaunc5Dg1 i02MdinJbG337bf5L42CyTcGVu6u7pNt/QDB3VRkxpkMdLYUiPLr2Ghhw/eHCqcSU+R8 vGZMrfycDqQrBuEav51Ujlkk9dsV049gyh4JvROJFHnJe8QPVv1DI3Q0rmlUUdAG1NGW 3Nhw== 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=/clQZX/fw2OWVnHHui/dMKrv5Zei2PjYS/kS1c7stqo=; b=mEe3DaE6XFVVS7J+J77T2AeF8YdPl+euCkjuNJXGXSA+Q121hb8SrLopSn1q0OnN8z Wi/yYrMw8o3RslLIhcERy6VXhgEcq2+D+cXozBmpHUSjTGcCT50xSmF2JY4YoOJQB95s dtHqHETTwzsmwQbV5jXVUHX5ckzSPJyH5NXmnKYGPsFgJUvFTklbeeqJGXIA4A3fVul8 swNSIWth9AWcDYNeTa5/IOvb3XRl/Owm4BNRdNRltYV+NOlprgCpfV4HYB9UMK6hYdx4 jR0KqMzuyY5Z/BwljSF9pGcGVcL9BoTFzJXLgwwW6wB4s10E/GSImcSQDdBfwfvD/lwY fpQA== 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 cs1si2167255ejc.413.2022.02.17.05.16.00; Thu, 17 Feb 2022 05:16:24 -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 S236584AbiBQHxD (ORCPT + 99 others); Thu, 17 Feb 2022 02:53:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231381AbiBQHxC (ORCPT ); Thu, 17 Feb 2022 02:53:02 -0500 Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F841178386; Wed, 16 Feb 2022 23:52:47 -0800 (PST) Received: from mail-wr1-f54.google.com ([209.85.221.54]) by mrelayeu.kundenserver.de (mreue107 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MTRhS-1nhaUr1zAK-00TmQM; Thu, 17 Feb 2022 08:52:45 +0100 Received: by mail-wr1-f54.google.com with SMTP id x5so2599562wrg.13; Wed, 16 Feb 2022 23:52:45 -0800 (PST) X-Gm-Message-State: AOAM531TqIZdxzgjKe4IT23BQjAj1r63uuynd0Qg8QWg7OVn4Y2HxdBL jgNv3OGPn/PBpOvnautqsDKZ5B1nfPHZOSMxt4U= X-Received: by 2002:adf:ea01:0:b0:1e4:b3e6:1f52 with SMTP id q1-20020adfea01000000b001e4b3e61f52mr1268592wrm.317.1645084364936; Wed, 16 Feb 2022 23:52:44 -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: Arnd Bergmann Date: Thu, 17 Feb 2022 08:52:29 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 13/18] uaccess: generalize access_ok() To: Linus Torvalds , Christoph Hellwig , linux-arch , Linux-MM , Linux API , Arnd Bergmann , Linux Kernel Mailing List , Al Viro Cc: Russell King - ARM Linux , Will Deacon , Guo Ren , Brian Cain , Geert Uytterhoeven , 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 Miller , Richard Weinberger , "the arch/x86 maintainers" , Max Filippov , "Eric W . Biederman" , Andrew Morton , Ard Biesheuvel , alpha , "open list:SYNOPSYS ARC ARCHITECTURE" , 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-Provags-ID: V03:K1:6qcGhdTsQQvMIjB+11ipNF1DrG+OLInVcjYi4AXjSR4T+7w4a4G tvj/SU8V3XwoOWQPVG9LxfZPKnFfLZip/Q4k4pg7UiCm4QGSGIJG0sIDDl9GKfICP6+qAIY 2+TUcn5VnZN+i0sxBK5Yt242p2TWzmOaCg69Dt9OeqZlWdjtizeah9g/3PjyvE9B+9lCD1L cKNv6Z/s/LgftziOoQUwQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:CT/jrqtcU4M=:Zv3JDSyXiRmqHqKodZslB7 3QItAyZqGrrdujTkgjWTe2nLVFia6DNQFSxqyuKIbAZbvNq2qVE/eFLvQySB221PHtHXwneUV jDNmJ+8IvxTUh9sQ2tvEo798diQK/aMGpLb6zIxR3+FmT27CYi3O72DzVWnceCXZK/Ab97tjl 7yNpRfe9rseliofEBesnhBMlkoPAA3BkpAufttUG/1+JHNedB9jjpLNOTjRRTqx+xpCAe8TJu bekYeD49xY2n6gC6aMUr1P3If+IrOGrkCuU+Y/JgmVOzXR49gdzM1pvgLMeEh+IxznNF700YJ NSfkg3nwCztUCEcq4QrM0rYqRzo9VVeLE8clBCyFNwIBEK2h7V47gFGJU/jh1/OIgX+QDG1Bd ykoa0T4/6JAO1tRyeVLtwu5V4+O8XmfcIe/0HFAgKMomfIUv5z0TRjCBRPfVEgUT1z26sY8eZ V2FyUYhGL4T8niOYM0VMElPrWbPXCpkDTc32CTxUG4FtnLAUm5q0YtY8UCB5SfPmEvs872UcB JYG5FhZ6yvlju0HgBfXV5Ij6tGi8f6vs1Iul27i8PJDCX7NblHy1jMjIeeYujTJZOKGNZYuZF 9WygKkgt0tYdxs3IY9w1y1O6q5aO9ej6sDRdevCJ9Mgs53y7tapePFZlQFEK4n/xyuefbw+aG ONLsNcA4Js6RituaMOzRoHSki8u9w79atqtmfMMpr447tcY8vA0gG/lY1+mAY1SIShQrJuVPW IgaumcQOhFBhQLK33pRh20IdKBdAI/f98rh2rbS91AVhB4stYLN5lwF+Lp20cvEnO84Wlgc2W zPr4qrp2w7NFLOSP4dAsGZuNUvSWeaUnvz85A2q/N5hU7F34V4= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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:13 PM Arnd Bergmann wrote: > + * limit and catch all possible overflows. > + * On architectures with separate user address space (m68k, s390, parisc, > + * sparc64) or those without an MMU, this should always return true. ... > +static inline int __access_ok(const void __user *ptr, unsigned long size) > +{ > + unsigned long limit = user_addr_max(); > + unsigned long addr = (unsigned long)ptr; > + > + if (IS_ENABLED(CONFIG_ALTERNATE_USER_ADDRESS_SPACE)) > + return true; I noticed that I'm missing the check for !CONFIG_MMU here, despite mentioning that in the comment above it. I've added it now. Arnd