Convert parser of seccomp filter program to new mpers infrastructure
* seccomp_fprog.h: New file. * fetch_seccomp_fprog.c: New file. * Makefile.am (strace_SOURCES): Add them. * seccomp.c: Include "seccomp_fprog.h". (print_seccomp_filter): Use fetch_seccomp_fprog.
This commit is contained in:
parent
3b731941f3
commit
7a12974e95
@ -59,6 +59,7 @@ strace_SOURCES = \
|
||||
fallocate.c \
|
||||
fanotify.c \
|
||||
fchownat.c \
|
||||
fetch_seccomp_fprog.c \
|
||||
file.c \
|
||||
futex.c \
|
||||
get_robust_list.c \
|
||||
@ -123,6 +124,7 @@ strace_SOURCES = \
|
||||
sched.c \
|
||||
scsi.c \
|
||||
seccomp.c \
|
||||
seccomp_fprog.h \
|
||||
sendfile.c \
|
||||
sigaltstack.c \
|
||||
signal.c \
|
||||
|
24
fetch_seccomp_fprog.c
Normal file
24
fetch_seccomp_fprog.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include "defs.h"
|
||||
|
||||
#include DEF_MPERS_TYPE(seccomp_fprog_t)
|
||||
|
||||
#include "seccomp_fprog.h"
|
||||
typedef struct seccomp_fprog seccomp_fprog_t;
|
||||
|
||||
#include MPERS_DEFS
|
||||
|
||||
MPERS_PRINTER_DECL(bool, fetch_seccomp_fprog)(struct tcb *tcp, const long addr, void *p)
|
||||
{
|
||||
struct seccomp_fprog *pfp = p;
|
||||
seccomp_fprog_t mfp;
|
||||
|
||||
if (sizeof(*pfp) == sizeof(mfp))
|
||||
return !umove_or_printaddr(tcp, addr, pfp);
|
||||
|
||||
if (umove_or_printaddr(tcp, addr, &mfp))
|
||||
return false;
|
||||
|
||||
pfp->len = mfp.len;
|
||||
pfp->filter = mfp.filter;
|
||||
return true;
|
||||
}
|
25
seccomp.c
25
seccomp.c
@ -190,30 +190,15 @@ decode_fprog(struct tcb *tcp, unsigned short len, unsigned long addr)
|
||||
}
|
||||
}
|
||||
|
||||
#include "seccomp_fprog.h"
|
||||
|
||||
void
|
||||
print_seccomp_filter(struct tcb *tcp, unsigned long addr)
|
||||
{
|
||||
#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
|
||||
if (current_wordsize == 4) {
|
||||
struct {
|
||||
unsigned short len;
|
||||
uint32_t filter;
|
||||
} fprog;
|
||||
struct seccomp_fprog fprog;
|
||||
|
||||
if (!umove_or_printaddr(tcp, addr, &fprog))
|
||||
decode_fprog(tcp, fprog.len, fprog.filter);
|
||||
} else {
|
||||
#endif
|
||||
struct {
|
||||
unsigned short len;
|
||||
unsigned long filter;
|
||||
} fprog;
|
||||
|
||||
if (!umove_or_printaddr(tcp, addr, &fprog))
|
||||
decode_fprog(tcp, fprog.len, fprog.filter);
|
||||
#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
|
||||
}
|
||||
#endif
|
||||
if (fetch_seccomp_fprog(tcp, addr, &fprog))
|
||||
decode_fprog(tcp, fprog.len, fprog.filter);
|
||||
}
|
||||
|
||||
static void
|
||||
|
4
seccomp_fprog.h
Normal file
4
seccomp_fprog.h
Normal file
@ -0,0 +1,4 @@
|
||||
struct seccomp_fprog {
|
||||
unsigned short len;
|
||||
unsigned long filter;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user