Skip to content

Commit

Permalink
audit: log 32-bit socketcalls
Browse files Browse the repository at this point in the history
[ 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: linux-audit/audit-kernel#14

Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
rgbriggs authored and scafroglia93 committed Mar 10, 2018
1 parent f6532dc commit 0bc069b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
20 changes: 20 additions & 0 deletions include/linux/audit.h
Expand Up @@ -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 = 0; i < nargs; i++)
a[i] = (unsigned long)args[i];
return __audit_socketcall(nargs, a);
}

static inline int audit_sockaddr(int len, void *addr)
{
if (unlikely(!audit_dummy_context()))
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 14 additions & 3 deletions net/compat.c
Expand Up @@ -22,6 +22,7 @@
#include <linux/filter.h>
#include <linux/compat.h>
#include <linux/security.h>
#include <linux/audit.h>
#include <linux/export.h>

#include <net/scm.h>
Expand Down Expand Up @@ -796,14 +797,24 @@ COMPAT_SYSCALL_DEFINE5(recvmmsg, int, fd, struct compat_mmsghdr __user *, mmsg,

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;

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];

Expand Down

0 comments on commit 0bc069b

Please sign in to comment.