Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2985030pxy; Tue, 3 Aug 2021 22:25:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzECykh1CLWwqu0b/v3L7JAAVPsPzOso5L1Uf/6l0+Pfrddn2iNaLlBtnkfBH7bLrpKHlPg X-Received: by 2002:a5e:8d16:: with SMTP id m22mr55481ioj.60.1628054747799; Tue, 03 Aug 2021 22:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628054747; cv=none; d=google.com; s=arc-20160816; b=nEuzFYKWWCuQ7DeYPOCQZdFJUDvCgMA7qqJwEgxTRE2h8L/IayAiciQB26566pJfTu rAkEWNtbuvgPZEGCZrPpYRacHc1gdO322MYaxJSIcIQ1TWczC9Sds+/kdmBrgBLaWfs0 XFsH+wcS03UuL1FKOUrnYFu8cEuPzktP+zy3sJ1QvE1jD4OK1YDXOVopMovk7eAD6oS8 qquludpwpvWFdiWNzrpUdrTLmju5keJWTz+O0DlteL3xGe24odI2LbU6C+Bz8GxjSDi4 CFoPw4+dH6dRiEg4oWCkb6UA0qgQ4npxPSwC+BgzK2LDDkkBAXn6pV/+w3FVOk1GJ/b9 N64w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:organization:subject:cc:to:from; bh=tvsAna3hn++gIrv0rC6Zy8SDxJ8/FMSrRjilXYHGYi0=; b=ARHXh1aVIIF+GJPNyNIp869lpPYyvopQhNXbsfzLar99X/LwBVdTQeL1zSdGxIW+hg jV20DquljkndK0Rv9JwFZJhDsAvbWJiBDf0srblzaD4b7h9EGwtom+TnBC+j1DaJf84P 4n6xu8TaRrSW1qaRPg9gsL7g/umco9sA3IFpgu1gDjzTZixKuNzzG4AC8YKW/OQbAYX9 3oKm2TK1i44EiK3LUb3YxqdBml8703DsXsPxh/XCtqhDNBDFBza9Rpo9SCO1wt08Ual+ RWAkuVj05i92D7CuTS/c1PMI4XYv93bOQtNUPzmYvYzqqlb+sbpxJWptHc7DNjPpYoRA 4xOw== 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 j14si1367188jat.60.2021.08.03.22.25.16; Tue, 03 Aug 2021 22:25:47 -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 S233595AbhHDExK (ORCPT + 99 others); Wed, 4 Aug 2021 00:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbhHDExK (ORCPT ); Wed, 4 Aug 2021 00:53:10 -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 1FF9FC0613D5 for ; Tue, 3 Aug 2021 21:52:58 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 8322C1F43565 From: Gabriel Krisman Bertazi To: Amir Goldstein Cc: LTP List , Jan Kara , Ext4 , Khazhismel Kumykov , kernel@collabora.com Subject: Re: [PATCH 6/7] syscalls/fanotify20: Test file event with broken inode Organization: Collabora References: <20210802214645.2633028-1-krisman@collabora.com> <20210802214645.2633028-7-krisman@collabora.com> Date: Wed, 04 Aug 2021 00:52:52 -0400 In-Reply-To: (Amir Goldstein's message of "Tue, 3 Aug 2021 12:08:11 +0300") Message-ID: <87k0l1hkuz.fsf@collabora.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Amir Goldstein writes: > On Tue, Aug 3, 2021 at 12:47 AM Gabriel Krisman Bertazi > wrote: >> >> 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, > > Why is error 0? > What's the rationale? Hi Amir, That is specific to Ext4. Some ext4 conditions report bogus error codes. I will come up with a kernel patch changing it. -- Gabriel Krisman Bertazi