]> git.baikalelectronics.ru Git - kernel.git/commit
dm ioctl: harden copy_params()'s copy_from_user() from malicious users
authorWenwen Wang <wang6495@umn.edu>
Wed, 3 Oct 2018 16:43:59 +0000 (11:43 -0500)
committerMike Snitzer <snitzer@redhat.com>
Thu, 18 Oct 2018 15:54:07 +0000 (11:54 -0400)
commit9f430765f9f7a9950f29e0da41930abb6b99c8ca
tree661f1c6576b6862811a74b5431500c1487943b2f
parentc9230dd4f0914df826c3f08fdcf8c5c78563643e
dm ioctl: harden copy_params()'s copy_from_user() from malicious users

In copy_params(), the struct 'dm_ioctl' is first copied from the user
space buffer 'user' to 'param_kernel' and the field 'data_size' is
checked against 'minimum_data_size' (size of 'struct dm_ioctl' payload
up to its 'data' member).  If the check fails, an error code EINVAL will be
returned.  Otherwise, param_kernel->data_size is used to do a second copy,
which copies from the same user-space buffer to 'dmi'.  After the second
copy, only 'dmi->data_size' is checked against 'param_kernel->data_size'.
Given that the buffer 'user' resides in the user space, a malicious
user-space process can race to change the content in the buffer between
the two copies.  This way, the attacker can inject inconsistent data
into 'dmi' (versus previously validated 'param_kernel').

Fix redundant copying of 'minimum_data_size' from user-space buffer by
using the first copy stored in 'param_kernel'.  Also remove the
'data_size' check after the second copy because it is now unnecessary.

Cc: stable@vger.kernel.org
Signed-off-by: Wenwen Wang <wang6495@umn.edu>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-ioctl.c