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 BC7FFC433FE for ; Fri, 18 Feb 2022 09:00:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 251A16B0074; Fri, 18 Feb 2022 04:00:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 200E26B0075; Fri, 18 Feb 2022 04:00:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A2AC6B0078; Fri, 18 Feb 2022 04:00:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id EC9936B0074 for ; Fri, 18 Feb 2022 04:00:53 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B46A1998C4 for ; Fri, 18 Feb 2022 09:00:53 +0000 (UTC) X-FDA: 79155305586.26.4FE69BB Received: from mail-vs1-f54.google.com (mail-vs1-f54.google.com [209.85.217.54]) by imf20.hostedemail.com (Postfix) with ESMTP id 3F4281C0006 for ; Fri, 18 Feb 2022 09:00:53 +0000 (UTC) Received: by mail-vs1-f54.google.com with SMTP id d26so4387650vsh.0 for ; Fri, 18 Feb 2022 01:00:53 -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=1nYL/qjPVlkIqK+5dnbJ/5QVdVKG9AQSDTVmJuSTxwE=; b=jBzLaNtJyUnr1GxXvjs34INcX518n2twf8jeaKiWHZd5WfhmHemkeGu2JVi7J1JHxv JWsMgdbCeGqbzjkq3UhZ7YprRDrIvEScizf6XW3lDDLlO7WNIQsryozD7YYwrsk7m0pw e6s+jPmz8TVfnXMuPOnD2yJNa47BMqtaSspOPen/Maw+gywc8MTt0qbEwFg/4OeSGVoq 7Ee/GGBS2ol0nE47h/xUnZRB2GrwsELEfyUBMVVB++4ySdR5d+IxQqBQk1PZ9a9H/jFn bQSl239O6+lSPDucxxIJnWpuQRzcD4TEbLetRqiW2kacDUs1os9U+JjT0uolJjydd/vf ULFw== X-Gm-Message-State: AOAM533eCg338YRENVmTG9Vdl+1bncLHRBIQGmGFxcLfZvzal8gzqDFK au4HPEtQqkM6/sopGAUJk/izWBh/nd3fow== X-Google-Smtp-Source: ABdhPJxWjZ1Us1nD5rQgm6UNqfubkXAQmZBXPxST86m6Aw2A9zZfCFQCGzkAnd5TT91U6JqEG6dP7A== X-Received: by 2002:a67:ca02:0:b0:31b:70d7:a97c with SMTP id z2-20020a67ca02000000b0031b70d7a97cmr2888103vsk.75.1645174852128; Fri, 18 Feb 2022 01:00:52 -0800 (PST) Received: from mail-vs1-f46.google.com (mail-vs1-f46.google.com. [209.85.217.46]) by smtp.gmail.com with ESMTPSA id d1sm369370vsd.24.2022.02.18.01.00.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Feb 2022 01:00:51 -0800 (PST) Received: by mail-vs1-f46.google.com with SMTP id d11so5171553vsm.5 for ; Fri, 18 Feb 2022 01:00:50 -0800 (PST) X-Received: by 2002:a67:e113:0:b0:30e:303d:d1d6 with SMTP id d19-20020a67e113000000b0030e303dd1d6mr3151546vsl.38.1645174850220; Fri, 18 Feb 2022 01:00:50 -0800 (PST) MIME-Version: 1.0 References: <20220216131332.1489939-1-arnd@kernel.org> <20220216131332.1489939-11-arnd@kernel.org> In-Reply-To: <20220216131332.1489939-11-arnd@kernel.org> From: Geert Uytterhoeven Date: Fri, 18 Feb 2022 10:00:39 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 10/18] m68k: fix access_ok for coldfire 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-Queue-Id: 3F4281C0006 X-Stat-Signature: 6mxax5shur3dxfeennh6airxhsqkkr8t X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf20.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.217.54 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com X-Rspamd-Server: rspam03 X-HE-Tag: 1645174853-354909 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: Hi Arnd, On Wed, Feb 16, 2022 at 2:17 PM Arnd Bergmann wrote: > From: Arnd Bergmann > > While most m68k platforms use separate address spaces for user > and kernel space, at least coldfire does not, and the other > ones have a TASK_SIZE that is less than the entire 4GB address > range. > > Using the default implementation of __access_ok() stops coldfire > user space from trivially accessing kernel memory. > > Signed-off-by: Arnd Bergmann Thanks for your patch! > --- a/arch/m68k/include/asm/uaccess.h > +++ b/arch/m68k/include/asm/uaccess.h > @@ -12,14 +12,21 @@ > #include > > /* We let the MMU do all checking */ > -static inline int access_ok(const void __user *addr, > +static inline int access_ok(const void __user *ptr, > unsigned long size) > { > + unsigned long limit = TASK_SIZE; > + unsigned long addr = (unsigned long)ptr; > + > /* > * XXX: for !CONFIG_CPU_HAS_ADDRESS_SPACES this really needs to check > * for TASK_SIZE! > + * Removing this helper is probably sufficient. > */ Shouldn't the above comment block be removed completely, as this is now implemented below? > - return 1; > + if (IS_ENABLED(CONFIG_CPU_HAS_ADDRESS_SPACES)) > + return 1; > + > + return (size <= limit) && (addr <= (limit - size)); > } Any pesky compilers that warn (or worse with -Werror) about "condition always true" for TASK_SIZE = 0xFFFFFFFFUL? 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