From: cgel.zte@gmail.com
To: rth@twiddle.net, ink@jurassic.park.msu.ru, mattst88@gmail.com,
paul@paul-moore.com, eparis@redhat.com, linux-audit@redhat.com
Cc: Yang Yang <yang.yang29@zte.com.cn>,
Zeal Robot <zealci@zte.com.cn>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2] audit: do a quick exit when syscall number is invalid
Date: Mon, 28 Mar 2022 05:46:42 +0000 [thread overview]
Message-ID: <20220328054641.2372974-1-yang.yang29@zte.com.cn> (raw)
From: Yang Yang <yang.yang29@zte.com.cn>
Userspace may use syscall with invalid syscall number by calling
syscall(syscall_num,..). For example we found openSSH may use
syscall with syscall number is -1 in some case. When that happens
we better do a quick handle no need to gohead.
Signed-off-by: Yang Yang <yang.yang29@zte.com.cn>
Reported-by: Zeal Robot <zealci@zte.com.cn>
---
v2:
- fix compile error of arch/alpha, I have no alpha compile environment, so this fix
- is done by code review.
---
arch/alpha/include/uapi/asm/unistd.h | 1 +
kernel/auditsc.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/alpha/include/uapi/asm/unistd.h b/arch/alpha/include/uapi/asm/unistd.h
index 71fd5db06866..8115062216e4 100644
--- a/arch/alpha/include/uapi/asm/unistd.h
+++ b/arch/alpha/include/uapi/asm/unistd.h
@@ -13,5 +13,6 @@
#define __NR_getgid __NR_getxgid
#include <asm/unistd_32.h>
+#include <asm-generic/unistd.h>
#endif /* _UAPI_ALPHA_UNISTD_H */
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index ea2ee1181921..ea4915999e01 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -2077,7 +2077,8 @@ void __audit_syscall_exit(int success, long return_code)
struct audit_context *context = audit_context();
if (!context || context->dummy ||
- context->context != AUDIT_CTX_SYSCALL)
+ context->context != AUDIT_CTX_SYSCALL ||
+ unlikely(context->major < 0 || context->major >= NR_syscalls))
goto out;
/* this may generate CONFIG_CHANGE records */
--
2.25.1
--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit
next reply other threads:[~2022-03-28 13:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 5:46 cgel.zte [this message]
2022-03-28 15:19 ` [PATCH v2] audit: do a quick exit when syscall number is invalid kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220328054641.2372974-1-yang.yang29@zte.com.cn \
--to=cgel.zte@gmail.com \
--cc=eparis@redhat.com \
--cc=ink@jurassic.park.msu.ru \
--cc=linux-audit@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mattst88@gmail.com \
--cc=paul@paul-moore.com \
--cc=rth@twiddle.net \
--cc=yang.yang29@zte.com.cn \
--cc=zealci@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).