Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1230945pxb; Fri, 18 Feb 2022 03:33:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxc3N0N/hYSfNS/BecDxVxrsN/2DjePqcmVNPJSER2mK7LpMaMzznSF6vEC4l+3JsgYtl/h X-Received: by 2002:a17:90a:b10a:b0:1bb:82a7:5d69 with SMTP id z10-20020a17090ab10a00b001bb82a75d69mr12146312pjq.111.1645183989053; Fri, 18 Feb 2022 03:33:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645183989; cv=none; d=google.com; s=arc-20160816; b=JIbaUDc5mva0YYoQOk0BeOmkOP09RGpaE8Ok1bA2nHyvbTYC0BNwJueUwhZP01E3oS 5jb/dimaTmiEMS6Qur4DXJioaAtU8+Npw0XWYwa3DnihReqm33te6WI0wcT+1V4aFQ3r tpUEq1Vl1tIqhwiQFFrB6YZoTIiqWp4vFF7sFCgDP0GbnMyXPw5UbZQfIZ/72T1X9dAS kv9C17qXqGh5g0aiSZKWeBb4X6qS6+bLwuZuMljMJydtLjA5pxoiFlPhdNBKrYS+Cld+ EO5cCi14EHpu923Xg3kQ3MPKETErUmCURpBb9cP9tDU19JUJCC4N16E8WMtp9ZqEf8Bp k52A== 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=1nYL/qjPVlkIqK+5dnbJ/5QVdVKG9AQSDTVmJuSTxwE=; b=adAJKodfFHN9dqaMwleMbr0rx5qD0X6DGPqxeDSEZUQ0pey5a29/3XVm/MWnCxcG9n mA/e8wfCq9R7jfIapHKsa7nCgkwYOe+qyG0muy3Dn1mhc6wUdaCANqqLL2VY7ho5N7VK 8Yv/d3/9UI5WeXyfgYJtVOsBwz7Oy86F0S3HQUjlGAqD0G5e2x++gbbU5P65SYsyqae4 kKk/NjDiVC3svCE/I5sGWbnWLI3XAB77lJU6+4N/6i5p5//C4Ws76xEf2dgn6Q59rXAJ AXSORtqH5BKXA9/ioD9r08uqlFmC5MIDdpi7LK/ocCxZ9Gt13XUh44IgV11eNCN5/khp hIcQ== 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 192si11635771pgc.664.2022.02.18.03.32.54; Fri, 18 Feb 2022 03:33:09 -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 S232974AbiBRJBL (ORCPT + 99 others); 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-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" 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 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