[PATCH v3 4/5] kcmp: add KCMP_FILE_PRIVATE_DATA
From: Tycho Andersen <hidden>
Date: 2015-09-30 18:15:27
Also in:
linux-api, lkml
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Tycho Andersen <hidden>
Date: 2015-09-30 18:15:27
Also in:
linux-api, lkml
Subsystem:
the rest · Maintainer:
Linus Torvalds
This command allows comparing the underling private data of two fds. This is useful e.g. to find out if a seccomp filter is inherited, since struct seccomp_filter are unique across tasks and are the private_data seccomp fds. Signed-off-by: Tycho Andersen <redacted> CC: Kees Cook <redacted> CC: Will Drewry <wad@chromium.org> CC: Oleg Nesterov <oleg@redhat.com> CC: Andy Lutomirski <luto@amacapital.net> CC: Pavel Emelyanov <redacted> CC: Serge E. Hallyn <redacted> CC: Alexei Starovoitov <ast@kernel.org> CC: Daniel Borkmann <daniel@iogearbox.net> --- include/uapi/linux/kcmp.h | 1 + kernel/kcmp.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+)
diff --git a/include/uapi/linux/kcmp.h b/include/uapi/linux/kcmp.h
index 84df14b..ed389d2 100644
--- a/include/uapi/linux/kcmp.h
+++ b/include/uapi/linux/kcmp.h@@ -10,6 +10,7 @@ enum kcmp_type { KCMP_SIGHAND, KCMP_IO, KCMP_SYSVSEM, + KCMP_FILE_PRIVATE_DATA, KCMP_TYPES, };
diff --git a/kernel/kcmp.c b/kernel/kcmp.c
index 0aa69ea..9ae673b 100644
--- a/kernel/kcmp.c
+++ b/kernel/kcmp.c@@ -165,6 +165,20 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type, ret = -EOPNOTSUPP; #endif break; + case KCMP_FILE_PRIVATE_DATA: { + struct file *filp1, *filp2; + + filp1 = get_file_raw_ptr(task1, idx1); + filp2 = get_file_raw_ptr(task2, idx2); + + if (filp1 && filp2) + ret = kcmp_ptr(filp1->private_data, + filp2->private_data, + KCMP_FILE_PRIVATE_DATA); + else + ret = -EBADF; + break; + } default: ret = -EINVAL; break;
--
2.5.0