git: 7e8aeb42e488 - stable/13 - linux(4): Handle incorrect FUTEX_CLOCK_REALTIME option bit.

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Fri, 17 Jun 2022 19:37:49 UTC
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=7e8aeb42e4881b1ba39d92cf12fc646c63a0b832

commit 7e8aeb42e4881b1ba39d92cf12fc646c63a0b832
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2021-07-29 09:55:33 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:33:24 +0000

    linux(4): Handle incorrect FUTEX_CLOCK_REALTIME option bit.
    
    Return ENOSYS if the FUTEX_CLOCK_REALTIME option bit is specified for an
    inappropriate futex operation.
    
    MFC after:              2 weeks
    
    (cherry picked from commit 626cbd4648141929502b953111dc8a71d550c7e8)
---
 sys/compat/linux/linux_futex.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c
index fcac2eba4956..5f18c93b0988 100644
--- a/sys/compat/linux/linux_futex.c
+++ b/sys/compat/linux/linux_futex.c
@@ -224,6 +224,12 @@ linux_futex(struct thread *td, struct linux_futex_args *args)
 	args->clockrt = args->op & LINUX_FUTEX_CLOCK_REALTIME;
 	args->op = args->op & ~LINUX_FUTEX_CLOCK_REALTIME;
 
+	if (args->clockrt &&
+	    args->op != LINUX_FUTEX_WAIT_BITSET &&
+	    args->op != LINUX_FUTEX_WAIT_REQUEUE_PI &&
+	    args->op != LINUX_FUTEX_LOCK_PI2)
+		return (ENOSYS);
+
 	switch (args->op) {
 	case LINUX_FUTEX_WAIT:
 		args->val3 = FUTEX_BITSET_MATCH_ANY;