Skip to content

Commit 093fe10

Browse files
rgbriggsgregkh
authored andcommitted
audit: log 32-bit socketcalls
[ 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>
1 parent af37494 commit 093fe10

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
@@ -281,6 +281,20 @@ static inline int audit_socketcall(int nargs, unsigned long *args)
281281
return __audit_socketcall(nargs, args);
282282
return 0;
283283
}
284+
285+
static inline int audit_socketcall_compat(int nargs, u32 *args)
286+
{
287+
unsigned long a[AUDITSC_ARGS];
288+
int i;
289+
290+
if (audit_dummy_context())
291+
return 0;
292+
293+
for (i = 0; i < nargs; i++)
294+
a[i] = (unsigned long)args[i];
295+
return __audit_socketcall(nargs, a);
296+
}
297+
284298
static inline int audit_sockaddr(int len, void *addr)
285299
{
286300
if (unlikely(!audit_dummy_context()))
@@ -407,6 +421,12 @@ static inline int audit_socketcall(int nargs, unsigned long *args)
407421
{
408422
return 0;
409423
}
424+
425+
static inline int audit_socketcall_compat(int nargs, u32 *args)
426+
{
427+
return 0;
428+
}
429+
410430
static inline void audit_fd_pair(int fd1, int fd2)
411431
{ }
412432
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>
@@ -767,14 +768,24 @@ COMPAT_SYSCALL_DEFINE5(recvmmsg, int, fd, struct compat_mmsghdr __user *, mmsg,
767768

768769
COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
769770
{
770-
int ret;
771-
u32 a[6];
771+
u32 a[AUDITSC_ARGS];
772+
unsigned int len;
772773
u32 a0, a1;
774+
int ret;
773775

774776
if (call < SYS_SOCKET || call > SYS_SENDMMSG)
775777
return -EINVAL;
776-
if (copy_from_user(a, args, nas[call]))
778+
len = nas[call];
779+
if (len > sizeof(a))
780+
return -EINVAL;
781+
782+
if (copy_from_user(a, args, len))
777783
return -EFAULT;
784+
785+
ret = audit_socketcall_compat(len / sizeof(a[0]), a);
786+
if (ret)
787+
return ret;
788+
778789
a0 = a[0];
779790
a1 = a[1];
780791

0 commit comments

Comments
 (0)