From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f68.google.com (mail-dl1-f68.google.com [74.125.82.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 610E73B19B6 for ; Wed, 27 May 2026 19:51:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.68 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779911520; cv=none; b=E9UqWVmWEAyRfJcp1EgDR4kV0UgWoJR/NqMka2oG57TSoI2cMZzSL+VbWU5V2jFirEqeHg+zQ5ZRxHccaK71TevuJs4U5lRRGEmVmsy3dxtXOC+z8alhWoZw2R+8MciB89qULhkkh5AKMrPoDs64FR0pa8q8ivZR4hAZJF1o+7o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779911520; c=relaxed/simple; bh=kCl++7kVYFt/ccvpD4rkLQoby1VrrRSqMkxpEBLSpA8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qWoAQJTQy/HFidygP6MqD255Iar9exGxWLt3olLtg2/167YqCEnx/U4HWq+60TFpEX4JujKzSllFmvs0UyeXYKZUfm2cu0AH1NLNfSXDKDoFuV9dUyMfPZIRlnOK1HGOL+G3jhz5LcnibcTD274c+4eNcMWwgBaDRpraUlKXDOE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=c0tOkv30; arc=none smtp.client-ip=74.125.82.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c0tOkv30" Received: by mail-dl1-f68.google.com with SMTP id a92af1059eb24-137335bc3caso2993383c88.0 for ; Wed, 27 May 2026 12:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779911518; x=1780516318; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0Sp+s7C7f8D+jwwDxh0Y9qxUvL34f7v6oQb0ido5j04=; b=c0tOkv30dFFMOs8lQI7MqrKFPpuSGUHCXUY0W0d4Bzgc+Jvd/y3VR/qfrQF6Dxk3Nj XcueQNIxEDBPxc+v4abjlF1kFNAvJ5it/qCGT5vrs2rsSeki0LEGg3XJDxn2kWP4Qa0c r9aptGyWYN6aBYJ4OK5htdqYve3Z36WtnWzivYMp446V+GeT3dh7QpEZ0xAwlNkXtaK9 +B1ixPm8bRDPVtb3Ktbr5dkDJm7W4zOaLP8Mhp3kJw6r41/bsquLLktSV1AtX1YxR2UZ qWQ0Z/ePiAXANRPy3LszmpA+AowH3R/Pcqpn3SbpBjynXDVp+Vj3ecEx9KK3UsG8xjjO Dv1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779911518; x=1780516318; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0Sp+s7C7f8D+jwwDxh0Y9qxUvL34f7v6oQb0ido5j04=; b=AJVdvPl5Uq7pls+khnm1sNidvYGEeGUGT/Eu/mPH7SMkNrEWFzUEYmxFP/fcoxxdKz dvT/xI8xFHXyBd0Td0wgN6j4YSX9mDd9OGWRSi8vHjkA1g13ZgzUrtUQOXT9bAZ0HzpO /oQ0qdoiVnI8L0oQHgBbL/NFhFsZGKAwDLSRsc19urZoioo36LeIirY2b4PPCeFTA9Q7 uRLwBcNgmj/+oi7QB2wF2fLLzvWny15yvU2i+jJYCyktJVgRnDRJVpGnAMtxk8UYQ8iF QQHt80fU7QkcxPExf5qftEyJ+hXYOmUEVhJam9NOW+5nYDo7qn18m8qxP7DPBK7dKh3Q nQoQ== X-Forwarded-Encrypted: i=1; AFNElJ/S2qbE266A7/EpqRp6PgPsX6YSWltrUucRJiZ2aQVnASUyebUSkeVpixPwhe/wXJ6/LIVc11wn756wrPA=@vger.kernel.org X-Gm-Message-State: AOJu0YxGZvy4TZ2GFzhAbE+yVpUysOFxN6HAL8Bf/WqupH5eLfdXBBfw y2NSngbHKe3JWY3EfkFgtwAcibuN/pbCw1p+Ic/gzHmPHt/zaifGjnoD X-Gm-Gg: Acq92OH4XOxmGLo7LsVObcwMB2DKLQyZZdXyJfHfEnja5A+FFbFsn49oRK0ScHZEPNB pAhXs3L57ut70S9W8sAplBX1ni3dwDFEfinEfo5X4fJdWF/bxhTVEZt6zZkIt/rbbCGbahlYTvx rw8V4r+WjI31exJ9Dwq287dehPJqASsTgzDkQ/YxYhgMcU+zdlj9VLdwInzaI3r+0NwUf0hw/Tn kC+uwF8H16fuYhaqJlpssRW5KRs0QDLMnJnaODAYwSkWWMViBUmth0gDme4W6GjBZUu7tQ9LgkC 7EXzOZIGAK/IcG6mRnmKffQOdINm1LXM/7ZcGzX5DbLgz8ZY9TZrzGBeSJUysgr8Ho3A4EinVef z0BovcS1adNzz1bNMrJ6RV5vohKmQNX3AIkUngENdbFfosDRCSvh7qWzvz3gNLHBkVoUYOFrlq4 mMlRqLLdb609xDdWMlPFjD6duo5cHwxg== X-Received: by 2002:a05:7022:61a0:b0:133:3c47:92de with SMTP id a92af1059eb24-1365f812367mr9061282c88.17.1779911518387; Wed, 27 May 2026 12:51:58 -0700 (PDT) Received: from anonyme ([2605:52c0:2:2f27:be24:11ff:fe89:6f0f]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30451ef4719sm13705106eec.1.2026.05.27.12.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2026 12:51:58 -0700 (PDT) From: AnonymeMeow To: pvorel@suse.cz Cc: amir73il@gmail.com, jack@suse.cz, repnop@google.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, ltp@lists.linux.it, AnonymeMeow Subject: [PATCH v2 1/2] fanotify: fix crash when running multiple iterations Date: Thu, 28 May 2026 03:50:55 +0800 Message-ID: <20260527195056.337081-1-anonymemeow@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260527072312.GA231966@pevik> References: <20260527072312.GA231966@pevik> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This commit fixes ./fanotify13 -i10 crash by restoring the deleted objects every time a test finishes. This commit also fixes ./fanotify21 -i10 crash by remounting the read-only mount (if the mount is remounted read-only during the test) back to read-write every time a test finishes. Signed-off-by: AnonymeMeow --- On 2026-05-27 09:23:12+02:00, Petr Vorel wrote: > @AnonymeMeow nit: if you put whole conversation after --- (below), it will not > be part of the commit message when one applies the patch. And here should be a > proper commit message. Thank you for pointing this out, I will be more mindful the next time (this time). > Also I found that fanotify21.c on the current master fails when running more > than 1 iteration: Thanks for testing my patch, I didn't know that the standalone test binary supports the -i option to specify the number of iterations. Running multiple iterations through kirk's -i option seems to work fine. I then tested all fanotify tests with the -i option and found that fanotify13 also crashed when running multiple iterations. I fixed both fanotify13 and fanotify21 in this patch. So now all fanotify tests pass with the -i option. With Best Regards, AnonymeMeow --- .../kernel/syscalls/fanotify/fanotify13.c | 20 +++++++++++++++++++ .../kernel/syscalls/fanotify/fanotify21.c | 13 +++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c index 76d40eaf7..540e0b483 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify13.c +++ b/testcases/kernel/syscalls/fanotify/fanotify13.c @@ -137,6 +137,16 @@ static void delete_objects(void) } } +static void clean_upper_dir(void) +{ + unsigned int i; + + SAFE_MOUNT(OVL_UPPER, MOUNT_PATH, "none", MS_BIND, NULL); + for (i = 0; i < ARRAY_SIZE(objects); i++) + SAFE_UNLINK(objects[i].path); + SAFE_UMOUNT(MOUNT_PATH); +} + static void get_object_stats(void) { unsigned int i; @@ -340,6 +350,15 @@ static void do_test(unsigned int number) "Did not get an expected event (expected: %llx)", event_set[i].expected_mask); } + + if (tc->mask & FAN_DELETE_SELF) { + if (tst_variant & 1) { + clean_upper_dir(); + } else { + create_objects(); + get_object_stats(); + } + } out: SAFE_CLOSE(fanotify_fd); } @@ -417,6 +436,7 @@ static void do_cleanup(void) if (ovl_bind_mounted) SAFE_UMOUNT(MOUNT_PATH); if (bind_mounted) { + delete_objects(); SAFE_UMOUNT(MOUNT_PATH); SAFE_RMDIR(MOUNT_PATH); } diff --git a/testcases/kernel/syscalls/fanotify/fanotify21.c b/testcases/kernel/syscalls/fanotify/fanotify21.c index 340fb0018..2e3dbd4bd 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify21.c +++ b/testcases/kernel/syscalls/fanotify/fanotify21.c @@ -199,7 +199,7 @@ static void do_test(unsigned int num) if (len < 0) { if (tc->remount_ro && !fd_err && errno == EROFS) { tst_res(TPASS, "cannot read event with rw fd from a ro fs"); - return; + goto restore_rw_mount; } tst_brk(TBROK | TERRNO, "reading fanotify events failed"); } else if (tc->remount_ro && !fd_err) { @@ -346,6 +346,17 @@ next_event: if (event_pidfd_fdinfo) free(event_pidfd_fdinfo); } + +restore_rw_mount: + if (tc->remount_ro) { + /* SAFE_MOUNT fails to remount FUSE */ + if (mount(tst_device->dev, MOUNT_PATH, tst_device->fs_type, + MS_REMOUNT, NULL) != 0) { + tst_brk(TFAIL, + "filesystem %s failed to remount read-write", + tst_device->fs_type); + } + } } static void do_cleanup(void) -- 2.54.0