Files
linux-cix/include/linux
Marco Elver 45eec49fa2 kcsan, seqlock: Fix incorrect assumption in read_seqbegin()
[ Upstream commit 183ec5f26b2fc97a4a9871865bfe9b33c41fddb2 ]

During testing of the preceding changes, I noticed that in some cases,
current->kcsan_ctx.in_flat_atomic remained true until task exit. This is
obviously wrong, because _all_ accesses for the given task will be
treated as atomic, resulting in false negatives i.e. missed data races.

Debugging led to fs/dcache.c, where we can see this usage of seqlock:

	struct dentry *d_lookup(const struct dentry *parent, const struct qstr *name)
	{
		struct dentry *dentry;
		unsigned seq;

		do {
			seq = read_seqbegin(&rename_lock);
			dentry = __d_lookup(parent, name);
			if (dentry)
				break;
		} while (read_seqretry(&rename_lock, seq));
	[...]

As can be seen, read_seqretry() is never called if dentry != NULL;
consequently, current->kcsan_ctx.in_flat_atomic will never be reset to
false by read_seqretry().

Give up on the wrong assumption of "assume closing read_seqretry()", and
rely on the already-present annotations in read_seqcount_begin/retry().

Fixes: 88ecd153be ("seqlock, kcsan: Add annotations for KCSAN")
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20241104161910.780003-6-elver@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-12-09 10:31:51 +01:00
..
2024-06-12 11:12:49 +02:00
2024-07-25 09:50:47 +02:00
2024-10-04 16:29:59 +02:00
2024-06-12 11:11:38 +02:00
2024-05-25 16:22:55 +02:00
2024-11-01 01:58:30 +01:00
2024-07-05 09:34:04 +02:00
2024-03-26 18:20:13 -04:00
2024-08-29 17:33:31 +02:00
2024-06-16 13:47:41 +02:00
2024-06-12 11:12:52 +02:00
2024-04-03 15:28:29 +02:00
2024-06-12 11:11:56 +02:00
2023-10-06 11:01:23 +02:00
2023-10-06 11:01:23 +02:00
2024-05-17 12:01:59 +02:00
2024-08-29 17:33:23 +02:00
2023-11-28 17:19:38 +00:00
2024-10-17 15:24:23 +02:00
2024-11-08 16:28:26 +01:00