]> granicus.if.org Git - strace/blobdiff - seccomp.c
Robustify mpers.awk against invalid input
[strace] / seccomp.c
index 4c176a787718207f45a877dbb00f099bab7b68bb..71cda7d654334ee2cb4ab449aeac00137cec5731 100644 (file)
--- a/seccomp.c
+++ b/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;
-
-               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
+       struct seccomp_fprog fprog;
+
+       if (fetch_seccomp_fprog(tcp, addr, &fprog))
+               decode_fprog(tcp, fprog.len, fprog.filter);
 }
 
 static void
@@ -225,21 +210,20 @@ decode_seccomp_set_mode_strict(unsigned int flags, unsigned long addr)
 
 SYS_FUNC(seccomp)
 {
-       if (entering(tcp)) {
-               unsigned int op = tcp->u_arg[0];
+       unsigned int op = tcp->u_arg[0];
 
-               printxval(seccomp_ops, op, "SECCOMP_SET_MODE_???");
-               tprints(", ");
+       printxval(seccomp_ops, op, "SECCOMP_SET_MODE_???");
+       tprints(", ");
 
-               if (op == SECCOMP_SET_MODE_FILTER) {
-                       printflags(seccomp_filter_flags, tcp->u_arg[1],
-                                  "SECCOMP_FILTER_FLAG_???");
-                       tprints(", ");
-                       print_seccomp_filter(tcp, tcp->u_arg[2]);
-               } else {
-                       decode_seccomp_set_mode_strict(tcp->u_arg[1],
-                                                      tcp->u_arg[2]);
-               }
+       if (op == SECCOMP_SET_MODE_FILTER) {
+               printflags(seccomp_filter_flags, tcp->u_arg[1],
+                          "SECCOMP_FILTER_FLAG_???");
+               tprints(", ");
+               print_seccomp_filter(tcp, tcp->u_arg[2]);
+       } else {
+               decode_seccomp_set_mode_strict(tcp->u_arg[1],
+                                              tcp->u_arg[2]);
        }
-       return 0;
+
+       return RVAL_DECODED;
 }