Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp512189pxb; Fri, 29 Oct 2021 14:21:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaUKp4BhpP2xG6Kn3O+KeYLF8jEQevIwEbLaJAeJ2grSf3vlGyB4BEnoC8UP7Qj06XhAh6 X-Received: by 2002:a17:907:3e14:: with SMTP id hp20mr17162729ejc.507.1635542493875; Fri, 29 Oct 2021 14:21:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635542493; cv=none; d=google.com; s=arc-20160816; b=OnrytTLMvmCEJobkUkgnLyH3PJKTYve4QaN1ssE//GQYkaGBroF4vPv6gSmdMEx8Jn AainVTn3pWyTuVsT+vFRXdOtNfVwh7h6vN2Ub6ZqLaTo6cocEF1VOIZlizPXkzoOqxnI +wjpbpostjrUA4pWdD9IkdljJYN5jINuuqa1fHV5XsxwIKu93l+KnWlxd29GagRvEp75 cKB3bl/AONR2jO8kkrY/8nJSaFuTC71XKTQD5XpS1FTPPfvCHy59YENTLY9FG/7ZvuTg 44db1lXtJ3UsayMOsF5Q7+PNx92OMNnS7StmSSO8kRJlDAdV83R+Q1wpKrJkaY7VQnhB FVjQ== 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=IOAcDKyyznscuv0dR1cHi+qWMIRUzoB0YhNMlub07kE=; b=YYssLuvqt4jK+4OuBo2llGO4O8cD32VCouv42GXJ7K7EgoSq/rNmsKA3/1hV5LMPUy 7Ga0lL++suPhDxR/7VKjYpwN4BR7+Hjgp/s4ybGFDPskEeIN1SFpBfgyJ5UcUvfWIntg D1Zb+nC/xCgsn5I92iq08mi5W4Gcu3NW8O6+OX7hmN1xFSd6DQQCgPtHo5haF80Gm3/n S3hq5p4zSBDSgGPAlVQVSLbR4IgVTUKl5R4rq8GiD67hgMZLHvCBCFnG0hA0IJqiy/8A 6ZTizf9cqnLd59wyBrHMEJYMYu34MQVB1/0+mIASC8RxUERORli9MaaoqBLb4iMV1G+H fZyw== 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.21.10; Fri, 29 Oct 2021 14:21:33 -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 S231579AbhJ2VVL (ORCPT + 99 others); Fri, 29 Oct 2021 17:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231463AbhJ2VVL (ORCPT ); Fri, 29 Oct 2021 17:21:11 -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 46ED4C061570 for ; Fri, 29 Oct 2021 14:18:42 -0700 (PDT) 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 ADE581F45C6F; Fri, 29 Oct 2021 22:18:40 +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 8/9] syscalls/fanotify21: Test file event with broken inode Date: Fri, 29 Oct 2021 18:17:31 -0300 Message-Id: <20211029211732.386127-9-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 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. Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- .../kernel/syscalls/fanotify/fanotify21.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/testcases/kernel/syscalls/fanotify/fanotify21.c b/testcases/kernel/syscalls/fanotify/fanotify21.c index 3e4ac2eb2e5b..e463365dd69d 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify21.c +++ b/testcases/kernel/syscalls/fanotify/fanotify21.c @@ -34,6 +34,10 @@ #ifdef HAVE_SYS_FANOTIFY_H #include "fanotify.h" +#ifndef EFSCORRUPTED +#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ +#endif + #define BUF_SIZE 256 static char event_buf[BUF_SIZE]; int fd_notify; @@ -59,6 +63,17 @@ static void do_debugfs_request(const char *dev, char *request) SAFE_CMD(cmd, NULL, 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"/"BAD_DIR, O_RDONLY, 0); + if (ret != -1 && errno != EUCLEAN) + tst_res(TFAIL, "Unexpected lookup result(%d) of %s (%d!=%d)", + ret, BAD_DIR, errno, EUCLEAN); +} + static struct test_case { char *name; int error; @@ -73,6 +88,13 @@ static struct test_case { .error = ESHUTDOWN, .fid = &null_fid, }, + { + .name = "Lookup of inode with invalid mode", + .trigger_error = &tcase2_trigger_lookup, + .error_count = 1, + .error = EFSCORRUPTED, + .fid = &bad_file_fid, + }, }; int check_error_event_info_fid(struct fanotify_event_info_fid *fid, -- 2.33.0