Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25226001rwd; Sun, 2 Jul 2023 12:57:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlHGw8BPLKlED+hLzoyHPnzEwftKhJ/CZxqKAhv/4fLhGgugZdiwzzmV7Sjqib96lP9X+27h X-Received: by 2002:a05:6a20:8f19:b0:12e:7fc9:5c44 with SMTP id b25-20020a056a208f1900b0012e7fc95c44mr2159771pzk.14.1688327824133; Sun, 02 Jul 2023 12:57:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688327824; cv=none; d=google.com; s=arc-20160816; b=hBOL0vrie0dUN1mCzLPShwMXJgQ9tdr6sFB8yR5xkdoZwFFeEsDUEtX7Jb3Q8OdNrm U4LwNW03WOosWOGTcoIW8Jo9RjJ8yLwrhh4d/2Jw8CHcRpxyeG2xqVMSmV+qAiz/YArN 8aD0SsRTpjM7zbMDL5zBObsq/RtE4sLHXWZp8Txtm5KfwPSzhhIymL3PEJkIeEtdZznj ReL7V5Xk3m0rbNjEL5iStzhVSaKksAEnIGSNI9o3GTpjyvB2U3r7lxV0jEe7F204Eb29 BNujo8Ine1SfZnXE998mCbexhXbd9Y0ZSXROY4i4ZCAAeXkL3vnqLIQlBrjE1/3Um1wn 3xLA== 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=GwGeePzpDE5nZ+InS0CUv9+DYTo+EL82bME3T5m0stc=; fh=xTirQDE91jmNtr980oKEIQRfH7S+aeoNp7gkS0wwTB0=; b=Fb45GAZGfKi36ZeqjCxvM6edquCfGOS87cxgEL5hVMrFKMmptU2ywTf2tRrN0gpgCf F+PKM+GsNM+BZJyayke8LSSXwXzJR2+d4iJSLL3VMudUJwS/syJE26fITKpEh+6HXHek jC9BbTm61MQsKIHqlDhss8Hr77bJM+sXYUfN+OMagJimzUaL4k15lTJryeLZKPhcMUuE ff655cdbFb9vHlHIrfhxGcUEJQOA7hREmL9Q5o8zDgcK5OqS7ZLqr8KfqrEGbPLtb3gW 1eIYs2YIKUL2YbJtZHVdMXPgVouS0KxdaMn8BBmLe/80+PxeNQqrdL0cmuTZbhzs1QIP T10A== 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 z11-20020aa7888b000000b0068281dbbd13si2820594pfe.76.2023.07.02.12.56.52; Sun, 02 Jul 2023 12:57:04 -0700 (PDT) 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 S230155AbjGBTdX (ORCPT + 99 others); Sun, 2 Jul 2023 15:33:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjGBTdV (ORCPT ); Sun, 2 Jul 2023 15:33:21 -0400 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2F3D8A6; Sun, 2 Jul 2023 12:33:19 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 362JX6cW017544; Sun, 2 Jul 2023 21:33:06 +0200 Date: Sun, 2 Jul 2023 21:33:06 +0200 From: Willy Tarreau To: Zhangjin Wu Cc: thomas@t-8ch.de, arnd@arndb.de, david.laight@aculab.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, Thomas =?iso-8859-1?Q?Wei=DFschuh?= Subject: Re: [PATCH v5 14/14] selftests/nolibc: add mmap and munmap test cases Message-ID: <20230702193306.GK16233@1wt.eu> References: <90179484b62c0bafb0fad9b03680136bd6fedee3.1687957589.git.falcon@tinylab.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <90179484b62c0bafb0fad9b03680136bd6fedee3.1687957589.git.falcon@tinylab.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi Zhangjin, On Wed, Jun 28, 2023 at 09:51:57PM +0800, Zhangjin Wu wrote: > Three mmap/munmap related test cases are added: > > - mmap_bad: the length argument must be greater than 0, otherwise, fail > with -EINVAL. > > - munmap_bad: invalid (void *)-1 address fail with -EINVAL. > > - mmap_munmap_good: mmap() a file with good offset and then munmap(). > > Note, it is not easy to find a unique file for mmap() in different > scenes, so, a file list is used to search the right one: > > - /proc/1/exe, for 'run' and 'run-user' target > 'run-user' can not find '/proc/self/exe' > > - /proc/self/exe, for 'libc-test' target > normal program 'libc-test' has no permission to access '/proc/1/exe' Strictly speaking, if your executable is not readable (e.g. chmod 111 due to a restrictive umask) it will also fail that one. > - the others, for kernel without procfs > let it pass even with 'worst case' kernel configs You should include /dev/zero, which is commonly used to allocate anonymous memory and is more likely present and readable than any of the other files. And another file of choice is obviously argv[0] ;-) In this case you don't need any of the other extra ones. Thus I could suggest that you try in this order: /dev/zero, /proc/self/exe, /proc/1/exe, argv[0] and be done with it. That doesn't prevent one from extending the list if really needed later, but I doubt it would be needed. Also, it's already arranged in a read-write, then read-only fallbacks mode, so if we later need to add more complex tests involving writes, the writable /dev/zero will have precedence. Willy