]> git.baikalelectronics.ru Git - kernel.git/commit
dm: fix dropped return code from dm_get_bdev_for_ioctl
authorMike Snitzer <snitzer@redhat.com>
Fri, 30 Mar 2018 03:31:32 +0000 (23:31 -0400)
committerMike Snitzer <snitzer@redhat.com>
Fri, 30 Mar 2018 03:31:32 +0000 (23:31 -0400)
commit2c8a77061d022f08dc9229305015635e2f47e95d
tree6dacbd021d8c2d9f494aab81ee8a095fc22664ea
parentf2731d25fea93ab3ced03904d552ca4dac76b125
dm: fix dropped return code from dm_get_bdev_for_ioctl

dm_get_bdev_for_ioctl()'s return of 0 or 1 must be the result from
prepare_ioctl (1 means the ioctl was issued to a partition, 0 means it
wasn't).  Unfortunately commit e33ac80c68 ("dm: use blkdev_get rather
than bdgrab when issuing pass-through ioctl") reused the variable 'r'
to store the return from blkdev_get() that follows prepare_ioctl()
-- whereby dropping prepare_ioctl()'s result on the floor.

This can lead to an ioctl or persistent reservation being issued to a
partition going unnoticed, which implies the extra permission check for
CAP_SYS_RAWIO is skipped.

Fix this by using a different variable to store blkdev_get()'s return.

Fixes: e33ac80c68 ("dm: use blkdev_get rather than bdgrab when issuing pass-through ioctl")
Reported-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm.c