From patchwork Fri Jun 15 17:22:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Stancek X-Patchwork-Id: 930135 X-Patchwork-Delegate: petr.vorel@gmail.com 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=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 416nPB3G3zz9ry1 for ; Sat, 16 Jun 2018 03:22:34 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C6C1B3E7C35 for ; Fri, 15 Jun 2018 19:22:30 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 1CBAE3E7AA5 for ; Fri, 15 Jun 2018 19:22:28 +0200 (CEST) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 731AB601F80 for ; Fri, 15 Jun 2018 19:22:26 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1ABD740122A1; Fri, 15 Jun 2018 17:22:25 +0000 (UTC) Received: from dustball.brq.redhat.com (unknown [10.43.17.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id C96D72026609; Fri, 15 Jun 2018 17:22:23 +0000 (UTC) From: Jan Stancek To: ltp@lists.linux.it, naresh.kamboju@linaro.org, smuckle@google.com, rafael.tinoco@linaro.org, xzhou@redhat.com, chrubis@suse.cz Date: Fri, 15 Jun 2018 19:22:18 +0200 Message-Id: <8b5ddc69aae83b332b205dbeddb3284ab00f827e.1529082112.git.jstancek@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 17:22:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 17:22:25 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jstancek@redhat.com' RCPT:'' X-Virus-Scanned: clamav-milter 0.99.2 at in-2.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-2.smtp.seeweb.it Subject: [LTP] [PATCH] fcntl36: fix 32-bit sporadic failures 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: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" fcntl36 testcase has been observed to sporadically fail, when running 32-bit user-space on 64-bit kernel. Strace shows that region length is 0 for some commands: fcntl64(6, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=5120, l_len=0} This is because testcase is passing struct flock64, but command is F_SETLK, not F_SETLK64. So, kernel treats argument for POSIX command as 32-bit "struct flock": static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, ... case F_SETLK: case F_SETLKW: err = get_compat_flock(&flock, compat_ptr(arg)); ... in contrast to F_OFD_* commands, where argument is treated as "struct flock64": case F_SETLK64: case F_SETLKW64: case F_OFD_SETLK: case F_OFD_SETLKW: err = get_compat_flock64(&flock, compat_ptr(arg)); ... Switch argument of POSIX commands to 'struct flock' and leave it to glibc to pick correct syscall and command. I tested fcntl36 and fcntl36_64 on x86_64 kernel (as 64bit + 32bit binary) and i386 kernel by running 100 iterations. Signed-off-by: Jan Stancek Tested-by: Naresh Kamboju --- No kernel bug, problem was found in my reproducer. Can anyone confirm this fixes 32-bit arm too? testcases/kernel/syscalls/fcntl/fcntl36.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/syscalls/fcntl/fcntl36.c b/testcases/kernel/syscalls/fcntl/fcntl36.c index 3246d13892cd..81bd5a647e4c 100644 --- a/testcases/kernel/syscalls/fcntl/fcntl36.c +++ b/testcases/kernel/syscalls/fcntl/fcntl36.c @@ -127,7 +127,7 @@ static void *fn_posix_w(void *arg) int fd = SAFE_OPEN(fname, O_RDWR); long wt = pa->cnt; - struct flock64 lck = { + struct flock lck = { .l_whence = SEEK_SET, .l_start = pa->offset, .l_len = pa->length, @@ -227,7 +227,7 @@ static void *fn_posix_r(void *arg) int i; int fd = SAFE_OPEN(fname, O_RDWR); - struct flock64 lck = { + struct flock lck = { .l_whence = SEEK_SET, .l_start = pa->offset, .l_len = pa->length,