Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4036144pxb; Mon, 21 Feb 2022 10:36:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5wTcTVi6iIgoP0xUr/0q+7TqlM4yAfdr62liAtdpnNJPU0QuAGgawqsr6LD+Ut4xy8for X-Received: by 2002:aa7:cfda:0:b0:410:aaaa:320 with SMTP id r26-20020aa7cfda000000b00410aaaa0320mr22831583edy.360.1645468597597; Mon, 21 Feb 2022 10:36:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645468597; cv=none; d=google.com; s=arc-20160816; b=gjE98XMvSlNpToP5mZPmdhxLvFPOSShNZzYe5CnK9QyqQGHx8qykx9n1WvqlxKnfLL ec5gcycA1S1es3F9XxNKi3nS0T/RdwWv3wxtDPqQ/FWu2gBAJM4liuRhL9iL1Dr4Cc0q 7NHBu1EyLmrgZZNaPa24RgsjACrJOXIn4ZVkk/DnKChALtTJ66eyUCeBJ+/de1cdw7Ob V74p/KhcoiqpQauUFg4FKUwGTcldnEMmRf5jB55WUaArI4stGZxCuJqc5RFOlzN4b2er p5H7sx/sbMgyihwUK3oWCUMw6+AoVyaRfy4e6KqS3i1+InrB/8roaOSyz+L0VSlrBDRb 2oOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=uxGeqtSl4rAMdQk6vmplDzIYaBYax7G2K+5B5OvSPOI=; b=PRenhk+ev6DJQ69DmKUO+zY4Aqac+bdXr+EvuTOyekzGmue7zkOqIwr8LurSbCj/+R 7YqbLPQGpvsNXDuMbNQ1UCZgqFAKihCJgJ/ARcOFIJMKQSJrCPjB38WWQKfQHjzMPPRl lpwLIAF7+//oQSFIzSotfBwqVlSKYAcs316obcAWSn0g63k2jO6QIlMJZZugMCHKxjfq 2s0D3XN0Fh1aZadPvqQvkAnSlClo+1b95aBQ8YK4JtNtJPJBCeCsGBbqsLmCKjvBYhAK jvPkYGVtKBTxkh3bCYCBwLwO2NJcxfq4gf3HB7rj/k9wqu9ilkMJpjdgmp39WNpjj4c3 5v+g== 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 f14si8332387edf.249.2022.02.21.10.36.14; Mon, 21 Feb 2022 10:36:37 -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 S1379028AbiBUPXe (ORCPT + 99 others); Mon, 21 Feb 2022 10:23:34 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379020AbiBUPXa (ORCPT ); Mon, 21 Feb 2022 10:23:30 -0500 Received: from elvis.franken.de (elvis.franken.de [193.175.24.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 49D6C1DA7C; Mon, 21 Feb 2022 07:23:07 -0800 (PST) Received: from uucp (helo=alpha) by elvis.franken.de with local-bsmtp (Exim 3.36 #1) id 1nMAWk-00025w-00; Mon, 21 Feb 2022 16:23:02 +0100 Received: by alpha.franken.de (Postfix, from userid 1000) id 22D4EC25F8; Mon, 21 Feb 2022 16:21:30 +0100 (CET) Date: Mon, 21 Feb 2022 16:21:30 +0100 From: Thomas Bogendoerfer To: Arnd Bergmann Cc: Linus Torvalds , Christoph Hellwig , linux-arch , Linux-MM , Linux API , Arnd Bergmann , Linux Kernel Mailing List , Al Viro , Russell King - ARM Linux , Will Deacon , Guo Ren , Brian Cain , Geert Uytterhoeven , Michal Simek , 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)" Subject: Re: [PATCH v2 09/18] mips: use simpler access_ok() Message-ID: <20220221152130.GA17373@alpha.franken.de> References: <20220216131332.1489939-1-arnd@kernel.org> <20220216131332.1489939-10-arnd@kernel.org> <20220221132456.GA7139@alpha.franken.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_NONE,T_SCC_BODY_TEXT_LINE,T_SPF_HELO_PERMERROR 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 Mon, Feb 21, 2022 at 03:31:23PM +0100, Arnd Bergmann wrote: > On Mon, Feb 21, 2022 at 2:24 PM Thomas Bogendoerfer > wrote: > > On Wed, Feb 16, 2022 at 02:13:23PM +0100, Arnd Bergmann wrote: > > > > > > diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h > > > index db9a8e002b62..d7c89dc3426c 100644 > > > > this doesn't work. For every access above maximum implemented virtual address > > space of the CPU an address error will be issued, but not a TLB miss. > > And address error isn't able to handle this situation. > > Ah, so the __ex_table entry only catches TLB misses? no, but there is no __ex_table handling in address error hanlder (yet). > Does this mean it also traps for kernel memory accesses, or do those > work again? it will trap for every access. > If the addresses on mips64 are separate like on > sparc64 or s390, the entire access_ok() step could be replaced > by a fixup code in the exception handler. I suppose this depends on > CONFIG_EVA and you still need a limit check at least when EVA is > disabled. only EVA has seperate address spaces for kernel/user. > > Is there a reason to not also #define TASK_SIZE_MAX __UA_LIMIT like > > for the 32bit case ? > > > > For 32-bit, the __UA_LIMIT is a compile-time constant, so the check > ends up being trivial. On all other architectures, the same thing can > be done after the set_fs removal, so I was hoping it would work here > as well. ic > I suspect doing the generic (size <= limit) && (addr <= (limit - size)) > check on mips64 with the runtime limit ends up slightly slower > than the current code that checks a bit mask instead. If you like, > I'll update it this way, otherwise I'd need help in form of a patch > that changes the exception handling so __get_user/__put_user > also return -EFAULT for an address error. that's what the patch does. For aligned accesses the patch should do the right thing, but it breaks unaligned get_user/put_user. Checking if the trapping vaddr is between end of CPU VM space and TASK_MAX_SIZE before exception handling should do the trick. I'll send a patch, if this works. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]