lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Thu, 18 Nov 2021 18:57:42 -0500 From: Gabriel Krisman Bertazi <krisman@...labora.com> To: pvorel@...e.cz, jack@...e.com, amir73il@...il.com, repnop@...gle.com Cc: linux-ext4@...r.kernel.org, kernel@...labora.com, khazhy@...gle.com, ltp@...ts.linux.it, Gabriel Krisman Bertazi <krisman@...labora.com> Subject: [PATCH v4 7/9] syscalls/fanotify22: Create a corrupted file 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 <amir73il@...il.com> Signed-off-by: Gabriel Krisman Bertazi <krisman@...labora.com> --- 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); -- 2.33.0
Powered by blists - more mailing lists