Skip to content

Commit 62bc306

Browse files
rgbriggspcmoore
authored andcommitted
audit: log 32-bit socketcalls
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>
1 parent 92c82e8 commit 62bc306

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

‎include/linux/audit.h‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,20 @@ static inline int audit_socketcall(int nargs, unsigned long *args)
387387
return __audit_socketcall(nargs, args);
388388
return 0;
389389
}
390+
391+
static inline int audit_socketcall_compat(int nargs, u32 *args)
392+
{
393+
unsigned long a[AUDITSC_ARGS];
394+
int i;
395+
396+
if (audit_dummy_context())
397+
return 0;
398+
399+
for (i = 0; i < nargs; i++)
400+
a[i] = (unsigned long)args[i];
401+
return __audit_socketcall(nargs, a);
402+
}
403+
390404
static inline int audit_sockaddr(int len, void *addr)
391405
{
392406
if (unlikely(!audit_dummy_context()))
@@ -513,6 +527,12 @@ static inline int audit_socketcall(int nargs, unsigned long *args)
513527
{
514528
return 0;
515529
}
530+
531+
static inline int audit_socketcall_compat(int nargs, u32 *args)
532+
{
533+
return 0;
534+
}
535+
516536
static inline void audit_fd_pair(int fd1, int fd2)
517537
{ }
518538
static inline int audit_sockaddr(int len, void *addr)

‎net/compat.c‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/filter.h>
2323
#include <linux/compat.h>
2424
#include <linux/security.h>
25+
#include <linux/audit.h>
2526
#include <linux/export.h>
2627

2728
#include <net/scm.h>
@@ -781,14 +782,24 @@ COMPAT_SYSCALL_DEFINE5(recvmmsg, int, fd, struct compat_mmsghdr __user *, mmsg,
781782

782783
COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
783784
{
784-
int ret;
785-
u32 a[6];
785+
u32 a[AUDITSC_ARGS];
786+
unsigned int len;
786787
u32 a0, a1;
788+
int ret;
787789

788790
if (call < SYS_SOCKET || call > SYS_SENDMMSG)
789791
return -EINVAL;
790-
if (copy_from_user(a, args, nas[call]))
792+
len = nas[call];
793+
if (len > sizeof(a))
794+
return -EINVAL;
795+
796+
if (copy_from_user(a, args, len))
791797
return -EFAULT;
798+
799+
ret = audit_socketcall_compat(len / sizeof(a[0]), a);
800+
if (ret)
801+
return ret;
802+
792803
a0 = a[0];
793804
a1 = a[1];
794805

0 commit comments

Comments
 (0)