dlm: don't leak kernel pointer to userspace
authorTycho Andersen <tycho@tycho.ws>
Fri, 2 Nov 2018 20:18:22 +0000 (14:18 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 1 Dec 2019 08:17:28 +0000 (09:17 +0100)
commit5c2a3997ae5b7d14431eda830bfd0d4d727a7ec9
tree0bf6e8b83e2a06220a7aceadb0678f041f1f931f
parentafb4717ab81b5aca60cd9836788cb6e2e6a1bcba
dlm: don't leak kernel pointer to userspace

[ Upstream commit 9de30f3f7f4d31037cfbb7c787e1089c1944b3a7 ]

In copy_result_to_user(), we first create a struct dlm_lock_result, which
contains a struct dlm_lksb, the last member of which is a pointer to the
lvb. Unfortunately, we copy the entire struct dlm_lksb to the result
struct, which is then copied to userspace at the end of the function,
leaking the contents of sb_lvbptr, which is a valid kernel pointer in some
cases (indeed, later in the same function the data it points to is copied
to userspace).

It is an error to leak kernel pointers to userspace, as it undermines KASLR
protections (see e.g. 65eea8edc31 ("floppy: Do not copy a kernel pointer to
user memory in FDGETPRM ioctl") for another example of this).

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/dlm/user.c