Fix NULL pointer dereference in futex_wake_op() in case when the same

address specified for arguments uaddr and uaddr2.

PR:		218987
Reported by:	luke.tw gmail
MFC after:	1 week
This commit is contained in:
Dmitry Chagin 2017-05-01 12:25:37 +00:00
parent 52f72bfa66
commit 2ca5d34d20

View File

@ -952,6 +952,11 @@ linux_sys_futex(struct thread *td, struct linux_sys_futex_args *args)
args->uaddr, args->val, args->uaddr2, args->val3,
args->timeout);
if (args->uaddr == args->uaddr2) {
LIN_SDT_PROBE1(futex, linux_sys_futex, return, EINVAL);
return (EINVAL);
}
retry2:
error = futex_get(args->uaddr, NULL, &f, flags | FUTEX_DONTLOCK);
if (error) {
@ -959,9 +964,7 @@ linux_sys_futex(struct thread *td, struct linux_sys_futex_args *args)
return (error);
}
if (args->uaddr != args->uaddr2)
error = futex_get(args->uaddr2, NULL, &f2,
flags | FUTEX_DONTLOCK);
error = futex_get(args->uaddr2, NULL, &f2, flags | FUTEX_DONTLOCK);
if (error) {
futex_put(f, NULL);