Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp511025pxb; Fri, 29 Oct 2021 14:20:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweZXdS8WEp6M2I0VGImIk8tKL1G8KVGtSnxUCRqX2r2K0aBHh20lIaBE5VN90KYXQoZLfF X-Received: by 2002:a17:907:3e14:: with SMTP id hp20mr17154811ejc.507.1635542406085; Fri, 29 Oct 2021 14:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635542406; cv=none; d=google.com; s=arc-20160816; b=kIBNdgzmp6h9zpJR38bFwdbS8v492I10YaAr3uicugtfDEk1zX2JFme3SYswvV+2JQ 5Ci+FpavmSA4nCQRnPR0M8owTMjbmM5gqfc4Gfm87K9Kt8kBWKZrUTgLrRcDS0t9N0rl MadNrtwOTfsBpTocLqEVw0unBfKdiV9Va9kq0gSkod33MsMAbvnsRUbTxBJBX5rC2zoa JO8HFf5g29zp/arrwp8Uy67FoKt7UY9oOlWfBm97BBISfCNiKpPUhvCLMlC6hrIE2Ep6 5JgKhBuX1UGPfddJTZGK872xwdEq9lS/3dpbMkyjrnr2bZk7vtnMOQd1rCVyK5pMqxLH ABrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=n/m396XwqJlTvYIpIGJZUUKUiyBNtjsE2WaCU9J1INE=; b=V3TrxZ8EBjtKqntOXJ1wGg+JqGK0mounQGDVvg6kVTLdjGx8U64tkOcAqYnNTZBfnN ezWFw89CmaUPrDcr+/YtnVfENlJWada2o5By6+1pT+Pp1jAFHUkiq4WWiGpfb8vA5IxL V09XPc4i2S9aWyyUyGiMv9XQywEe2PzJ/oRuf98FERPIwnhPC7rH30y1WDHOSBoK8Kj9 qGMKE0U/IeJyUrycrhwOsbvkpbX+7mnpB7Mg6AgtTI3wtiUG9g2HC01fmuU6fIrd+jhh gI8+Int1KbOeGzrr34EnsyyDQ3F5tIUPewrjCmtZAbpXMERKneTynheLjuqdk0YK08+u SJpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o2si13774358ejy.80.2021.10.29.14.19.42; Fri, 29 Oct 2021 14:20:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231515AbhJ2VVG (ORCPT + 99 others); Fri, 29 Oct 2021 17:21:06 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:58444 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231463AbhJ2VVF (ORCPT ); Fri, 29 Oct 2021 17:21:05 -0400 Received: from localhost (unknown [IPv6:2804:14c:124:8a08::1002]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: krisman) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 406171F45C6F; Fri, 29 Oct 2021 22:18:34 +0100 (BST) From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com, repnop@google.com Cc: ltp@lists.linux.it, khazhy@google.com, kernel@collabora.com, linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v3 7/9] syscalls/fanotify21: Create a corrupted file Date: Fri, 29 Oct 2021 18:17:30 -0300 Message-Id: <20211029211732.386127-8-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211029211732.386127-1-krisman@collabora.com> References: <20211029211732.386127-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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/fanotify21.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/testcases/kernel/syscalls/fanotify/fanotify21.c b/testcases/kernel/syscalls/fanotify/fanotify21.c index 43e606c27372..3e4ac2eb2e5b 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify21.c +++ b/testcases/kernel/syscalls/fanotify/fanotify21.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 @@ -216,6 +231,8 @@ static void setup(void) init_null_fid(); + pre_corrupt_fs(); + fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF|FAN_REPORT_FID, O_RDONLY); } -- 2.33.0