Message ID | fdc400ae881aa3819978d43cea7004df7b276551.1688739493.git.falcon@tinylab.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3348666vqx; Fri, 7 Jul 2023 08:27:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlG868Jv2RjOYNHAXP7hSugtjZfUX18QiwPmu8360rVDRqEOCuBGt3Y+kJb2PZ6Cjiy4+VeH X-Received: by 2002:a50:ee07:0:b0:51a:2d2c:75ee with SMTP id g7-20020a50ee07000000b0051a2d2c75eemr4355767eds.25.1688743637757; Fri, 07 Jul 2023 08:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688743637; cv=none; d=google.com; s=arc-20160816; b=HDUWtQUkNQc5w6h/QyRtIk1pE8stKAbBOKth8jLB7EiCMijnKFvNjnGxl6MAV6e6rK jNmaRpPXxKrB9K3BsNbolZ6PEtXfLtbMBUU/KORn6yxaNQgjKFbS4jDlggI1WUwzzXvy JTG/CV0jnYJ62GAtsEBktpjyOhmp1O36z+oKUpaCef+LZ3jZgV+DrjUgoSxThu7IVq3W onYpGLxbDEOxE64BBaY75Cdog1cU58LxOTf1UgIVDhHg9QIV3PyS0gdgL+WWlFeAgW+X GP5av1gOTS8SUyp3dU+mGWpTnZnnRSBIEV12sCmH5MVXoD4Lj54uVkGB3Yn6ZBk3nkiG QuNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=mUzr5R1l8tm97oCiQDkkXXCSSes5UCkpp25rwYx3nTQ=; fh=pYBoK8NKvGZirLsyIjvjlYHPy/fM5+u4iD3mF5vegBA=; b=MmbJ31DNYWNP4cToDF9PzWte/GMJyV8/XSxkL0Kz4E+H11goNMy6bZ6/j2xB2S13V8 svZM4iZMZmbv2m8GKle1fxPgZM3X4x+V52AUSh+nvfgcTzfqVBTBk26KEzKQKP9aK9+R WfQwZyn+1dBjODCa/faD59DMO3jkVMD6l7Nm+hYWtWvshTrHXoxtZJUTrgGK5ECiLUsS yQl4TEceiLNKhai9nqCAJ3SpxWK7AJkGZWXyzft6eSvMmZMD5YLCF1crwhiCDlHXpa6c mEZs3hpIq0fwmIb9jGEGu6OwX5cVnZRX9hbKCw1NWnEwdJeNUwOBL9ishWquEkyCB4Tz kJpA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l23-20020aa7d957000000b0051e367e4653si1586703eds.282.2023.07.07.08.26.51; Fri, 07 Jul 2023 08:27:17 -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 S232467AbjGGPG2 (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Fri, 7 Jul 2023 11:06:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232151AbjGGPG0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 7 Jul 2023 11:06:26 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07F8BAA; Fri, 7 Jul 2023 08:06:24 -0700 (PDT) X-QQ-mid: bizesmtp72t1688742370t5qefwef Received: from linux-lab-host.localdomain ( [116.30.131.119]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 07 Jul 2023 23:06:09 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: 3M0okmaRx3hzmnpwX7/mep5Hi+aL1BsPnbLb2Ne734KOZ+87748VonTMKdRIp EFDKQ10JOaI9H1K/u2Yfwm8Ia6Dla25b2yBF2VOfTaGbJ/qyULz0sUU/SWH5h85TZzJwQ+a ztzbh/G5rkZFJYZ4liyhe7BpLWnr+cG4Cso4RfBaWwkjZAKRX31UJCpxkIJvbOU/LUOgxD5 Qgl3up7OJ42WsGe4o8iGLxOPxd9rbypRPLBrFdawoixcB5WOgHOgR4cSe7KnQuCPj8OcVdY +ZeJXUx7dr7R+2CsEhy7RZm+kHa23A8+dd3hyEJ1r0fouvYK1X4bs88rqWmwsePtF9ARtvj XfrFvCXbpGEVTpwnrQq6gBVuH6ZDkORFuY53Ge7nNia4nbM0CqdRjoa1eF15Q== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 12075169014602729724 From: Zhangjin Wu <falcon@tinylab.org> To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, david.laight@aculab.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v6 13/15] selftests/nolibc: add mmap_bad test case Date: Fri, 7 Jul 2023 23:05:49 +0800 Message-Id: <fdc400ae881aa3819978d43cea7004df7b276551.1688739493.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <cover.1688739492.git.falcon@tinylab.org> References: <cover.1688739492.git.falcon@tinylab.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770776048721277295?= X-GMAIL-MSGID: =?utf-8?q?1770776048721277295?= |
Series |
tools/nolibc: add a new syscall helper
|
|
Commit Message
Zhangjin Wu
July 7, 2023, 3:05 p.m. UTC
The length argument of mmap() must be greater than 0, passing a zero
length argument expects failure with -EINVAL.
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
tools/testing/selftests/nolibc/nolibc-test.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Fri, Jul 07, 2023 at 11:05:49PM +0800, Zhangjin Wu wrote: > The length argument of mmap() must be greater than 0, passing a zero > length argument expects failure with -EINVAL. This one doesn't work for me on x86_64 kernel 5.15.112, qemu userland: 46 mmap_bad = <0x0> EEXIST != (<0xffffffffffffffff> EINVAL) [FAIL] This EEXIST actually is the errno from the previous test. If I run the test natively it's OK: $ ./nolibc-test syscall:46 Running test 'syscall' 46 mmap_bad = <0xffffffffffffffff> EINVAL [OK] Errors during this test: 0 I'll queue it anyway for now but it would be nice that we figure what's happening (even if we need to adjust or drop the test if it's a false positive) so that we don't get used to "ah this is a normal error". Willy
Hi, Willy > On Fri, Jul 07, 2023 at 11:05:49PM +0800, Zhangjin Wu wrote: > > The length argument of mmap() must be greater than 0, passing a zero > > length argument expects failure with -EINVAL. > > This one doesn't work for me on x86_64 kernel 5.15.112, qemu userland: > > 46 mmap_bad = <0x0> EEXIST != (<0xffffffffffffffff> EINVAL) [FAIL] > Just rerun 'run-user' on x86_64 with kernel 5.11.0-41-generic, it is ok. The failure is very interesting, and also rechecked the kernel mmap code: unsigned long do_mmap(struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long pgoff, unsigned long *populate, struct list_head *uf) { ... if (!len) return -EINVAL; ... } $ git blame -L 1202,1202 mm/mmap.c e37609bb36f70 (Piotr Kwapulinski 2015-06-24 16:58:39 -0700 1202) if (!len) $ git show e37609bb36f706c954e82e580e2e790e9d5caef8:Makefile VERSION = 4 PATCHLEVEL = 1 SUBLEVEL = 0 EXTRAVERSION = So, the kernel side should be ok from v4.1? For qemu-user, I have rechecked the following version: $ qemu-x86_64 --version qemu-x86_64 version 4.2.1 (Debian 1:4.2-3ubuntu6.18) $ qemu-x86_64 --version qemu-x86_64 version 7.0.0 (Debian 1:7.0+dfsg-7ubuntu2.6~backport20.04.202306190332~ubuntu20.04.1) $ build/x86_64/pc/qemu/v8.0.2/qemu-x86_64 --version qemu-x86_64 version 8.0.2 (v8.0.2-dirty) all of them work well, as a comparison, what's your qemu-user version? > This EEXIST actually is the errno from the previous test. If I run > the test natively it's OK: > > $ ./nolibc-test syscall:46 > Running test 'syscall' > 46 mmap_bad = <0xffffffffffffffff> EINVAL [OK] > Errors during this test: 0 > > I'll queue it anyway for now but it would be nice that we figure what's > happening (even if we need to adjust or drop the test if it's a false > positive) so that we don't get used to "ah this is a normal error". > Yes, if there is a failure, we should figure out why. It is ok for me to remove this one or let's find another errno condition before we find the root cause of the reported failure. Thanks, Zhangjin > Willy
Hi Zhangjin, On Mon, Jul 10, 2023 at 02:33:22AM +0800, Zhangjin Wu wrote: > For qemu-user, I have rechecked the following version: > > $ qemu-x86_64 --version > qemu-x86_64 version 4.2.1 (Debian 1:4.2-3ubuntu6.18) > > $ qemu-x86_64 --version > qemu-x86_64 version 7.0.0 (Debian 1:7.0+dfsg-7ubuntu2.6~backport20.04.202306190332~ubuntu20.04.1) > > $ build/x86_64/pc/qemu/v8.0.2/qemu-x86_64 --version > qemu-x86_64 version 8.0.2 (v8.0.2-dirty) > > all of them work well, as a comparison, what's your qemu-user version? Spot on! I ran it remotely and had a different qemu in my default path: $ qemu-x86_64 --version qemu-x86_64 version 2.7.0, Copyright (c) 2003-2016 Fabrice Bellard and the QEMU Project developers I didn't notice but it yells at me during the test: qemu: Unsupported syscall: 332 Locally with this version it's much cleaner: $ qemu-x86_64 --version qemu-x86_64 version 6.2.0 Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers $ make run-user | grep status: 143 test(s): 141 passed, 2 skipped, 0 failed => status: warning So we can keep it and blame my environment for that failure. Thanks for checking, Willy
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index fde1b3c51a4a..4026772ed4c5 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -669,6 +669,7 @@ int run_syscall(int min, int max) CASE_TEST(lseek_m1); EXPECT_SYSER(1, lseek(-1, 0, SEEK_SET), -1, EBADF); break; CASE_TEST(lseek_0); EXPECT_SYSER(1, lseek(0, 0, SEEK_SET), -1, ESPIPE); break; CASE_TEST(mkdir_root); EXPECT_SYSER(1, mkdir("/", 0755), -1, EEXIST); break; + CASE_TEST(mmap_bad); EXPECT_PTRER(1, mmap(NULL, 0, PROT_READ, MAP_PRIVATE, 0, 0), MAP_FAILED, EINVAL); break; CASE_TEST(open_tty); EXPECT_SYSNE(1, tmp = open("/dev/null", 0), -1); if (tmp != -1) close(tmp); break; CASE_TEST(open_blah); EXPECT_SYSER(1, tmp = open("/proc/self/blah", 0), -1, ENOENT); if (tmp != -1) close(tmp); break; CASE_TEST(poll_null); EXPECT_SYSZR(1, poll(NULL, 0, 0)); break;