Return-Path: Received: from omzsmtpe03.verizonbusiness.com ([199.249.25.208]:28750 "EHLO omzsmtpe03.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752104AbdITEqy (ORCPT ); Wed, 20 Sep 2017 00:46:54 -0400 From: "Levin, Alexander (Sasha Levin)" Cc: Richard Guy Briggs , Paul Moore , "Levin, Alexander (Sasha Levin)" To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH review for 3.18 17/30] audit: log 32-bit socketcalls Date: Wed, 20 Sep 2017 04:45:54 +0000 Message-ID: <20170920044542.7571-17-alexander.levin@verizon.com> References: <20170920044542.7571-1-alexander.levin@verizon.com> In-Reply-To: <20170920044542.7571-1-alexander.levin@verizon.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Richard Guy Briggs [ Upstream commit 62bc306e2083436675e33b5bdeb6a77907d35971 ] 32-bit socketcalls were not being logged by audit on x86_64 systems. Log them. This is basically a duplicate of the call from net/socket.c:sys_socketcall(), but it addresses the impedance mismatch between 32-bit userspace process and 64-bit kernel audit. See: https://github.com/linux-audit/audit-kernel/issues/14 Signed-off-by: Richard Guy Briggs Acked-by: David S. Miller Signed-off-by: Paul Moore Signed-off-by: Sasha Levin --- include/linux/audit.h | 20 ++++++++++++++++++++ net/compat.c | 17 ++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index 10f155b7daf6..ba78e12bef53 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -273,6 +273,20 @@ static inline int audit_socketcall(int nargs, unsigned= long *args) return __audit_socketcall(nargs, args); return 0; } + +static inline int audit_socketcall_compat(int nargs, u32 *args) +{ + unsigned long a[AUDITSC_ARGS]; + int i; + + if (audit_dummy_context()) + return 0; + + for (i =3D 0; i < nargs; i++) + a[i] =3D (unsigned long)args[i]; + return __audit_socketcall(nargs, a); +} + static inline int audit_sockaddr(int len, void *addr) { if (unlikely(!audit_dummy_context())) @@ -398,6 +412,12 @@ static inline int audit_socketcall(int nargs, unsigned= long *args) { return 0; } + +static inline int audit_socketcall_compat(int nargs, u32 *args) +{ + return 0; +} + static inline void audit_fd_pair(int fd1, int fd2) { } static inline int audit_sockaddr(int len, void *addr) diff --git a/net/compat.c b/net/compat.c index 53e933eb78b8..3bb039e92744 100644 --- a/net/compat.c +++ b/net/compat.c @@ -22,6 +22,7 @@ #include #include #include +#include #include =20 #include @@ -796,14 +797,24 @@ COMPAT_SYSCALL_DEFINE5(recvmmsg, int, fd, struct comp= at_mmsghdr __user *, mmsg, =20 COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args) { - int ret; - u32 a[6]; + u32 a[AUDITSC_ARGS]; + unsigned int len; u32 a0, a1; + int ret; =20 if (call < SYS_SOCKET || call > SYS_SENDMMSG) return -EINVAL; - if (copy_from_user(a, args, nas[call])) + len =3D nas[call]; + if (len > sizeof(a)) + return -EINVAL; + + if (copy_from_user(a, args, len)) return -EFAULT; + + ret =3D audit_socketcall_compat(len / sizeof(a[0]), a); + if (ret) + return ret; + a0 =3D a[0]; a1 =3D a[1]; =20 --=20 2.11.0