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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72F21C433EF for ; Fri, 18 Feb 2022 09:00:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232977AbiBRJBL (ORCPT ); Fri, 18 Feb 2022 04:01:11 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232897AbiBRJBJ (ORCPT ); Fri, 18 Feb 2022 04:01:09 -0500 Received: from mail-vs1-f54.google.com (mail-vs1-f54.google.com [209.85.217.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7711D1867C4; Fri, 18 Feb 2022 01:00:52 -0800 (PST) Received: by mail-vs1-f54.google.com with SMTP id q9so3731377vsg.2; Fri, 18 Feb 2022 01:00:52 -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=Zv5we/RxYb0vPcwmthg0UKS7t8MJAYVmVgrUzX//i6/+r/z75j0fq9KuaSGpBRCpRD pZQVMpJrgHDjmG/pE8NlMIvxraQAFXZnmK35GZwk3dCq7hULFowna8Yz/6wIN1vtjrWg lj0Oyn2RsxPnATMlbZt062i4aueZdDsQ8CYOVZfIggEJ5EAMCANlwVUlMHA196K4g6b+ kT0ndFGmgRy0zi8Tbd/Tqb7JAUhQDMdAROWAJIF1NzUZ27qX4OlzI5x0LiEXRgN4YiWd sKJI0XDR/2shnBfhqNzA1yJeMbZQTBjUrPoMcf/6mCGwNr017Gv2BTYqMMgB8+rLJ4jD YlzQ== X-Gm-Message-State: AOAM532ndTqZyoRzKkrB94qVdAYO9LGhrj6jjuLVe0C2uEIPb4o6vVLZ Dfoh87O71pgFgZS3iuGX6YHyHo0+q8dGPA== X-Google-Smtp-Source: ABdhPJxp40nmkJXiu8iNeCwx9n2AED0TZQVM/tj+B9o99AsQIveQ6vybTcySkFQDWjbvuLfgWeR4eA== X-Received: by 2002:a67:d50a:0:b0:31b:9be2:8aa0 with SMTP id l10-20020a67d50a000000b0031b9be28aa0mr2906226vsj.76.1645174851807; Fri, 18 Feb 2022 01:00:51 -0800 (PST) Received: from mail-vs1-f53.google.com (mail-vs1-f53.google.com. [209.85.217.53]) by smtp.gmail.com with ESMTPSA id n77sm7184646vkn.29.2022.02.18.01.00.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Feb 2022 01:00:50 -0800 (PST) Received: by mail-vs1-f53.google.com with SMTP id u10so9161585vsu.13; 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" Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org 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 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 2C3C6C433F5 for ; Fri, 18 Feb 2022 09:01:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mhW/DC9gKYAhyodeXyMVhyJp2WWSYSYavk6Q3mbA1NM=; b=hbuTULKwuvBfov 8mivEJROOc67QCtygJtf2DAqHIQcQlwZ3RcMX1YDRvqfVy8cwArnGL7QIKAk/dC/DCJuH3LmAzZlC au81JK2UAc/j85MXSb3PQAzHg+ElMaENABwTRQw5mfOPGBEsy4qRnOa0lZs4JOctmpZ27oCVh6yHO ajTOdgPZlxMXXm2cJHpKTJy1lASTzcU/Xpy9YE8Dx+Git9oWgjq5Ve3tiEERzLpMZi5W2yifvclDm 3GnoKbA2AEudVNGEp3geeLRrLXG6XR/WyUR3/queSeIYdjs9mZOiDLOzqCOu6DgGsbup17Z3Qh0T/ DQMzODt9/DHkJVJZeJpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKz8W-00DOC8-Tr; Fri, 18 Feb 2022 09:01:08 +0000 Received: from mail-pg1-f175.google.com ([209.85.215.175]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKz8R-00DOA1-73; Fri, 18 Feb 2022 09:01:06 +0000 Received: by mail-pg1-f175.google.com with SMTP id f8so7282201pgc.8; Fri, 18 Feb 2022 01:01:02 -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=iHCNwCmh5CPdsAOyLx48UqBhJQ8la549mbnQ2nAHwWtBQW3J0siEsMl14e0NW3Gy9c 7ALZupE6t64vujM8z2Zsr+GS38aA+xWg/7rZIPkZKCXOfPJBVYpRxUTrXLewZh/DEers iz/vTeQXYHbrPJcLuyPFgEW+vb6MJVVHWdlZ41wz/PQFpfNZEthzM8EnGWwRnz3l8l/m 4HdirOeegVWTTNoBTRNVc6a5x36XmHnSb95LdOca94xYyc0qWEKGWHKc1JUcQaUBtYqE y6UoBe5+EhGzGFpUpvIN11JrYkxpzZ2lOeySE88+yl2lbZQZIHhH9DG1Hz1n+EPFN74D F+vg== X-Gm-Message-State: AOAM530ox//N6Tgsn1aTt6TxGjMuH3zEK+MJNvQ3A5w/Yv71syYTDU2e c6Y+R85iVMJBBpdKHBjCZim5tBziinqixA== X-Google-Smtp-Source: ABdhPJyO2jxzlIGTA0hqztucWDeXloLdH9RUuFhaS9bjmWlwoU4rQzGRGAMdIm0TEfMuRbN65wEVrw== X-Received: by 2002:a63:4041:0:b0:372:c918:631a with SMTP id n62-20020a634041000000b00372c918631amr5612089pga.370.1645174861629; Fri, 18 Feb 2022 01:01:01 -0800 (PST) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com. [209.85.216.50]) by smtp.gmail.com with ESMTPSA id n13sm4064126pjq.13.2022.02.18.01.01.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Feb 2022 01:01:01 -0800 (PST) Received: by mail-pj1-f50.google.com with SMTP id m7so8055828pjk.0; 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 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)" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220218_010105_535493_9BBB163C X-CRM114-Status: GOOD ( 28.66 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv 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 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 76195C433EF for ; Fri, 18 Feb 2022 09:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OZcS/VLEzE7g6A5xLCr7EJAjf+I3w1iIImZigT5y07I=; b=s15fwkl6RvZnqV 3HSNgHhkro2eeMg2mZVzWf+6ea0hqWtb1If6p6+FinYbd9WuMGzfs3AZk+/fx2WTTPha0m5zX5t8w /yxFzH8Re6IAkopn5GLqU9AKehX57dZ/+8cq1nTomFH6Mp90hX1tjOf2eKkh/xbnsvUVNhbx0WsLe 8FzYw55PEm5Ml2YJ393hhUHUDnCBIJkR6NSVbeCiDtS4TnbOfzhWGj5qWotb5mHXtwPLVYndZeCnK TBfaztcYW5cvBAsqQC5seUI6jHi3E0l5NprBZp+GdtfBZcdexFy4uopJbgMAEfEYiFwpF3vtR2jTF YBRbXLW3gh+KOkjQqUBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKz8W-00DOBz-Ik; Fri, 18 Feb 2022 09:01:08 +0000 Received: from mail-pg1-f175.google.com ([209.85.215.175]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKz8R-00DOA1-73; Fri, 18 Feb 2022 09:01:06 +0000 Received: by mail-pg1-f175.google.com with SMTP id f8so7282201pgc.8; Fri, 18 Feb 2022 01:01:02 -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=iHCNwCmh5CPdsAOyLx48UqBhJQ8la549mbnQ2nAHwWtBQW3J0siEsMl14e0NW3Gy9c 7ALZupE6t64vujM8z2Zsr+GS38aA+xWg/7rZIPkZKCXOfPJBVYpRxUTrXLewZh/DEers iz/vTeQXYHbrPJcLuyPFgEW+vb6MJVVHWdlZ41wz/PQFpfNZEthzM8EnGWwRnz3l8l/m 4HdirOeegVWTTNoBTRNVc6a5x36XmHnSb95LdOca94xYyc0qWEKGWHKc1JUcQaUBtYqE y6UoBe5+EhGzGFpUpvIN11JrYkxpzZ2lOeySE88+yl2lbZQZIHhH9DG1Hz1n+EPFN74D F+vg== X-Gm-Message-State: AOAM530ox//N6Tgsn1aTt6TxGjMuH3zEK+MJNvQ3A5w/Yv71syYTDU2e c6Y+R85iVMJBBpdKHBjCZim5tBziinqixA== X-Google-Smtp-Source: ABdhPJyO2jxzlIGTA0hqztucWDeXloLdH9RUuFhaS9bjmWlwoU4rQzGRGAMdIm0TEfMuRbN65wEVrw== X-Received: by 2002:a63:4041:0:b0:372:c918:631a with SMTP id n62-20020a634041000000b00372c918631amr5612089pga.370.1645174861629; Fri, 18 Feb 2022 01:01:01 -0800 (PST) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com. [209.85.216.50]) by smtp.gmail.com with ESMTPSA id n13sm4064126pjq.13.2022.02.18.01.01.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Feb 2022 01:01:01 -0800 (PST) Received: by mail-pj1-f50.google.com with SMTP id m7so8055828pjk.0; 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 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)" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220218_010105_535493_9BBB163C X-CRM114-Status: GOOD ( 28.66 ) X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+linux-snps-arc=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc From mboxrd@z Thu Jan 1 00:00:00 1970 From: Geert Uytterhoeven Date: Fri, 18 Feb 2022 10:00:39 +0100 Subject: [OpenRISC] [PATCH v2 10/18] m68k: fix access_ok for coldfire In-Reply-To: <20220216131332.1489939-11-arnd@kernel.org> References: <20220216131332.1489939-1-arnd@kernel.org> <20220216131332.1489939-11-arnd@kernel.org> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: openrisc@lists.librecores.org 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 at 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Geert Uytterhoeven Date: Fri, 18 Feb 2022 09:00:39 +0000 Subject: Re: [PATCH v2 10/18] m68k: fix access_ok for coldfire Message-Id: List-Id: References: <20220216131332.1489939-1-arnd@kernel.org> <20220216131332.1489939-11-arnd@kernel.org> In-Reply-To: <20220216131332.1489939-11-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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)" 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Geert Uytterhoeven Subject: Re: [PATCH v2 10/18] m68k: fix access_ok for coldfire Date: Fri, 18 Feb 2022 10:00:39 +0100 Message-ID: References: <20220216131332.1489939-1-arnd@kernel.org> <20220216131332.1489939-11-arnd@kernel.org> Mime-Version: 1.0 Return-path: In-Reply-To: <20220216131332.1489939-11-arnd@kernel.org> List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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