From patchwork Tue Oct 8 09:42:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1994160 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=bscafhBB; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=SKfWw9XE; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=bscafhBB; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=SKfWw9XE; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XNB2m3k9fz1xtV for ; Tue, 8 Oct 2024 20:45:20 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0F4933C1B71 for ; Tue, 8 Oct 2024 11:45:18 +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 (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 66A573C19F3 for ; Tue, 8 Oct 2024 11:42:38 +0200 (CEST) Authentication-Results: in-7.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:1; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 9D7932082A0 for ; Tue, 8 Oct 2024 11:42:37 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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 smtp-out1.suse.de (Postfix) with ESMTPS id 6329721A32; Tue, 8 Oct 2024 09:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728380556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0tg+hmQe0o/a/xtuMcoeFp2Gzih5GezvQ3Wxr7tG4ew=; b=bscafhBBBObcb5RJ8XjpmIJev4haIsFfGIQdxilYx/9imlC9YLDORCoE/TPuClyDKYrtkU xgN9t8BgiJr6LpoWIviaj7WKn6ejeGwfJOya+dWmOC3RPXkDNhw885IABQxKYPyOxsNASA sYGd80QGmJXzbj7DdAu3kzfx2ncFlKM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728380556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0tg+hmQe0o/a/xtuMcoeFp2Gzih5GezvQ3Wxr7tG4ew=; b=SKfWw9XENd4kd/xrTSZKHSmak5ShQutUQe4PyN9WASt0amecSIAoItBpwxpP+ZPvudzAL4 cIbcKAVBngVqkgAg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=bscafhBB; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=SKfWw9XE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728380556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0tg+hmQe0o/a/xtuMcoeFp2Gzih5GezvQ3Wxr7tG4ew=; b=bscafhBBBObcb5RJ8XjpmIJev4haIsFfGIQdxilYx/9imlC9YLDORCoE/TPuClyDKYrtkU xgN9t8BgiJr6LpoWIviaj7WKn6ejeGwfJOya+dWmOC3RPXkDNhw885IABQxKYPyOxsNASA sYGd80QGmJXzbj7DdAu3kzfx2ncFlKM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728380556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0tg+hmQe0o/a/xtuMcoeFp2Gzih5GezvQ3Wxr7tG4ew=; b=SKfWw9XENd4kd/xrTSZKHSmak5ShQutUQe4PyN9WASt0amecSIAoItBpwxpP+ZPvudzAL4 cIbcKAVBngVqkgAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id ECBCD1340C; Tue, 8 Oct 2024 09:42:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SFtnJ4v+BGcZPAAAD6G6ig (envelope-from ); Tue, 08 Oct 2024 09:42:35 +0000 From: Andrea Cervesato Date: Tue, 08 Oct 2024 11:42:03 +0200 MIME-Version: 1.0 Message-Id: <20241008-listmount_statmount-v5-10-66f4e1a9e7db@suse.com> References: <20241008-listmount_statmount-v5-0-66f4e1a9e7db@suse.com> In-Reply-To: <20241008-listmount_statmount-v5-0-66f4e1a9e7db@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728380526; l=4199; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=XbelAVhH+v51dIWJ1KcmiFEctFwki3hohFW62zDCklg=; b=KHcW8vE2rptTP+jG7qIibOZYf4EfIl8dzAYtqqHNEuPJbQKOxtlMl5bNPvbWGxyPYTPba27Cl xRiczfDhNNjAdNc1wm1GkGiuO/8JPMl4Vj1XUSEbH7JjK5J4F3oOdat X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Rspamd-Queue-Id: 6329721A32 X-Spam-Level: X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim,suse.cz:email,suse.com:email,suse.com:mid]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.51 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,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-Virus-Scanned: clamav-milter 1.0.3 at in-7.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v5 10/16] Add statmount04 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato This test verifies that statmount() is correctly reading propagation from what mount in current namespace using STATMOUNT_PROPAGATE_FROM. Reviewed-by: Cyril Hrubis Signed-off-by: Andrea Cervesato --- runtest/syscalls | 1 + testcases/kernel/syscalls/statmount/.gitignore | 1 + testcases/kernel/syscalls/statmount/statmount04.c | 105 ++++++++++++++++++++++ 3 files changed, 107 insertions(+) diff --git a/runtest/syscalls b/runtest/syscalls index 47ca26213..452ac1ac9 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1577,6 +1577,7 @@ stat04_64 stat04_64 statmount01 statmount01 statmount02 statmount02 statmount03 statmount03 +statmount04 statmount04 statfs01 statfs01 statfs01_64 statfs01_64 diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore index 2a02bf721..e720050b5 100644 --- a/testcases/kernel/syscalls/statmount/.gitignore +++ b/testcases/kernel/syscalls/statmount/.gitignore @@ -1,3 +1,4 @@ statmount01 statmount02 statmount03 +statmount04 diff --git a/testcases/kernel/syscalls/statmount/statmount04.c b/testcases/kernel/syscalls/statmount/statmount04.c new file mode 100644 index 000000000..509fdf6a1 --- /dev/null +++ b/testcases/kernel/syscalls/statmount/statmount04.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * This test verifies that statmount() is correctly reading propagation from + * what mount in current namespace using STATMOUNT_PROPAGATE_FROM. + * + * [Algorithm] + * + * - create a mount point + * - propagate a mounted folder inside the mount point + * - run statmount() on the mount point using STATMOUNT_PROPAGATE_FROM + * - read results and check propagated_from parameter contains the propagated + * folder ID + */ + +#define _GNU_SOURCE + +#include "statmount.h" +#include "lapi/stat.h" +#include "lapi/sched.h" + +#define MNTPOINT "mntpoint" +#define DIR_A MNTPOINT "/LTP_DIR_A" +#define DIR_C_SUBFOLDER "/LTP_DIR_A/propagated" +#define DIR_C (MNTPOINT DIR_C_SUBFOLDER) +#define DIR_B MNTPOINT "/LTP_DIR_B" +#define DIR_D MNTPOINT "/LTP_DIR_B/propagated" + +static uint64_t peer_group_id; +static uint64_t dird_id; +static struct statmount *st_mount; + +static void run(void) +{ + memset(st_mount, 0, sizeof(struct statmount)); + + TST_EXP_PASS(statmount(dird_id, STATMOUNT_PROPAGATE_FROM, st_mount, + sizeof(struct statmount), 0)); + + if (!TST_PASS) + return; + + TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_PROPAGATE_FROM); + TST_EXP_EQ_LI(st_mount->size, sizeof(struct statmount)); + TST_EXP_EQ_LI(st_mount->propagate_from, peer_group_id); +} + +static void setup(void) +{ + struct ltp_statx sx; + + /* create DIR_A / DIR_C structure with DIR_C mounted */ + SAFE_MKDIR(DIR_A, 0700); + SAFE_MOUNT(DIR_A, DIR_A, "none", MS_BIND, NULL); + SAFE_MOUNT("none", DIR_A, "none", MS_SHARED, NULL); + + SAFE_MKDIR(DIR_C, 0700); + SAFE_MOUNT(DIR_C, DIR_C, "none", MS_BIND, NULL); + SAFE_MOUNT("none", DIR_C, "none", MS_SHARED, NULL); + + /* DIR_A mounts into DIR_B. DIR_D is propagated */ + SAFE_MKDIR(DIR_B, 0700); + SAFE_MOUNT(DIR_A, DIR_B, "none", MS_BIND, NULL); + SAFE_MOUNT("none", DIR_B, "none", MS_SLAVE, NULL); + + SAFE_STATX(AT_FDCWD, DIR_D, 0, STATX_MNT_ID_UNIQUE, &sx); + dird_id = sx.data.stx_mnt_id; + + peer_group_id = read_peer_group(DIR_A); +} + +static void cleanup(void) +{ + if (tst_is_mounted(DIR_C)) + SAFE_UMOUNT(DIR_C); + + if (tst_is_mounted(DIR_B)) + SAFE_UMOUNT(DIR_B); + + if (tst_is_mounted(DIR_A)) + SAFE_UMOUNT(DIR_A); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .cleanup = cleanup, + .min_kver = "6.8", + .mount_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .skip_filesystems = (const char *const []) { + "fuse", + NULL + }, + .bufs = (struct tst_buffers []) { + {&st_mount, .size = sizeof(struct statmount)}, + {} + } +};