From patchwork Mon Oct 23 13:56:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 1853782 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SDckj6XFMz202k for ; Tue, 24 Oct 2023 01:19:09 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D3CCE3CECB0 for ; Mon, 23 Oct 2023 16:19:07 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id EAF213CECA6 for ; Mon, 23 Oct 2023 15:57:24 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by in-7.smtp.seeweb.it (Postfix) with ESMTP id 7844F200DD1 for ; Mon, 23 Oct 2023 15:57:23 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AAC73C15; Mon, 23 Oct 2023 06:58:02 -0700 (PDT) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E5F63F64C; Mon, 23 Oct 2023 06:57:20 -0700 (PDT) From: Kevin Brodsky To: ltp@lists.linux.it Date: Mon, 23 Oct 2023 14:56:45 +0100 Message-Id: <20231023135647.2157030-2-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20231023135647.2157030-1-kevin.brodsky@arm.com> References: <20231023135647.2157030-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 1.0.1 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-7.smtp.seeweb.it X-Mailman-Approved-At: Mon, 23 Oct 2023 16:18:31 +0200 Subject: [LTP] [PATCH 1/3] syscalls/{, f}setxattr: Fix passing of value pointer X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Brodsky Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" tc[i].value is a pointer to the actual value pointer, it therefore needs to be dereferenced before passing it down to {f,}setxattr() (which is already done as expected in the TEST() line below). This brokenness went unnoticed as the initial value (garbage before this patch) is never read back - this call is only used to create the key. Signed-off-by: Kevin Brodsky --- testcases/kernel/syscalls/fsetxattr/fsetxattr01.c | 2 +- testcases/kernel/syscalls/setxattr/setxattr01.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/syscalls/fsetxattr/fsetxattr01.c b/testcases/kernel/syscalls/fsetxattr/fsetxattr01.c index d799e477f49c..b65b27bdf9ac 100644 --- a/testcases/kernel/syscalls/fsetxattr/fsetxattr01.c +++ b/testcases/kernel/syscalls/fsetxattr/fsetxattr01.c @@ -140,7 +140,7 @@ static void verify_fsetxattr(unsigned int i) { /* some tests might require existing keys for each iteration */ if (tc[i].keyneeded) { - SAFE_FSETXATTR(fd, tc[i].key, tc[i].value, tc[i].size, + SAFE_FSETXATTR(fd, tc[i].key, *tc[i].value, tc[i].size, XATTR_CREATE); } diff --git a/testcases/kernel/syscalls/setxattr/setxattr01.c b/testcases/kernel/syscalls/setxattr/setxattr01.c index 8cd2821d0c6c..31f41369a608 100644 --- a/testcases/kernel/syscalls/setxattr/setxattr01.c +++ b/testcases/kernel/syscalls/setxattr/setxattr01.c @@ -137,7 +137,7 @@ static void verify_setxattr(unsigned int i) { /* some tests might require existing keys for each iteration */ if (tc[i].keyneeded) { - SAFE_SETXATTR(FNAME, tc[i].key, tc[i].value, tc[i].size, + SAFE_SETXATTR(FNAME, tc[i].key, *tc[i].value, tc[i].size, XATTR_CREATE); } From patchwork Mon Oct 23 13:56:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 1853780 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SDckH4sBqz202k for ; Tue, 24 Oct 2023 01:18:47 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 5692C3CECEE for ; Mon, 23 Oct 2023 16:18:45 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id BFD1A3CECA6 for ; Mon, 23 Oct 2023 15:57:24 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by in-7.smtp.seeweb.it (Postfix) with ESMTP id F3201200DD9 for ; Mon, 23 Oct 2023 15:57:23 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 341A1FEC; Mon, 23 Oct 2023 06:58:03 -0700 (PDT) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B02893F64C; Mon, 23 Oct 2023 06:57:21 -0700 (PDT) From: Kevin Brodsky To: ltp@lists.linux.it Date: Mon, 23 Oct 2023 14:56:46 +0100 Message-Id: <20231023135647.2157030-3-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20231023135647.2157030-1-kevin.brodsky@arm.com> References: <20231023135647.2157030-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 1.0.1 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-7.smtp.seeweb.it X-Mailman-Approved-At: Mon, 23 Oct 2023 16:18:31 +0200 Subject: [LTP] [PATCH 2/3] syscalls/msgctl06: Pass an appropriate struct to msgsnd() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Brodsky Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" msgsnd() expects a pointer to a struct as second argument. If a pointer to a short buffer is provided instead, both the type and message read by the kernel will be garbage. This went unnoticed as the sent message is never read back in this test. Signed-off-by: Kevin Brodsky --- testcases/kernel/syscalls/ipc/msgctl/msgctl06.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c index 6f54763833ed..c1264b71e0e4 100644 --- a/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c +++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c @@ -139,12 +139,16 @@ static void verify_msgctl(unsigned int n) static void setup(void) { struct msqid_ds temp_buf; + struct buf { + long type; + char text[5]; + } msgbuf = {MSGTYPE, "abcd"}; ltpuser = SAFE_GETPWNAM("nobody"); nobody_uid = ltpuser->pw_uid; root_uid = 0; msg_id = SAFE_MSGGET(IPC_PRIVATE, IPC_CREAT | MSG_RW); - SAFE_MSGSND(msg_id, "abcd", 4, 0); + SAFE_MSGSND(msg_id, &msgbuf, sizeof(msgbuf.text), 0); TEST(msgctl(msg_id, MSG_STAT_ANY, &temp_buf)); if (TST_RET == -1) { From patchwork Mon Oct 23 13:56:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 1853783 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SDckx1hbJz202k for ; Tue, 24 Oct 2023 01:19:21 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 5C2453CECBF for ; Mon, 23 Oct 2023 16:19:18 +0200 (CEST) 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 [217.194.8.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 742B13CECA6 for ; Mon, 23 Oct 2023 15:57:25 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by in-6.smtp.seeweb.it (Postfix) with ESMTP id 7FB921400077 for ; Mon, 23 Oct 2023 15:57:24 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D5F4C1042; Mon, 23 Oct 2023 06:58:03 -0700 (PDT) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5E36F3F64C; Mon, 23 Oct 2023 06:57:22 -0700 (PDT) From: Kevin Brodsky To: ltp@lists.linux.it Date: Mon, 23 Oct 2023 14:56:47 +0100 Message-Id: <20231023135647.2157030-4-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20231023135647.2157030-1-kevin.brodsky@arm.com> References: <20231023135647.2157030-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 1.0.1 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-6.smtp.seeweb.it X-Mailman-Approved-At: Mon, 23 Oct 2023 16:18:31 +0200 Subject: [LTP] [PATCH 3/3] Provide a PATH_MAX-long buffer when expecting ENAMETOOLONG X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Brodsky Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" A number of tests check that syscalls manipulating paths return -ENAMETOOLONG when the specified path is longer than allowed. There are actually two ways this error can be triggered: 1. If the given string is longer than PATH_MAX, i.e. 4096 as far as the kernel is concerned, then the getname() helper will fail and the kernel will return -ENAMETOOLONG right away. 2. If the string fits in PATH_MAX, but the filesystem rejects the path name, for instance because one of its components is longer than the support file name length (e.g. 255 for ext4). At the moment, we always fail because of 2. since we set PATH_MAX to 1024 in LTP, and in fact we sometimes use NAME_MAX as buffer length instead (which is shorter). Thus what actually happens is that the kernel overreads the provided buffer and finds some zero before hitting the "real" PATH_MAX limit (4096). We should clearly avoid such overreads. Having the syscalls fail right away by hitting 1. is the safer option. To do so, we obtain the value of PATH_MAX directly from the appropriate kernel header, and ensure it is used where relevant. This affects at least the following tests: - rename10 - symlink03 Signed-off-by: Kevin Brodsky --- include/old/usctest.h | 12 ++---------- testcases/kernel/syscalls/rename/rename10.c | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/include/old/usctest.h b/include/old/usctest.h index 9b9446d70a1e..2d46c4045111 100644 --- a/include/old/usctest.h +++ b/include/old/usctest.h @@ -34,16 +34,8 @@ #ifndef __USCTEST_H__ #define __USCTEST_H__ -/* - * Ensure that PATH_MAX is defined - */ -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif -#endif +/* For PATH_MAX */ +#include /*********************************************************************** * The following globals are defined in parse_opts.c but must be diff --git a/testcases/kernel/syscalls/rename/rename10.c b/testcases/kernel/syscalls/rename/rename10.c index 444f65366576..3eab4be0f913 100644 --- a/testcases/kernel/syscalls/rename/rename10.c +++ b/testcases/kernel/syscalls/rename/rename10.c @@ -18,7 +18,7 @@ #define MNT_POINT "mntpoint" #define TEMP_FILE "tmpfile" -static char long_path[NAME_MAX + 1] = {[0 ... NAME_MAX] = 'a'}; +static char long_path[PATH_MAX + 1] = {[0 ... PATH_MAX] = 'a'}; static void setup(void) {