From patchwork Thu Nov 18 23:57:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 1556836 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=QZNaO+bK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwGvd1bJRz9sRR for ; Fri, 19 Nov 2021 10:58:02 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E1A943C898C for ; Fri, 19 Nov 2021 00:57:59 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id D18693C0930 for ; Fri, 19 Nov 2021 00:57:57 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 4753B1000D3D for ; Fri, 19 Nov 2021 00:57:56 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 40C031F4709C DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=collabora.com; s=mail; t=1637279876; bh=NcVyMlBPKgXYpOVhQDPfsPDkKy9i3A0eWmNha6N06ig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QZNaO+bKd35Q5w0KbNyDPh2TvukDLxZrrGWMq1S37lT71mhCeiKwONECH0u7/srdn 6RdirCmTD4VNg47Z486ATCPZlmQy45Q0TeUZy3TQG6f/s6fMUoySY+4o7amINIyN1E 1r7IcAZBGVN5NqIXr7trgObPNoN07mfhHG4FWGg5pnF1uPZkIW2IE32mTNBwQhShwj 8yC5QjY6drgVV1pUmlwfgdvmzV3uGBLyr2W+W3jrhQ3WtRq64SWZKpx/vNImAFvdA4 lK4nufJnKO5B8o159CzsvYExO9Ga9IqtX34EZKf6S6p5L87luntIc+dacYMD06OVh1 4wdFpQOLTfb+A== From: Gabriel Krisman Bertazi To: pvorel@suse.cz, jack@suse.com, amir73il@gmail.com, repnop@google.com Date: Thu, 18 Nov 2021 18:57:36 -0500 Message-Id: <20211118235744.802584-2-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211118235744.802584-1-krisman@collabora.com> References: <20211118235744.802584-1-krisman@collabora.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=DKIM_INVALID,DKIM_SIGNED, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v4 1/9] syscalls: fanotify: Add macro to require specific mark types 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: Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, kernel@collabora.com, ltp@lists.linux.it, khazhy@google.com Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Like done for init flags and event types, and a macro to require a specific mark type. Reviewed-by: Matthew Bobrowski Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- testcases/kernel/syscalls/fanotify/fanotify.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h index c91162d97a89..b9f430fe0c35 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify.h +++ b/testcases/kernel/syscalls/fanotify/fanotify.h @@ -399,4 +399,9 @@ static inline int fanotify_mark_supported_by_kernel(uint64_t flag) return rval; } +#define REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL(mark_type) do { \ + fanotify_init_flags_err_msg(#mark_type, __FILE__, __LINE__, tst_brk_, \ + fanotify_mark_supported_by_kernel(mark_type)); \ +} while (0) + #endif /* __FANOTIFY_H__ */ From patchwork Thu Nov 18 23:57:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 1556843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=Lczo/mfl; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwGw02jPVz9sVc for ; Fri, 19 Nov 2021 10:58:24 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8302E3C891E for ; Fri, 19 Nov 2021 00:58:21 +0100 (CET) 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]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 151203C899C for ; Fri, 19 Nov 2021 00:58:01 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 8E1046020DA for ; Fri, 19 Nov 2021 00:58:00 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 8EE8B1F47098 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=collabora.com; s=mail; t=1637279879; bh=rwtNSWvQX+7xmt4GpPOTiL9OPrYhl410OyKlms/69DM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lczo/mflAaBuy9MpBNjiu1SuW4YKg7VGHA/bCkH9Vys8R37xu7W3qcTj2F/iEDNdO 17v1fmFGUNlVtm5S/hsnXfG5oAFf61SrA3csMsiRwgJsDHYC3o0Pk/Ggz5B7wb4lw8 qyR45NZfZKBw3aVElhADXqKyG3nfXo3/IUbc7D1EkkmR7mx/4+VBsFVvADOXXy/9TJ uuRZkia7WI8pBPBmbmx79lewEY4CLFG83mToVT9KAb37eb+o8sQTV4lFRZ0dfFtWzP Ak/W9uR332SSRUpETuWb5++pozDBHWeXAnMcWqPj07njWDdSkB0+88JVmADS6mt6KH CY1Jt2QbmF1lQ== From: Gabriel Krisman Bertazi To: pvorel@suse.cz, jack@suse.com, amir73il@gmail.com, repnop@google.com Date: Thu, 18 Nov 2021 18:57:37 -0500 Message-Id: <20211118235744.802584-3-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211118235744.802584-1-krisman@collabora.com> References: <20211118235744.802584-1-krisman@collabora.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=DKIM_INVALID,DKIM_SIGNED, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v4 2/9] syscalls: fanotify: Add macro to require specific events 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: Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, kernel@collabora.com, ltp@lists.linux.it, khazhy@google.com Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Add a helper for tests to fail if an event is not available in the kernel. Since some events only work with REPORT_FID or a specific class, update the verifier to allow those to be specified. Reviewed-by: Amir Goldstein Reviewed-by: Matthew Bobrowski Signed-off-by: Gabriel Krisman Bertazi --- If I understand correctly, the decision was to leave fanotify10 unchanged and this is what I've done here. Changes since v1: - Use SAFE_FANOTIFY_INIT instead of open coding. (Amir) - Use FAN_CLASS_NOTIF for fanotify12 testcase. (Amir) --- testcases/kernel/syscalls/fanotify/fanotify.h | 17 ++++++++++++++--- testcases/kernel/syscalls/fanotify/fanotify03.c | 4 ++-- testcases/kernel/syscalls/fanotify/fanotify10.c | 3 ++- testcases/kernel/syscalls/fanotify/fanotify12.c | 3 ++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h index b9f430fe0c35..242245826004 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify.h +++ b/testcases/kernel/syscalls/fanotify/fanotify.h @@ -287,14 +287,16 @@ static inline void require_fanotify_access_permissions_supported_by_kernel(void) SAFE_CLOSE(fd); } -static inline int fanotify_events_supported_by_kernel(uint64_t mask) +static inline int fanotify_events_supported_by_kernel(uint64_t mask, + unsigned int init_flags, + unsigned int mark_flags) { int fd; int rval = 0; - fd = SAFE_FANOTIFY_INIT(FAN_CLASS_CONTENT, O_RDONLY); + fd = SAFE_FANOTIFY_INIT(init_flags, O_RDONLY); - if (fanotify_mark(fd, FAN_MARK_ADD, mask, AT_FDCWD, ".") < 0) { + if (fanotify_mark(fd, FAN_MARK_ADD | mark_flags, mask, AT_FDCWD, ".") < 0) { if (errno == EINVAL) { rval = -1; } else { @@ -404,4 +406,13 @@ static inline int fanotify_mark_supported_by_kernel(uint64_t flag) fanotify_mark_supported_by_kernel(mark_type)); \ } while (0) +#define REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS(init_flags, mark_type, mask, fname) do { \ + if (mark_type) \ + REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL(mark_type); \ + if (init_flags) \ + REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(init_flags, fname); \ + fanotify_init_flags_err_msg(#mask, __FILE__, __LINE__, tst_brk_, \ + fanotify_events_supported_by_kernel(mask, init_flags, mark_type)); \ +} while (0) + #endif /* __FANOTIFY_H__ */ diff --git a/testcases/kernel/syscalls/fanotify/fanotify03.c b/testcases/kernel/syscalls/fanotify/fanotify03.c index 26d17e64d1f5..2081f0bd1b57 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify03.c +++ b/testcases/kernel/syscalls/fanotify/fanotify03.c @@ -323,8 +323,8 @@ static void setup(void) require_fanotify_access_permissions_supported_by_kernel(); filesystem_mark_unsupported = fanotify_mark_supported_by_kernel(FAN_MARK_FILESYSTEM); - exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC_PERM); - + exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC_PERM, + FAN_CLASS_CONTENT, 0); sprintf(fname, MOUNT_PATH"/fname_%d", getpid()); SAFE_FILE_PRINTF(fname, "1"); diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c index 92e4d3ff3054..0fa9d1f4f7e4 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify10.c +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c @@ -509,7 +509,8 @@ cleanup: static void setup(void) { - exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC); + exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC, + FAN_CLASS_CONTENT, 0); filesystem_mark_unsupported = fanotify_mark_supported_by_kernel(FAN_MARK_FILESYSTEM); fan_report_dfid_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_DFID_NAME, MOUNT_PATH); diff --git a/testcases/kernel/syscalls/fanotify/fanotify12.c b/testcases/kernel/syscalls/fanotify/fanotify12.c index 76f1aca77615..c77dbfd8c23d 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify12.c +++ b/testcases/kernel/syscalls/fanotify/fanotify12.c @@ -222,7 +222,8 @@ cleanup: static void do_setup(void) { - exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC); + exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC, + FAN_CLASS_NOTIF, 0); sprintf(fname, "fname_%d", getpid()); SAFE_FILE_PRINTF(fname, "1"); From patchwork Thu Nov 18 23:57:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 1556846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=jCgtYbK4; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwGwD1dkmz9sVc for ; Fri, 19 Nov 2021 10:58:36 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AF0343C89B1 for ; Fri, 19 Nov 2021 00:58:33 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id E06A43C89B3 for ; Fri, 19 Nov 2021 00:58:06 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 03D3D1000D3D for ; Fri, 19 Nov 2021 00:58:05 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id A3ED21F47098 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=collabora.com; s=mail; t=1637279883; bh=SEYcYBjqfpHp40Ol4xtoiG1XFKt8lQmtMcz+9DfxYd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jCgtYbK46JaDoTYmzKcfo9wDGrD3+QSBaZNhyTnVNLIz+4SZmjnboRv0P2xX6/1Wz m/vW/G7A2jyqy0JLjEfsFDJgStJN6wSXfNJUtRF3UNUo3N4pHsksEPuKfatbXPOvh+ H5/xAzJJwkB7V4FfRGzIcp1KXPiqKyM+S1GatCKXq0SrJVe91KBViYwnmBLtn+oNmz uzdi2pRtPxNNw4R4wv/dhRxD5Oj/XCst3ZbBz6gdzUgV71um2KWUA0uXQagd1DpDT6 mO5xbz5jUOOj/rSyo7k/KWWPWZKwAcSQlXEVPVOpH7kgSB12Ekm41FB4q9iZ08KHLa AO4/9Gl+RmX8A== From: Gabriel Krisman Bertazi To: pvorel@suse.cz, jack@suse.com, amir73il@gmail.com, repnop@google.com Date: Thu, 18 Nov 2021 18:57:38 -0500 Message-Id: <20211118235744.802584-4-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211118235744.802584-1-krisman@collabora.com> References: <20211118235744.802584-1-krisman@collabora.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=DKIM_INVALID,DKIM_SIGNED, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v4 3/9] syscalls/fanotify22: Introduce FAN_FS_ERROR test 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: Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, kernel@collabora.com, ltp@lists.linux.it, khazhy@google.com Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" fanotify22 is a new test validating the FAN_FS_ERROR file system error event. This adds some basic structure for the next patches and a single test of error reporting during filesystem abort The strategy for error reporting testing in fanotify22 goes like this: - Generate a broken filesystem - Start FAN_FS_ERROR monitoring group - Make the file system notice the error through ordinary operations - Observe the event generated FAN_FS_ERROR was added in the kernel by Linux commit 9709bd548f11 ("fanotify: Allow users to request FAN_FS_ERROR events"). Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- Changes since v3: - fanotify21 -> fanotify22 (Matthew) Changes since v1: - Move defines to header file. - Move fanotify_mark(2) to do_test (Amir) - Merge abort test here --- testcases/kernel/syscalls/fanotify/.gitignore | 1 + testcases/kernel/syscalls/fanotify/fanotify.h | 3 + .../kernel/syscalls/fanotify/fanotify22.c | 140 ++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify22.c diff --git a/testcases/kernel/syscalls/fanotify/.gitignore b/testcases/kernel/syscalls/fanotify/.gitignore index 35e73b91e392..6d4ab4ca3c06 100644 --- a/testcases/kernel/syscalls/fanotify/.gitignore +++ b/testcases/kernel/syscalls/fanotify/.gitignore @@ -19,4 +19,5 @@ /fanotify19 /fanotify20 /fanotify21 +/fanotify22 /fanotify_child diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h index 242245826004..3a8f950950e0 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify.h +++ b/testcases/kernel/syscalls/fanotify/fanotify.h @@ -127,6 +127,9 @@ static inline int safe_fanotify_mark(const char *file, const int lineno, #ifndef FAN_OPEN_EXEC_PERM #define FAN_OPEN_EXEC_PERM 0x00040000 #endif +#ifndef FAN_FS_ERROR +#define FAN_FS_ERROR 0x00008000 +#endif /* Additional error status codes that can be returned to userspace */ #ifndef FAN_NOPIDFD diff --git a/testcases/kernel/syscalls/fanotify/fanotify22.c b/testcases/kernel/syscalls/fanotify/fanotify22.c new file mode 100644 index 000000000000..55e695b133d6 --- /dev/null +++ b/testcases/kernel/syscalls/fanotify/fanotify22.c @@ -0,0 +1,140 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2021 Collabora Ltd. + * + * Author: Gabriel Krisman Bertazi + * Based on previous work by Amir Goldstein + */ + +/*\ + * [Description] + * Check fanotify FAN_ERROR_FS events triggered by intentionally + * corrupted filesystems: + * + * - Generate a broken filesystem + * - Start FAN_FS_ERROR monitoring group + * - Make the file system notice the error through ordinary operations + * - Observe the event generated + */ + +#define _GNU_SOURCE +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include "tst_test.h" +#include +#include +#include + +#ifdef HAVE_SYS_FANOTIFY_H +#include "fanotify.h" + +#define BUF_SIZE 256 +static char event_buf[BUF_SIZE]; +int fd_notify; + +#define MOUNT_PATH "test_mnt" + +static void trigger_fs_abort(void) +{ + SAFE_MOUNT(tst_device->dev, MOUNT_PATH, tst_device->fs_type, + MS_REMOUNT|MS_RDONLY, "abort"); +} + +static struct test_case { + char *name; + void (*trigger_error)(void); +} testcases[] = { + { + .name = "Trigger abort", + .trigger_error = &trigger_fs_abort, + }, +}; + +int check_error_event_metadata(struct fanotify_event_metadata *event) +{ + int fail = 0; + + if (event->mask != FAN_FS_ERROR) { + fail++; + tst_res(TFAIL, "got unexpected event %llx", + (unsigned long long)event->mask); + } + + if (event->fd != FAN_NOFD) { + fail++; + tst_res(TFAIL, "Weird FAN_FD %llx", + (unsigned long long)event->mask); + } + return fail; +} + +void check_event(char *buf, size_t len, const struct test_case *ex) +{ + struct fanotify_event_metadata *event = + (struct fanotify_event_metadata *) buf; + + if (len < FAN_EVENT_METADATA_LEN) { + tst_res(TFAIL, "No event metadata found"); + return; + } + + if (check_error_event_metadata(event)) + return; + + tst_res(TPASS, "Successfully received: %s", ex->name); +} + +static void do_test(unsigned int i) +{ + const struct test_case *tcase = &testcases[i]; + size_t read_len; + + SAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_ADD|FAN_MARK_FILESYSTEM, + FAN_FS_ERROR, AT_FDCWD, MOUNT_PATH); + + tcase->trigger_error(); + + read_len = SAFE_READ(0, fd_notify, event_buf, BUF_SIZE); + + SAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_REMOVE|FAN_MARK_FILESYSTEM, + FAN_FS_ERROR, AT_FDCWD, MOUNT_PATH); + + check_event(event_buf, read_len, tcase); +} + +static void setup(void) +{ + REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS(FAN_CLASS_NOTIF|FAN_REPORT_FID, + FAN_MARK_FILESYSTEM, + FAN_FS_ERROR, "."); + + fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF|FAN_REPORT_FID, + O_RDONLY); +} + +static void cleanup(void) +{ + if (fd_notify > 0) + SAFE_CLOSE(fd_notify); +} + +static struct tst_test test = { + .test = do_test, + .tcnt = ARRAY_SIZE(testcases), + .setup = setup, + .cleanup = cleanup, + .mount_device = 1, + .mntpoint = MOUNT_PATH, + .needs_root = 1, + .dev_fs_type = "ext4" +}; + +#else + TST_TEST_TCONF("system doesn't have required fanotify support"); +#endif From patchwork Thu Nov 18 23:57:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 1556847 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=m5h96OWW; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwGwQ6JJgz9sVc for ; Fri, 19 Nov 2021 10:58:46 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 1ED2C3C89B2 for ; Fri, 19 Nov 2021 00:58:44 +0100 (CET) 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]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 6E7133C8989 for ; Fri, 19 Nov 2021 00:58:09 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 422306020DA for ; Fri, 19 Nov 2021 00:58:07 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 431EE1F47098 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=collabora.com; s=mail; t=1637279887; bh=AX3c9fTCJEBoDqzWZ2+ck+gWbQoU+iauYve/clPEhL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m5h96OWWiYow1z8Fvhs2NOGEhNQNzzuzzZ9vUADl7JqPgHADheeSVpaK7eH7rJHga 5e3WhTN03xLWuJuedwK+LzdEL+sEf2DXWLr8BQe8YDpAo2MPoCO/bAmfDlDjBMc7bc hYGtw++ONWbCbZOTeujgr79jT3Ini7eYOThsZ+Jq6QKFn4dSt5G7wKKKgXiz18vvGk LmkbxxyLMm/1p+GzCCOJFvImo7lNslS1TC9QizNuxfZwU+gKlbuD08nCU52lVtP518 mu/s0gX0V0ZSY0k0tclgA4mvS1DfIo+VgIuyqL6avdN5wB5MdWDTrL0QqNJB1A/oMk Gh8fWO1Pyb5Qw== From: Gabriel Krisman Bertazi To: pvorel@suse.cz, jack@suse.com, amir73il@gmail.com, repnop@google.com Date: Thu, 18 Nov 2021 18:57:39 -0500 Message-Id: <20211118235744.802584-5-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211118235744.802584-1-krisman@collabora.com> References: <20211118235744.802584-1-krisman@collabora.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=DKIM_INVALID,DKIM_SIGNED, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v4 4/9] syscalls/fanotify22: Validate the generic error info 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: Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, kernel@collabora.com, ltp@lists.linux.it, khazhy@google.com Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Implement some validation for the generic error info record emitted by the kernel. The error number is fs-specific but, well, we only support ext4 for now anyway. Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- Changes since v2: - check for error record type in autotools (Amir) Changes since v1: - Move defines to header file. --- configure.ac | 3 +- testcases/kernel/syscalls/fanotify/fanotify.h | 32 ++++++++++++++++ .../kernel/syscalls/fanotify/fanotify22.c | 37 ++++++++++++++++++- 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 859aa9857021..a9dc2524966d 100644 --- a/configure.ac +++ b/configure.ac @@ -160,7 +160,8 @@ AC_CHECK_MEMBERS([struct utsname.domainname],,,[ AC_CHECK_TYPES([enum kcmp_type],,,[#include ]) AC_CHECK_TYPES([struct acct_v3],,,[#include ]) AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include ]) -AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header],,,[#include ]) +AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header, + struct fanotify_event_info_error],[],[],[#include ]) AC_CHECK_TYPES([struct file_dedupe_range],,,[#include ]) AC_CHECK_TYPES([struct file_handle],,,[ diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h index 3a8f950950e0..6b0e68a23a6b 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify.h +++ b/testcases/kernel/syscalls/fanotify/fanotify.h @@ -181,6 +181,9 @@ typedef struct { #ifndef FAN_EVENT_INFO_TYPE_PIDFD #define FAN_EVENT_INFO_TYPE_PIDFD 4 #endif +#ifndef FAN_EVENT_INFO_TYPE_ERROR +#define FAN_EVENT_INFO_TYPE_ERROR 5 +#endif #ifndef HAVE_STRUCT_FANOTIFY_EVENT_INFO_HEADER struct fanotify_event_info_header { @@ -205,6 +208,14 @@ struct fanotify_event_info_pidfd { }; #endif /* HAVE_STRUCT_FANOTIFY_EVENT_INFO_PIDFD */ +#ifndef HAVE_STRUCT_FANOTIFY_EVENT_INFO_ERROR +struct fanotify_event_info_error { + struct fanotify_event_info_header hdr; + __s32 error; + __u32 error_count; +}; +#endif /* HAVE_STRUCT_FANOTIFY_EVENT_INFO_ERROR */ + /* NOTE: only for struct fanotify_event_info_fid */ #ifdef HAVE_STRUCT_FANOTIFY_EVENT_INFO_FID_FSID___VAL # define FSID_VAL_MEMBER(fsid, i) (fsid.__val[i]) @@ -418,4 +429,25 @@ static inline int fanotify_mark_supported_by_kernel(uint64_t flag) fanotify_events_supported_by_kernel(mask, init_flags, mark_type)); \ } while (0) +struct fanotify_event_info_header *get_event_info( + struct fanotify_event_metadata *event, + int info_type) +{ + struct fanotify_event_info_header *hdr = NULL; + char *start = (char *) event; + int off; + + for (off = event->metadata_len; (off+sizeof(*hdr)) < event->event_len; + off += hdr->len) { + hdr = (struct fanotify_event_info_header *) &(start[off]); + if (hdr->info_type == info_type) + return hdr; + } + return NULL; +} + +#define get_event_info_error(event) \ + ((struct fanotify_event_info_error *) \ + get_event_info((event), FAN_EVENT_INFO_TYPE_ERROR)) + #endif /* __FANOTIFY_H__ */ diff --git a/testcases/kernel/syscalls/fanotify/fanotify22.c b/testcases/kernel/syscalls/fanotify/fanotify22.c index 55e695b133d6..d324191c28c8 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify22.c +++ b/testcases/kernel/syscalls/fanotify/fanotify22.c @@ -48,14 +48,38 @@ static void trigger_fs_abort(void) static struct test_case { char *name; + int error; + unsigned int error_count; void (*trigger_error)(void); } testcases[] = { { .name = "Trigger abort", .trigger_error = &trigger_fs_abort, + .error_count = 1, + .error = ESHUTDOWN, }, }; +int check_error_event_info_error(struct fanotify_event_info_error *info_error, + const struct test_case *ex) +{ + int fail = 0; + + if (info_error->error_count != ex->error_count) { + tst_res(TFAIL, "%s: Unexpected error_count (%d!=%d)", + ex->name, info_error->error_count, ex->error_count); + fail++; + } + + if (info_error->error != ex->error) { + tst_res(TFAIL, "%s: Unexpected error code value (%d!=%d)", + ex->name, info_error->error, ex->error); + fail++; + } + + return fail; +} + int check_error_event_metadata(struct fanotify_event_metadata *event) { int fail = 0; @@ -78,6 +102,8 @@ void check_event(char *buf, size_t len, const struct test_case *ex) { struct fanotify_event_metadata *event = (struct fanotify_event_metadata *) buf; + struct fanotify_event_info_error *info_error; + int fail = 0; if (len < FAN_EVENT_METADATA_LEN) { tst_res(TFAIL, "No event metadata found"); @@ -87,7 +113,16 @@ void check_event(char *buf, size_t len, const struct test_case *ex) if (check_error_event_metadata(event)) return; - tst_res(TPASS, "Successfully received: %s", ex->name); + info_error = get_event_info_error(event); + if (info_error) + fail += check_error_event_info_error(info_error, ex); + else { + tst_res(TFAIL, "Generic error record not found"); + fail++; + } + + if (!fail) + tst_res(TPASS, "Successfully received: %s", ex->name); } static void do_test(unsigned int i) From patchwork Thu Nov 18 23:57:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 1556848 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=gj4puOQi; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwGwc42bSz9sVc for ; Fri, 19 Nov 2021 10:58:56 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C81833C8984 for ; Fri, 19 Nov 2021 00:58:53 +0100 (CET) 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 RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id B0F2A3C899B for ; Fri, 19 Nov 2021 00:58:12 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 7A47D200C35 for ; Fri, 19 Nov 2021 00:58:11 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 6F3011F47098 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=collabora.com; s=mail; t=1637279890; bh=4ltSuo40feNEKTd2UPvpFTWVFo8E467iYwf8MrGWWsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gj4puOQidzdmoh+rbbV9V6lxoqfxlItPgG4r47eWBimj6snhUHU7+LkFNXj4oR5Ks ejqFoIhS2kNpcNrC9rqlMKig+Ugt0XU1aUyLKcXOKEYa5q+MIHpRqDSCdaHQX0Iytm 0QAMOlk84BtXCncioDEgMB1R2ZXF3eqyhvhGyhGnvu+zSY90yd40omwrTgQg7Nv8BX yGRETZUiAHEnBNQvEb/3+F/vK8Q1NxsflyVzlqpUiwX+aGG54ErqjSJICBMB9DNY20 DpmRd6II8JYP9NBfkT9n937bGcRrffKX/RLmk2pgNg79qCjZ40gw7AbO/RzTNuHoy9 28XYW4cglQq8Q== From: Gabriel Krisman Bertazi To: pvorel@suse.cz, jack@suse.com, amir73il@gmail.com, repnop@google.com Date: Thu, 18 Nov 2021 18:57:40 -0500 Message-Id: <20211118235744.802584-6-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211118235744.802584-1-krisman@collabora.com> References: <20211118235744.802584-1-krisman@collabora.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=DKIM_INVALID,DKIM_SIGNED, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH v4 5/9] syscalls/fanotify22: Validate incoming FID in FAN_FS_ERROR 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: Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, kernel@collabora.com, ltp@lists.linux.it, khazhy@google.com Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Verify the FID provided in the event. If the FH has size 0, this is assumed to be a superblock error (i.e. null FH). Reviewed-by: Petr Vorel Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- Changes since v2: - Move FILEID_INVALID define to header file (Amir) - Don't use FSID_VAL_MEMBER (Petr) Changes since v1: - Move defines to header file. - Use 0-len FH for sb error --- testcases/kernel/syscalls/fanotify/fanotify.h | 8 +++ .../kernel/syscalls/fanotify/fanotify22.c | 60 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h index 6b0e68a23a6b..f7778bb36b4d 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify.h +++ b/testcases/kernel/syscalls/fanotify/fanotify.h @@ -255,6 +255,10 @@ static inline void fanotify_get_fid(const char *path, __kernel_fsid_t *fsid, } } +#ifndef FILEID_INVALID +#define FILEID_INVALID 0xff +#endif + struct fanotify_fid_t { __kernel_fsid_t fsid; struct file_handle handle; @@ -450,4 +454,8 @@ struct fanotify_event_info_header *get_event_info( ((struct fanotify_event_info_error *) \ get_event_info((event), FAN_EVENT_INFO_TYPE_ERROR)) +#define get_event_info_fid(event) \ + ((struct fanotify_event_info_fid *) \ + get_event_info((event), FAN_EVENT_INFO_TYPE_FID)) + #endif /* __FANOTIFY_H__ */ diff --git a/testcases/kernel/syscalls/fanotify/fanotify22.c b/testcases/kernel/syscalls/fanotify/fanotify22.c index d324191c28c8..eeee582f1268 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify22.c +++ b/testcases/kernel/syscalls/fanotify/fanotify22.c @@ -40,6 +40,9 @@ int fd_notify; #define MOUNT_PATH "test_mnt" +/* These expected FIDs are common to multiple tests */ +static struct fanotify_fid_t null_fid; + static void trigger_fs_abort(void) { SAFE_MOUNT(tst_device->dev, MOUNT_PATH, tst_device->fs_type, @@ -50,6 +53,7 @@ static struct test_case { char *name; int error; unsigned int error_count; + struct fanotify_fid_t *fid; void (*trigger_error)(void); } testcases[] = { { @@ -57,9 +61,43 @@ static struct test_case { .trigger_error = &trigger_fs_abort, .error_count = 1, .error = ESHUTDOWN, + .fid = &null_fid, }, }; +int check_error_event_info_fid(struct fanotify_event_info_fid *fid, + const struct test_case *ex) +{ + struct file_handle *fh = (struct file_handle *) &fid->handle; + + if (memcmp(&fid->fsid, &ex->fid->fsid, sizeof(fid->fsid))) { + tst_res(TFAIL, "%s: Received bad FSID type (%x...!=%x...)", + ex->name, FSID_VAL_MEMBER(fid->fsid, 0), + ex->fid->fsid.val[0]); + + return 1; + } + if (fh->handle_type != ex->fid->handle.handle_type) { + tst_res(TFAIL, "%s: Received bad file_handle type (%d!=%d)", + ex->name, fh->handle_type, ex->fid->handle.handle_type); + return 1; + } + + if (fh->handle_bytes != ex->fid->handle.handle_bytes) { + tst_res(TFAIL, "%s: Received bad file_handle len (%d!=%d)", + ex->name, fh->handle_bytes, ex->fid->handle.handle_bytes); + return 1; + } + + if (memcmp(fh->f_handle, ex->fid->handle.f_handle, fh->handle_bytes)) { + tst_res(TFAIL, "%s: Received wrong handle. " + "Expected (%x...) got (%x...) ", ex->name, + *(int *)ex->fid->handle.f_handle, *(int *)fh->f_handle); + return 1; + } + return 0; +} + int check_error_event_info_error(struct fanotify_event_info_error *info_error, const struct test_case *ex) { @@ -103,6 +141,7 @@ void check_event(char *buf, size_t len, const struct test_case *ex) struct fanotify_event_metadata *event = (struct fanotify_event_metadata *) buf; struct fanotify_event_info_error *info_error; + struct fanotify_event_info_fid *info_fid; int fail = 0; if (len < FAN_EVENT_METADATA_LEN) { @@ -121,6 +160,14 @@ void check_event(char *buf, size_t len, const struct test_case *ex) fail++; } + info_fid = get_event_info_fid(event); + if (info_fid) + fail += check_error_event_info_fid(info_fid, ex); + else { + tst_res(TFAIL, "FID record not found"); + fail++; + } + if (!fail) tst_res(TPASS, "Successfully received: %s", ex->name); } @@ -143,6 +190,17 @@ static void do_test(unsigned int i) check_event(event_buf, read_len, tcase); } +static void init_null_fid(void) +{ + /* Use fanotify_save_fid to fill the fsid and overwrite the + * file_handler to create a null_fid + */ + fanotify_save_fid(MOUNT_PATH, &null_fid); + + null_fid.handle.handle_type = FILEID_INVALID; + null_fid.handle.handle_bytes = 0; +} + static void setup(void) { REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS(FAN_CLASS_NOTIF|FAN_REPORT_FID, @@ -151,6 +209,8 @@ static void setup(void) fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF|FAN_REPORT_FID, O_RDONLY); + + init_null_fid(); } static void cleanup(void) From patchwork Thu Nov 18 23:57:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 1556849 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=UqdoJgHi; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwGwn25Vjz9sVc for ; Fri, 19 Nov 2021 10:59:05 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 38B323C8989 for ; Fri, 19 Nov 2021 00:59:03 +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]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 37F933C3349 for ; Fri, 19 Nov 2021 00:58:16 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (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 7A4DE1400768 for ; Fri, 19 Nov 2021 00:58:15 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 599B41F47098 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=collabora.com; s=mail; t=1637279894; bh=mwgQRcAPY0UhabSUmUkf3+MRuf8WSxV9z4jkotD/HZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UqdoJgHiyJ7s4GJhgdAHy6SB0/sIJA9kEwf6LF2DTA3nWRmeztPUtyFRk1sEx88TP DPX1Vn7wBXrhHfyTjQQtGEMAndFRxbZ3lpRjWV9FxS6HiQu1jM+PmWMDo8pTinHOl9 lvyzb1RJuswTdG/4Cvs2tdjAYPuWzIBHkpExJQ1QT21nK2QBWIWL5n2pVIBvVVcvHk xB5xsgBf0IlGsZFb9OWRTo3SRbmykOdQCLBfePZ9rNcLTqrRTlM5EFmTk4inU9dyyi Cn7Oprmo4CgdnkYt2LeSBgdTnLFzkOLFYUNSCIZstUUY0KWFjJhr5rnblcBIvntXDh 0vVfHx6wgWGPA== From: Gabriel Krisman Bertazi To: pvorel@suse.cz, jack@suse.com, amir73il@gmail.com, repnop@google.com Date: Thu, 18 Nov 2021 18:57:41 -0500 Message-Id: <20211118235744.802584-7-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211118235744.802584-1-krisman@collabora.com> References: <20211118235744.802584-1-krisman@collabora.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=DKIM_INVALID,DKIM_SIGNED, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v4 6/9] syscalls/fanotify22: Support submission of debugfs commands 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: Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, kernel@collabora.com, ltp@lists.linux.it, khazhy@google.com Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" In order to test FAN_FS_ERROR, we want to corrupt the filesystem. The easiest way to do it is by using debugfs. Add a small helper to issue debugfs requests. Since most likely this will be the only testcase to need this, don't bother making it a proper helper for now. Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- changes since v1: - Add .needs_cmds to require debugfs --- testcases/kernel/syscalls/fanotify/fanotify22.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/testcases/kernel/syscalls/fanotify/fanotify22.c b/testcases/kernel/syscalls/fanotify/fanotify22.c index eeee582f1268..bb44ed55e96e 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify22.c +++ b/testcases/kernel/syscalls/fanotify/fanotify22.c @@ -49,6 +49,13 @@ static void trigger_fs_abort(void) MS_REMOUNT|MS_RDONLY, "abort"); } +static void do_debugfs_request(const char *dev, char *request) +{ + const char *cmd[] = {"debugfs", "-w", dev, "-R", request, NULL}; + + SAFE_CMD(cmd, NULL, NULL); +} + static struct test_case { char *name; int error; @@ -227,7 +234,11 @@ static struct tst_test test = { .mount_device = 1, .mntpoint = MOUNT_PATH, .needs_root = 1, - .dev_fs_type = "ext4" + .dev_fs_type = "ext4", + .needs_cmds = (const char *[]) { + "debugfs", + NULL + } }; #else From patchwork Thu Nov 18 23:57:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 1556850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=PQTOYubV; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwGwz0wkmz9sVc for ; Fri, 19 Nov 2021 10:59:15 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 1AD543C8994 for ; Fri, 19 Nov 2021 00:59:13 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 6EA8D3C89A0 for ; Fri, 19 Nov 2021 00:58:19 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id E32871A0119D for ; Fri, 19 Nov 2021 00:58:18 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id C77F51F47098 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=collabora.com; s=mail; t=1637279898; bh=AMEWurQydOhlrkam7tWoA2YxYk8g84h/9nWOOD1niKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PQTOYubV3sJj0NfeB6mNscv4HVzgadJYwxrFWy6xVm30NO13cF85tMXbZDHUqET8q 1qdN5knpN3mzINJ9EfnE82+uEg1ulJXE1PFWBY/e5qeApzyBUGv1G8ECQAWdy2u9P1 ABsQeOeN7hYYLugT++og3jrz1y7G66h+nbhIieq1X89ln3raxuKzsTmFMo9SHz6sWV h3GgLotnj/LPOwQvmgOjkrP80pFH8kJRGL5thcAbk0z24RiRSrUYyS705+XKO8rINO UpFFuW/7CZHkq6kgWWmLkXpJ0GBp5Bjx0hadrZzLs4dR1P6mfzyJ7MJUS1+vMyYf7I pyWjWtysvQuqA== From: Gabriel Krisman Bertazi To: pvorel@suse.cz, jack@suse.com, amir73il@gmail.com, repnop@google.com Date: Thu, 18 Nov 2021 18:57:42 -0500 Message-Id: <20211118235744.802584-8-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211118235744.802584-1-krisman@collabora.com> References: <20211118235744.802584-1-krisman@collabora.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=DKIM_INVALID,DKIM_SIGNED, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH v4 7/9] syscalls/fanotify22: Create a corrupted file 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: Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, kernel@collabora.com, ltp@lists.linux.it, khazhy@google.com Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Allocate a test directory and corrupt it with debugfs. The corruption is done by writing an invalid inode mode. This file can be later looked up to trigger a corruption error. Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- testcases/kernel/syscalls/fanotify/fanotify22.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/testcases/kernel/syscalls/fanotify/fanotify22.c b/testcases/kernel/syscalls/fanotify/fanotify22.c index bb44ed55e96e..5d8b4eec74bd 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify22.c +++ b/testcases/kernel/syscalls/fanotify/fanotify22.c @@ -39,9 +39,12 @@ static char event_buf[BUF_SIZE]; int fd_notify; #define MOUNT_PATH "test_mnt" +#define BASE_DIR "internal_dir" +#define BAD_DIR BASE_DIR"/bad_dir" /* These expected FIDs are common to multiple tests */ static struct fanotify_fid_t null_fid; +static struct fanotify_fid_t bad_file_fid; static void trigger_fs_abort(void) { @@ -197,6 +200,18 @@ static void do_test(unsigned int i) check_event(event_buf, read_len, tcase); } +static void pre_corrupt_fs(void) +{ + SAFE_MKDIR(MOUNT_PATH"/"BASE_DIR, 0777); + SAFE_MKDIR(MOUNT_PATH"/"BAD_DIR, 0777); + + fanotify_save_fid(MOUNT_PATH"/"BAD_DIR, &bad_file_fid); + + SAFE_UMOUNT(MOUNT_PATH); + do_debugfs_request(tst_device->dev, "sif " BAD_DIR " mode 0xff"); + SAFE_MOUNT(tst_device->dev, MOUNT_PATH, tst_device->fs_type, 0, NULL); +} + static void init_null_fid(void) { /* Use fanotify_save_fid to fill the fsid and overwrite the @@ -213,6 +228,7 @@ static void setup(void) REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS(FAN_CLASS_NOTIF|FAN_REPORT_FID, FAN_MARK_FILESYSTEM, FAN_FS_ERROR, "."); + pre_corrupt_fs(); fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF|FAN_REPORT_FID, O_RDONLY); From patchwork Thu Nov 18 23:57:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 1556851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=Mw8hYET2; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwGxB44vYz9sVc for ; Fri, 19 Nov 2021 10:59:26 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0CF993C899F for ; Fri, 19 Nov 2021 00:59:24 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 917CD3C8994 for ; Fri, 19 Nov 2021 00:58:23 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id D0E17600C38 for ; Fri, 19 Nov 2021 00:58:22 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id C59161F47098 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=collabora.com; s=mail; t=1637279902; bh=aWhpa1EEwRuPW3BfULGcgKipuwl/JVjvTOS3Grz/c3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mw8hYET2qcHvXrzh6LtV0Q9Yv71mZbcCn7Dx4KrUINFe/JBNd7socJIF8bjXY0m/U GyxkjTxikPms6wsUxeMDRi2tg5Nn0KsSb0BbSosyEyQ6j40OA2pBd05wEjGxaJlcWG qf1P4FGV1W8BFqTjBissAatQJ0g9c5Q5u9dqxdu6eX0fOsD/MWjLl0Qs2Z7hU/cqTu iWn5CZ1aQzYHrgZgYMY5LDin3q6vubjrq/cthrPLraa1Qo+IvWCIsXjNL3fVWSaBjk lgSEq+BW7G+H9ALR9EnR0yv5IpNdUYqGz0RCq/mYVi5P1h3VXfmYnN+H4Z6oACwpfs 8DXtXdFg9p/qQ== From: Gabriel Krisman Bertazi To: pvorel@suse.cz, jack@suse.com, amir73il@gmail.com, repnop@google.com Date: Thu, 18 Nov 2021 18:57:43 -0500 Message-Id: <20211118235744.802584-9-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211118235744.802584-1-krisman@collabora.com> References: <20211118235744.802584-1-krisman@collabora.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=DKIM_INVALID,DKIM_SIGNED, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v4 8/9] syscalls/fanotify22: Test file event with broken inode 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: Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, kernel@collabora.com, ltp@lists.linux.it, khazhy@google.com Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test corrupts an inode entry with an invalid mode through debugfs and then tries to access it. This should result in a ext4 error, which we monitor through the fanotify group. In order for this test to succeed, it requires a kernel fix introduced by kernel commit 124e7c61deb2 ("ext4: fix error code saved on super block during file system abort"), which is added to .tags. Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- .../kernel/syscalls/fanotify/fanotify22.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/testcases/kernel/syscalls/fanotify/fanotify22.c b/testcases/kernel/syscalls/fanotify/fanotify22.c index 5d8b4eec74bd..9cd8c8f919b0 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify22.c +++ b/testcases/kernel/syscalls/fanotify/fanotify22.c @@ -34,6 +34,10 @@ #ifdef HAVE_SYS_FANOTIFY_H #include "fanotify.h" +#ifndef EFSCORRUPTED +#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ +#endif + #define BUF_SIZE 256 static char event_buf[BUF_SIZE]; int fd_notify; @@ -59,6 +63,17 @@ static void do_debugfs_request(const char *dev, char *request) SAFE_CMD(cmd, NULL, NULL); } +static void tcase2_trigger_lookup(void) +{ + int ret; + + /* SAFE_OPEN cannot be used here because we expect it to fail. */ + ret = open(MOUNT_PATH"/"BAD_DIR, O_RDONLY, 0); + if (ret != -1 && errno != EUCLEAN) + tst_res(TFAIL, "Unexpected lookup result(%d) of %s (%d!=%d)", + ret, BAD_DIR, errno, EUCLEAN); +} + static struct test_case { char *name; int error; @@ -73,6 +88,13 @@ static struct test_case { .error = ESHUTDOWN, .fid = &null_fid, }, + { + .name = "Lookup of inode with invalid mode", + .trigger_error = &tcase2_trigger_lookup, + .error_count = 1, + .error = EFSCORRUPTED, + .fid = &bad_file_fid, + }, }; int check_error_event_info_fid(struct fanotify_event_info_fid *fid, @@ -251,6 +273,10 @@ static struct tst_test test = { .mntpoint = MOUNT_PATH, .needs_root = 1, .dev_fs_type = "ext4", + .tags = (const struct tst_tag[]) { + {"linux-git", "124e7c61deb2"}, + {} + }, .needs_cmds = (const char *[]) { "debugfs", NULL From patchwork Thu Nov 18 23:57:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 1556852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=Vg3b0lcs; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwGxN2C1bz9sVc for ; Fri, 19 Nov 2021 10:59:36 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 76D933C899B for ; Fri, 19 Nov 2021 00:59:33 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 2B6C83C8982 for ; Fri, 19 Nov 2021 00:58:27 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id C2255600C22 for ; Fri, 19 Nov 2021 00:58:26 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id A74741F47098 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=collabora.com; s=mail; t=1637279906; bh=rR3odTmBNckbpv7LtDd+ICNinRP/Al333rsvjphRca0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vg3b0lcsGsOQt/sBkPa364rk2SPkdgafZ+1iWz8iMYGg4mgtIUR42ymvNekVTmWeR Kg1sV8T4aY78IDuIOfP4JIspSCCAgU38tfdJ0FhF5k7NU5yN3ghkqeSuuVU1zb1vhD 6QaVGiDFIVnQXFCYcoh8SPSvuzDyQM6sLvKWaMbnoEvlyngs4r5KaXQGg+OHwEqMx/ bFyVh9sbSYKUglX5okHo8t2SASy7SgWp2B+pvALVy7/S4xy061xwn/jI+0L2MPB3Xl gsqfjKz6yyPz+Bbi2t7f6b13qYw6PctWQ0g8JraYUnPtgM0X2GRlHPo3+Yv5c2fn7I 7qVerwSPyrcug== From: Gabriel Krisman Bertazi To: pvorel@suse.cz, jack@suse.com, amir73il@gmail.com, repnop@google.com Date: Thu, 18 Nov 2021 18:57:44 -0500 Message-Id: <20211118235744.802584-10-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211118235744.802584-1-krisman@collabora.com> References: <20211118235744.802584-1-krisman@collabora.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=DKIM_INVALID,DKIM_SIGNED, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v4 9/9] syscalls/fanotify22: Test capture of multiple errors 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: Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, kernel@collabora.com, ltp@lists.linux.it, khazhy@google.com Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" When multiple FS errors occur, only the first is stored. This testcase validates this behavior by issuing two different errors and making sure only the first is stored, while the second is simply accumulated in error_count. Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- .../kernel/syscalls/fanotify/fanotify22.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/testcases/kernel/syscalls/fanotify/fanotify22.c b/testcases/kernel/syscalls/fanotify/fanotify22.c index 9cd8c8f919b0..b42e96e8263e 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify22.c +++ b/testcases/kernel/syscalls/fanotify/fanotify22.c @@ -74,6 +74,18 @@ static void tcase2_trigger_lookup(void) ret, BAD_DIR, errno, EUCLEAN); } +static void tcase3_trigger(void) +{ + trigger_fs_abort(); + tcase2_trigger_lookup(); +} + +static void tcase4_trigger(void) +{ + tcase2_trigger_lookup(); + trigger_fs_abort(); +} + static struct test_case { char *name; int error; @@ -95,6 +107,20 @@ static struct test_case { .error = EFSCORRUPTED, .fid = &bad_file_fid, }, + { + .name = "Multiple error submission", + .trigger_error = &tcase3_trigger, + .error_count = 2, + .error = ESHUTDOWN, + .fid = &null_fid, + }, + { + .name = "Multiple error submission 2", + .trigger_error = &tcase4_trigger, + .error_count = 2, + .error = EFSCORRUPTED, + .fid = &bad_file_fid, + } }; int check_error_event_info_fid(struct fanotify_event_info_fid *fid,