]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
revocable: fix SRCU index corruption by requiring caller-provided storage
authorTzung-Bi Shih <tzungbi@kernel.org>
Thu, 29 Jan 2026 14:37:32 +0000 (14:37 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Feb 2026 11:30:43 +0000 (12:30 +0100)
commit377563ce0653031de8d530e8b2f590d13349e29c
treeba01406c4590602c2406bdc6883e818e1cda3cea
parenta243f7fb11fe67c59c5df079384b123e58edb814
revocable: fix SRCU index corruption by requiring caller-provided storage

The struct revocable handle stores the SRCU read-side index (idx) for
the duration of a resource access.  If multiple threads share the same
struct revocable instance, they race on writing to the idx field,
corrupting the SRCU state and potentially causing unsafe unlocks.

Refactor the API to replace revocable_alloc()/revocable_free() with
revocable_init()/revocable_deinit().  This change requires the caller
to provide the storage for struct revocable.

By moving storage ownership to the caller, the API ensures that
concurrent users maintain their own private idx storage, eliminating
the race condition.

Reported-by: Johan Hovold <johan@kernel.org>
Closes: https://lore.kernel.org/all/20260124170535.11756-4-johan@kernel.org/
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/20260129143733.45618-4-tzungbi@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/driver-api/driver-model/revocable.rst
drivers/base/revocable.c
drivers/base/revocable_test.c
include/linux/revocable.h
tools/testing/selftests/drivers/base/revocable/test_modules/revocable_test.c