Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1949630pxy; Mon, 2 Aug 2021 14:49:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkbUDEiobz3Gm2uBBuAmaCKM8eInTaoBAx9q+OKXhrtvNJidP0sx4VPw2CqDxG0feUY/Z+ X-Received: by 2002:a92:dac9:: with SMTP id o9mr1312305ilq.124.1627940967825; Mon, 02 Aug 2021 14:49:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627940967; cv=none; d=google.com; s=arc-20160816; b=iE54ef0OGGyyc77vE709DZKAnGh/GtsSgJEIIOe34X6ds9Mt8mdFn+dRlVJbQ7Jrj4 Wqnp+RAB42uOZ4bMC844rs3a98h40LLDl+HrNl+uXRuRq3lpKk0yN8Tth4i2K9kI32t3 JlW1R4pL6wRRJv/UXLoLYUX0g2a+0REDcfnFqtUH+/Ct0RApkNgUgv/TdZRPLA7vgWw6 wXM6DOdNJIR9/BPOHE1Js0b0OG7YB2JwBv/5zRpPcR0AVqaPy5XLvKlR1NIoTK9Wrkk7 p6fR66aB5tldwZ5C03lVx/UidZ8f2VLB0XYnNsaPnXNMmAG+Lu3/EzdEyCvasKAX3FaI 3gIA== 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=Do7t4QmYjjAHrUpUKXr/m+o67GBcwQccFpXU+lOETvY=; b=ffC/Zxo/5ZIleseQRZuWN72/jTjS9QUy275LuNJi4Nf0UCB+xMG7IwYxFf4MqE9n9p p7JfVA6d84uYDx8WcG+8e3qwA0mBOo1X4qDRMbIO2vcyQdIQZmYcttKxIXh/z81vcFo1 5RR+L+4AGNHc8E3YO2xiJ1DaJEI/pbFJnkxv40IukMQp6TKnFz7sLbR2pqxARu/m/pY0 2HG+DVnYdNt8DM2W6gfN6IKc+XWoW2aQS/Cj7iFUOt/HVWuBzYHm1jlobYrM6Akg0/Sx 2aCiutkZ9dF86evS2AMgQsvFXH5LAcb3+iAjj4qJai9tz0ROIw1QV+Ws5osD21D1jJZr TQPA== 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 v66si6440505iof.105.2021.08.02.14.49.15; Mon, 02 Aug 2021 14:49:27 -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 S229567AbhHBVre (ORCPT + 99 others); Mon, 2 Aug 2021 17:47:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231814AbhHBVrd (ORCPT ); Mon, 2 Aug 2021 17:47:33 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2991FC061764 for ; Mon, 2 Aug 2021 14:47:21 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id C78EC1F42CCA From: Gabriel Krisman Bertazi To: ltp@lists.linux.it, jack@suse.com, amir73il@gmail.com Cc: linux-ext4@vger.kernel.org, khazhy@google.com, kernel@collabora.com, Gabriel Krisman Bertazi Subject: [PATCH 6/7] syscalls/fanotify20: Test file event with broken inode Date: Mon, 2 Aug 2021 17:46:44 -0400 Message-Id: <20210802214645.2633028-7-krisman@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802214645.2633028-1-krisman@collabora.com> References: <20210802214645.2633028-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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. Signed-off-by: Gabriel Krisman Bertazi --- .../kernel/syscalls/fanotify/fanotify20.c | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/testcases/kernel/syscalls/fanotify/fanotify20.c b/testcases/kernel/syscalls/fanotify/fanotify20.c index e7ced28eb61d..0c63e90edc3a 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify20.c +++ b/testcases/kernel/syscalls/fanotify/fanotify20.c @@ -76,6 +76,36 @@ static void trigger_fs_abort(void) MS_REMOUNT|MS_RDONLY, "abort"); } +#define TCASE2_BASEDIR "tcase2" +#define TCASE2_BAD_DIR TCASE2_BASEDIR"/bad_dir" + +static unsigned int tcase2_bad_ino; +static void tcase2_prepare_fs(void) +{ + struct stat stat; + + SAFE_MKDIR(MOUNT_PATH"/"TCASE2_BASEDIR, 0777); + SAFE_MKDIR(MOUNT_PATH"/"TCASE2_BAD_DIR, 0777); + + SAFE_STAT(MOUNT_PATH"/"TCASE2_BAD_DIR, &stat); + tcase2_bad_ino = stat.st_ino; + + SAFE_UMOUNT(MOUNT_PATH); + do_debugfs_request(tst_device->dev, "sif " TCASE2_BAD_DIR " mode 0xff"); + SAFE_MOUNT(tst_device->dev, MOUNT_PATH, tst_device->fs_type, 0, 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"/"TCASE2_BAD_DIR, O_RDONLY, 0); + if (ret != -1 && errno != EUCLEAN) + tst_res(TFAIL, "Unexpected lookup result(%d) of %s (%d!=%d)", + ret, TCASE2_BAD_DIR, errno, EUCLEAN); +} + static const struct test_case { char *name; int error; @@ -92,6 +122,14 @@ static const struct test_case { .error_count = 1, .error = EXT4_ERR_ESHUTDOWN, .inode = NULL + }, + { + .name = "Lookup of inode with invalid mode", + .prepare_fs = tcase2_prepare_fs, + .trigger_error = &tcase2_trigger_lookup, + .error_count = 1, + .error = 0, + .inode = &tcase2_bad_ino, } }; -- 2.32.0