From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org
Cc: Christoph Hellwig <hch@infradead.org>,
Mateusz Guzik <mjguzik@gmail.com>,
Penglei Jiang <superman.xpt@gmail.com>,
Al Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
Jeff Layton <jlayton@kernel.org>,
Josef Bacik <josef@toxicpanda.com>,
syzbot+5d8e79d323a13aa0b248@syzkaller.appspotmail.com,
Christian Brauner <brauner@kernel.org>
Subject: [PATCH 6/9] selftests/filesystems: add first test for anonymous inodes
Date: Mon, 07 Apr 2025 11:54:20 +0200 [thread overview]
Message-ID: <20250407-work-anon_inode-v1-6-53a44c20d44e@kernel.org> (raw)
In-Reply-To: <20250407-work-anon_inode-v1-0-53a44c20d44e@kernel.org>
Test that anonymous inodes cannot be chown()ed.
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
tools/testing/selftests/filesystems/.gitignore | 1 +
tools/testing/selftests/filesystems/Makefile | 2 +-
.../selftests/filesystems/anon_inode_test.c | 26 ++++++++++++++++++++++
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/filesystems/.gitignore b/tools/testing/selftests/filesystems/.gitignore
index 828b66a10c63..7afa58e2bb20 100644
--- a/tools/testing/selftests/filesystems/.gitignore
+++ b/tools/testing/selftests/filesystems/.gitignore
@@ -2,3 +2,4 @@
dnotify_test
devpts_pts
file_stressor
+anon_inode_test
diff --git a/tools/testing/selftests/filesystems/Makefile b/tools/testing/selftests/filesystems/Makefile
index 66305fc34c60..b02326193fee 100644
--- a/tools/testing/selftests/filesystems/Makefile
+++ b/tools/testing/selftests/filesystems/Makefile
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
CFLAGS += $(KHDR_INCLUDES)
-TEST_GEN_PROGS := devpts_pts file_stressor
+TEST_GEN_PROGS := devpts_pts file_stressor anon_inode_test
TEST_GEN_PROGS_EXTENDED := dnotify_test
include ../lib.mk
diff --git a/tools/testing/selftests/filesystems/anon_inode_test.c b/tools/testing/selftests/filesystems/anon_inode_test.c
new file mode 100644
index 000000000000..f2cae8f1ccae
--- /dev/null
+++ b/tools/testing/selftests/filesystems/anon_inode_test.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+#define _GNU_SOURCE
+#define __SANE_USERSPACE_TYPES__
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/stat.h>
+
+#include "../kselftest_harness.h"
+#include "overlayfs/wrappers.h"
+
+TEST(anon_inode_no_chown)
+{
+ int fd_context;
+
+ fd_context = sys_fsopen("tmpfs", 0);
+ ASSERT_GE(fd_context, 0);
+
+ ASSERT_LT(fchown(fd_context, 1234, 5678), 0);
+ ASSERT_EQ(errno, EOPNOTSUPP);
+
+ EXPECT_EQ(close(fd_context), 0);
+}
+
+TEST_HARNESS_MAIN
+
--
2.47.2
next prev parent reply other threads:[~2025-04-07 9:54 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 9:54 [PATCH 0/9] fs: harden anon inodes Christian Brauner
2025-04-07 9:54 ` [PATCH 1/9] anon_inode: use a proper mode internally Christian Brauner
2025-04-07 12:19 ` Jeff Layton
2025-04-07 13:43 ` Christian Brauner
2025-04-07 14:04 ` Jan Kara
2025-04-11 10:31 ` Mark Brown
2025-04-11 15:03 ` Christian Brauner
2025-04-14 5:50 ` Christoph Hellwig
2025-04-18 2:15 ` Xilin Wu
2025-04-20 10:54 ` Christian Brauner
2025-04-21 8:35 ` Christian Brauner
2025-04-07 9:54 ` [PATCH 2/9] pidfs: use anon_inode_getattr() Christian Brauner
2025-04-07 14:04 ` Jan Kara
2025-04-07 9:54 ` [PATCH 3/9] anon_inode: explicitly block ->setattr() Christian Brauner
2025-04-07 14:05 ` Jan Kara
2025-04-07 9:54 ` [PATCH 4/9] pidfs: use anon_inode_setattr() Christian Brauner
2025-04-07 14:06 ` Jan Kara
2025-04-07 9:54 ` [PATCH 5/9] anon_inode: raise SB_I_NODEV and SB_I_NOEXEC Christian Brauner
2025-04-07 14:07 ` Jan Kara
2025-04-07 14:18 ` Christian Brauner
2025-04-07 9:54 ` Christian Brauner [this message]
2025-04-07 14:09 ` [PATCH 6/9] selftests/filesystems: add first test for anonymous inodes Jan Kara
2025-04-07 9:54 ` [PATCH 7/9] selftests/filesystems: add second " Christian Brauner
2025-04-07 14:09 ` Jan Kara
2025-04-07 9:54 ` [PATCH 8/9] selftests/filesystems: add third " Christian Brauner
2025-04-07 14:09 ` Jan Kara
2025-04-07 9:54 ` [PATCH 9/9] selftests/filesystems: add fourth " Christian Brauner
2025-04-07 14:09 ` Jan Kara
2025-04-07 10:19 ` [PATCH 0/9] fs: harden anon inodes Mateusz Guzik
2025-04-07 13:41 ` Christian Brauner
2025-04-07 12:37 ` Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250407-work-anon_inode-v1-6-53a44c20d44e@kernel.org \
--to=brauner@kernel.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=superman.xpt@gmail.com \
--cc=syzbot+5d8e79d323a13aa0b248@syzkaller.appspotmail.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.