[valgrind] [Bug 343099] Linux setns syscall wrapper missing, unhandled syscall: 308

2018-01-17 Thread spacewanderlzx
https://bugs.kde.org/show_bug.cgi?id=343099

spacewander...@gmail.com  changed:

   What|Removed |Added

 CC||spacewander...@gmail.com

--- Comment #5 from spacewander...@gmail.com  ---
Any news here? I am looking forward to seeing this patch could be accepted
officially.

-- 
You are receiving this mail because:
You are watching all bug changes.

[valgrind] [Bug 388786] Support bpf syscall in amd64 Linux

2018-01-10 Thread spacewanderlzx
https://bugs.kde.org/show_bug.cgi?id=388786

spacewander...@gmail.com  changed:

   What|Removed |Added

 CC||spacewander...@gmail.com

-- 
You are receiving this mail because:
You are watching all bug changes.

[valgrind] [Bug 388786] New: Support bpf syscall in amd64 Linux

2018-01-10 Thread spacewanderlzx
https://bugs.kde.org/show_bug.cgi?id=388786

Bug ID: 388786
   Summary: Support bpf syscall in amd64 Linux
   Product: valgrind
   Version: 3.14 SVN
  Platform: unspecified
OS: Linux
Status: UNCONFIRMED
  Severity: task
  Priority: NOR
 Component: memcheck
  Assignee: jsew...@acm.org
  Reporter: spacewander...@gmail.com
  Target Milestone: ---

Created attachment 109783
  --> https://bugs.kde.org/attachment.cgi?id=109783=edit
Tha patch for supporting bpf syscall in amd64 Linux

Hi everyone.
I just wrote a patch to support bpf syscall in amd64 Linux, following
this guide: http://valgrind.org/docs/manual/dist.readme-missing.html
It is my first time to hack valgrind, please let me know if I made any mistake.
I am glad to see this patch could be reviewed and accepted.
Thanks!

diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c
b/coregrind/m_syswrap/syswrap-amd64-linux.c
index 14ad6499e..a75048397 100644
--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
@@ -201,6 +201,7 @@ DECL_TEMPLATE(amd64_linux, sys_arch_prctl);
 DECL_TEMPLATE(amd64_linux, sys_ptrace);
 DECL_TEMPLATE(amd64_linux, sys_fadvise64);
 DECL_TEMPLATE(amd64_linux, sys_mmap);
+DECL_TEMPLATE(amd64_linux, sys_bpf);
 DECL_TEMPLATE(amd64_linux, sys_syscall184);


@@ -401,6 +402,14 @@ PRE(sys_mmap)
SET_STATUS_from_SysRes(r);
 }

+PRE(sys_bpf)
+{
+
+   PRINT("sys_bpf ( %ld, %#lx, %lu )" , SARG1, ARG2, ARG3);
+   PRE_REG_READ3(int, "bpf",
+ int, cmd, union vki_bpf_attr *, attr, unsigned int, size);
+}
+

 /* ---
PRE/POST wrappers for AMD64/Linux-variant specific syscalls
@@ -839,10 +848,10 @@ static SyscallTableEntry syscall_table[] = {
LINX_(__NR_renameat2, sys_renameat2),// 316
 //   LIN__(__NR_seccomp,   sys_ni_syscall),   // 317
LINXY(__NR_getrandom, sys_getrandom),// 318
-   LINXY(__NR_memfd_create,  sys_memfd_create)  // 319
+   LINXY(__NR_memfd_create,  sys_memfd_create),  // 319

 //   LIN__(__NR_kexec_file_load,   sys_ni_syscall),   // 320
-//   LIN__(__NR_bpf,   sys_ni_syscall)// 321
+   PLAX_(__NR_bpf,   sys_bpf),  // 321
 };

 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/include/vki/vki-amd64-linux.h b/include/vki/vki-amd64-linux.h
index a506ade06..293c4edf0 100644
--- a/include/vki/vki-amd64-linux.h
+++ b/include/vki/vki-amd64-linux.h
@@ -48,6 +48,7 @@ typedef unsigned int __vki_u32;

 typedef __signed__ long long __vki_s64;
 typedef unsigned long long __vki_u64;
+typedef __vki_u64 __attribute__((aligned(8))) __vki_aligned_u64;

 typedef unsigned short vki_u16;

@@ -697,6 +698,86 @@ struct vki_shminfo64 {
 #define VKI_TIOCGSERIAL 0x541E
 #define VKI_TIOCSSERIAL 0x541F

+//--
+// From linux-4.14.13/include/uapi/linux/bpf.h
+//--
+
+union bpf_attr {
+struct { /* anonymous struct used by BPF_MAP_CREATE command */
+__vki_u32map_type;/* one of enum bpf_map_type */
+__vki_u32key_size;/* size of key in bytes */
+__vki_u32value_size;/* size of value in bytes */
+__vki_u32max_entries;/* max number of entries in a map */
+__vki_u32map_flags;/* BPF_MAP_CREATE related
+ * flags defined above.
+ */
+__vki_u32inner_map_fd;/* fd pointing to the inner map */
+__vki_u32numa_node;/* numa node (effective only if
+ * BPF_F_NUMA_NODE is set).
+ */
+};
+
+struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
+__vki_u32map_fd;
+__vki_aligned_u64key;
+union {
+__vki_aligned_u64 value;
+__vki_aligned_u64 next_key;
+};
+__vki_u64flags;
+};
+
+struct { /* anonymous struct used by BPF_PROG_LOAD command */
+__vki_u32prog_type;/* one of enum bpf_prog_type */
+__vki_u32insn_cnt;
+__vki_aligned_u64insns;
+__vki_aligned_u64license;
+__vki_u32log_level;/* verbosity level of verifier */
+__vki_u32log_size;/* size of user buffer */
+__vki_aligned_u64log_buf;/* user supplied buffer */
+__vki_u32kern_version;/* checked when
prog_type=kprobe */
+__vki_u32prog_flags;
+};
+
+struct { /* anonymous struct used by BPF_OBJ_* commands */
+__vki_aligned_u64pathname;
+__vki_u32bpf_fd;
+};
+
+struct { /* anonymous