From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tycho Andersen Subject: [PATCH v3 4/5] kcmp: add KCMP_FILE_PRIVATE_DATA Date: Wed, 30 Sep 2015 12:13:39 -0600 Message-ID: <1443636820-17083-5-git-send-email-tycho.andersen@canonical.com> References: <1443636820-17083-1-git-send-email-tycho.andersen@canonical.com> Return-path: In-Reply-To: <1443636820-17083-1-git-send-email-tycho.andersen@canonical.com> Sender: netdev-owner@vger.kernel.org To: Kees Cook , Alexei Starovoitov Cc: Will Drewry , Oleg Nesterov , Andy Lutomirski , Pavel Emelyanov , "Serge E. Hallyn" , Daniel Borkmann , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-api@vger.kernel.org, Tycho Andersen List-Id: linux-api@vger.kernel.org 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 CC: Kees Cook CC: Will Drewry CC: Oleg Nesterov CC: Andy Lutomirski CC: Pavel Emelyanov CC: Serge E. Hallyn CC: Alexei Starovoitov CC: Daniel Borkmann --- 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