From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751404AbdAMJwc (ORCPT ); Fri, 13 Jan 2017 04:52:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33374 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751319AbdAMJwa (ORCPT ); Fri, 13 Jan 2017 04:52:30 -0500 From: Richard Guy Briggs To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-audit@redhat.com Cc: Richard Guy Briggs , Kangkook Jee , Eric Paris , Paul Moore , Steve Grubb Subject: [PATCH V2] audit: log 32-bit socketcalls Date: Fri, 13 Jan 2017 04:51:48 -0500 Message-Id: X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 13 Jan 2017 09:52:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- v2: Move work to audit_socketcall_compat() and use audit_dummy_context(). --- include/linux/audit.h | 16 ++++++++++++++++ net/compat.c | 15 +++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index 9d4443f..43d8003 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -387,6 +387,18 @@ 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) +{ + if (unlikely(!audit_dummy_context())) { + int i; + unsigned long a[AUDITSC_ARGS]; + + for (i=0; i #include #include +#include #include #include @@ -781,14 +782,24 @@ COMPAT_SYSCALL_DEFINE5(recvmmsg, int, fd, struct compat_mmsghdr __user *, mmsg, COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args) { + unsigned int len; int ret; - u32 a[6]; + u32 a[AUDITSC_ARGS]; u32 a0, a1; if (call < SYS_SOCKET || call > SYS_SENDMMSG) return -EINVAL; - if (copy_from_user(a, args, nas[call])) + len = nas[call]; + if (len > sizeof(a)) + return -EINVAL; + + if (copy_from_user(a, args, len)) return -EFAULT; + + ret = audit_socketcall_compat(len/sizeof(a[0]), a); + if (ret) + return ret; + a0 = a[0]; a1 = a[1]; -- 1.7.1