]> git.ipfire.org Git - thirdparty/linux.git/commit
ublk: enforce ublks_max only for unprivileged devices
authorUday Shankar <ushankar@purestorage.com>
Sat, 1 Mar 2025 04:31:48 +0000 (21:31 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 4 Mar 2025 15:51:37 +0000 (08:51 -0700)
commit80bdfbb3545b6f16680a72c825063d08a6b44c7a
tree27ad9b0aaa1149cd66031035a24c266453bb2a87
parent3aab938c93ca952ebc96c85b753f2592de919369
ublk: enforce ublks_max only for unprivileged devices

Commit 403ebc877832 ("ublk_drv: add module parameter of ublks_max for
limiting max allowed ublk dev"), claimed ublks_max was added to prevent
a DoS situation with an untrusted user creating too many ublk devices.
If that's the case, ublks_max should only restrict the number of
unprivileged ublk devices in the system. Enforce the limit only for
unprivileged ublk devices, and rename variables accordingly. Leave the
external-facing parameter name unchanged, since changing it may break
systems which use it (but still update its documentation to reflect its
new meaning).

As a result of this change, in a system where there are only normal
(non-unprivileged) devices, the maximum number of such devices is
increased to 1 << MINORBITS, or 1048576. That ought to be enough for
anyone, right?

Signed-off-by: Uday Shankar <ushankar@purestorage.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250228-ublks_max-v1-1-04b7379190c0@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c