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 1826EC433EF for ; Fri, 18 Feb 2022 09:01:30 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K0Qfc0GW3z3ckg for ; Fri, 18 Feb 2022 20:01:28 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=209.85.217.48; helo=mail-vs1-f48.google.com; envelope-from=geert.uytterhoeven@gmail.com; receiver=) Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) (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 4K0Qf80Q15z3cJm for ; Fri, 18 Feb 2022 20:01:03 +1100 (AEDT) Received: by mail-vs1-f48.google.com with SMTP id e5so9160601vsg.12 for ; Fri, 18 Feb 2022 01:01:04 -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=bzbd/xkhU7FiXbsSFsFwBX/G5ifcKQZ+17z1JRrsG3g80fzXEzMwq+ilfdUyAMLCPC BOYKNiAsKlAU0bJNFXw4Xixkq00gaKcYauNEx7IUJwSH2JDvhx0xfx+VLLOPvj8NsQd0 jRcG6L4ike37BFWMigBU/XiDzLZWasmzIXPnHDKcZAmRPn/AfXXEK68fqMdCq/Hm69Tp IWaDf2UP1ITZYLS6V7fyAs6jWcj779JuhzKWo8yLcmU/eYKYq5Kqvhi6cGHMoGYrz0wd XnbUE8j5/hqGMkpQHFI9G8QrCK7rQ3P7oTA52hyPU7QNNwzsVfbXFgAUPz25M5RKzBxo ASmA== X-Gm-Message-State: AOAM532wf2GIFcQF+xuH+crFJInBx7Nc6O2fnGbYJMhMpFyBHJj4bbHM hCrO8ao0ZFaNAWItMCDHuQlL7lqmaF+3nw== X-Google-Smtp-Source: ABdhPJwaL7EFbRoBWDxHoDeFa4i6SmB+xwDPG3JF4tuZBdmz2U0HtZCdcaE/L+mhDjzK2qh4porxaw== X-Received: by 2002:a67:d582:0:b0:31c:e6c:6f81 with SMTP id m2-20020a67d582000000b0031c0e6c6f81mr256793vsj.0.1645174861361; Fri, 18 Feb 2022 01:01:01 -0800 (PST) Received: from mail-vs1-f50.google.com (mail-vs1-f50.google.com. [209.85.217.50]) by smtp.gmail.com with ESMTPSA id w15sm4604013uam.13.2022.02.18.01.01.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Feb 2022 01:01:01 -0800 (PST) Received: by mail-vs1-f50.google.com with SMTP id e26so9218161vso.3 for ; Fri, 18 Feb 2022 01:01:01 -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 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" 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