From patchwork Thu Feb 21 14:02:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Li X-Patchwork-Id: 1046194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444xHZ4Ncqz9s5c for ; Fri, 22 Feb 2019 01:12:10 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0A8563EA208 for ; Thu, 21 Feb 2019 15:12:08 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id DB620294AB6 for ; Thu, 21 Feb 2019 15:01:27 +0100 (CET) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 78722141CE92 for ; Thu, 21 Feb 2019 15:01:26 +0100 (CET) Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 073DF544B0B9328378A4 for ; Thu, 21 Feb 2019 22:01:22 +0800 (CST) Received: from euler.huawei.com (10.175.104.193) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Feb 2019 22:01:11 +0800 From: Wei Li To: Date: Thu, 21 Feb 2019 22:02:21 +0800 Message-ID: <20190221140221.42163-1-liwei391@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.104.193] X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it X-Mailman-Approved-At: Thu, 21 Feb 2019 15:12:06 +0100 Cc: cj.chengjian@huawei.com, huawei.libin@huawei.com, guohanjun@huawei.com Subject: [LTP] [PATCH] syscalls/fstat05.c: fix test logic error X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" On my machine running linux-4.19.23, the fstat05 test case went failed: [root@localhost ltp_20180926_src]# ./testcases/kernel/syscalls/fstat/fstat05 fstat05 1 TFAIL : fstat05.c:168: fstat() returned 0 but we wanted -1 Finally i found that, the end of head was expanded after invoking setup(), more than 4 * getpagesize(), then ptr_str is not a point outside user's accessible address space any more. Before invoking setup(): [root@localhost home]# cat /proc/10299/maps 00400000-00417000 r-xp 00000000 fc:01 63312180 /home/CI_DATA/20190213141353/testcase/kernel_test/ltp_20180926/ltp_20180926_src/testcases/kernel/syscalls/fstat/fstat05 0042f000-00430000 r--p 0001f000 fc:01 63312180 /home/CI_DATA/20190213141353/testcase/kernel_test/ltp_20180926/ltp_20180926_src/testcases/kernel/syscalls/fstat/fstat05 00430000-00431000 rw-p 00020000 fc:01 63312180 /home/CI_DATA/20190213141353/testcase/kernel_test/ltp_20180926/ltp_20180926_src/testcases/kernel/syscalls/fstat/fstat05 00431000-00434000 rw-p 00000000 00:00 0 132dc000-132fd000 rw-p 00000000 00:00 0 [heap] ffff92737000-ffff92747000 rw-p 00000000 00:00 0 ffff92747000-ffff928bd000 r-xp 00000000 fc:02 266045 /usr/lib64/libc-2.20-2014.11.so ffff928bd000-ffff928d3000 ---p 00176000 fc:02 266045 /usr/lib64/libc-2.20-2014.11.so ffff928d3000-ffff928d7000 r--p 0017c000 fc:02 266045 /usr/lib64/libc-2.20-2014.11.so ffff928d7000-ffff928d9000 rw-p 00180000 fc:02 266045 /usr/lib64/libc-2.20-2014.11.so ffff928d9000-ffff928dd000 rw-p 00000000 00:00 0 ffff928dd000-ffff928fd000 r-xp 00000000 fc:02 266038 /usr/lib64/ld-2.20-2014.11.so ffff92905000-ffff92908000 rw-p 00000000 00:00 0 ffff92909000-ffff9291a000 rw-p 00000000 00:00 0 ffff9291a000-ffff9291b000 r--p 00000000 00:00 0 [vvar] ffff9291b000-ffff9291c000 r-xp 00000000 00:00 0 [vdso] ffff9291c000-ffff9291d000 r--p 0002f000 fc:02 266038 /usr/lib64/ld-2.20-2014.11.so ffff9291d000-ffff9291e000 rw-p 00030000 fc:02 266038 /usr/lib64/ld-2.20-2014.11.so ffff9291e000-ffff9291f000 rw-p 00000000 00:00 0 fffff5998000-fffff59b9000 rw-p 00000000 00:00 0 [stack] After invoking setup(): [root@localhost home]# cat /proc/10299/maps 00400000-00417000 r-xp 00000000 fc:01 63312180 /home/CI_DATA/20190213141353/testcase/kernel_test/ltp_20180926/ltp_20180926_src/testcases/kernel/syscalls/fstat/fstat05 0042f000-00430000 r--p 0001f000 fc:01 63312180 /home/CI_DATA/20190213141353/testcase/kernel_test/ltp_20180926/ltp_20180926_src/testcases/kernel/syscalls/fstat/fstat05 00430000-00431000 rw-p 00020000 fc:01 63312180 /home/CI_DATA/20190213141353/testcase/kernel_test/ltp_20180926/ltp_20180926_src/testcases/kernel/syscalls/fstat/fstat05 00431000-00434000 rw-p 00000000 00:00 0 132dc000-1350d000 rw-p 00000000 00:00 0 [heap] ffff92705000-ffff92712000 r-xp 00000000 fc:02 266064 /usr/lib64/libnss_files-2.20-2014.11.so ffff92712000-ffff92724000 ---p 0000d000 fc:02 266064 /usr/lib64/libnss_files-2.20-2014.11.so ffff92724000-ffff92725000 r--p 0000f000 fc:02 266064 /usr/lib64/libnss_files-2.20-2014.11.so ffff92725000-ffff92726000 rw-p 00010000 fc:02 266064 /usr/lib64/libnss_files-2.20-2014.11.so ffff92737000-ffff92747000 rw-p 00000000 00:00 0 ffff92747000-ffff928bd000 r-xp 00000000 fc:02 266045 /usr/lib64/libc-2.20-2014.11.so ffff928bd000-ffff928d3000 ---p 00176000 fc:02 266045 /usr/lib64/libc-2.20-2014.11.so ffff928d3000-ffff928d7000 r--p 0017c000 fc:02 266045 /usr/lib64/libc-2.20-2014.11.so ffff928d7000-ffff928d9000 rw-p 00180000 fc:02 266045 /usr/lib64/libc-2.20-2014.11.so ffff928d9000-ffff928dd000 rw-p 00000000 00:00 0 ffff928dd000-ffff928fd000 r-xp 00000000 fc:02 266038 /usr/lib64/ld-2.20-2014.11.so ffff92905000-ffff92908000 rw-p 00000000 00:00 0 ffff92909000-ffff9291a000 rw-p 00000000 00:00 0 ffff9291a000-ffff9291b000 r--p 00000000 00:00 0 [vvar] ffff9291b000-ffff9291c000 r-xp 00000000 00:00 0 [vdso] ffff9291c000-ffff9291d000 r--p 0002f000 fc:02 266038 /usr/lib64/ld-2.20-2014.11.so ffff9291d000-ffff9291e000 rw-p 00030000 fc:02 266038 /usr/lib64/ld-2.20-2014.11.so ffff9291e000-ffff9291f000 rw-p 00000000 00:00 0 fffff5998000-fffff59b9000 rw-p 00000000 00:00 0 [stack] [root@localhost home]# Signed-off-by: Wei Li --- testcases/kernel/syscalls/fstat/fstat05.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testcases/kernel/syscalls/fstat/fstat05.c b/testcases/kernel/syscalls/fstat/fstat05.c index 8de5d070a..b10285cbe 100644 --- a/testcases/kernel/syscalls/fstat/fstat05.c +++ b/testcases/kernel/syscalls/fstat/fstat05.c @@ -135,15 +135,15 @@ int main(int ac, char **av) tst_parse_opts(ac, av, NULL, NULL); - /* Buffer points outside user's accessible address space. */ - ptr_str = &stat_buf; /* if it was for conformance testing */ - ptr_str = (void *)sbrk(0) + (4 * getpagesize()); - /* * Invoke setup function */ setup(); + /* Buffer points outside user's accessible address space. */ + ptr_str = &stat_buf; /* if it was for conformance testing */ + ptr_str = (void *)sbrk(0) + (4 * getpagesize()); + for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0;