Skip to content

Commit 9de30f3

Browse files
tych0teigland
authored andcommitted
dlm: don't leak kernel pointer to userspace
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. 65eea8e ("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>
1 parent 3f0806d commit 9de30f3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎fs/dlm/user.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ static int copy_result_to_user(struct dlm_user_args *ua, int compat,
702702
result.version[0] = DLM_DEVICE_VERSION_MAJOR;
703703
result.version[1] = DLM_DEVICE_VERSION_MINOR;
704704
result.version[2] = DLM_DEVICE_VERSION_PATCH;
705-
memcpy(&result.lksb, &ua->lksb, sizeof(struct dlm_lksb));
705+
memcpy(&result.lksb, &ua->lksb, offsetof(struct dlm_lksb, sb_lvbptr));
706706
result.user_lksb = ua->user_lksb;
707707

708708
/* FIXME: dlm1 provides for the user's bastparam/addr to not be updated

0 commit comments

Comments
 (0)