From: Paul Moore <pmoore@redhat.com>
To: Paul Osmialowski <p.osmialowsk@samsung.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Daniel Mack <daniel@zonque.org>,
David Herrmann <dh.herrmann@googlemail.com>,
Djalal Harouni <tixxdz@opendz.org>,
linux-kernel@vger.kernel.org,
Lukasz Pawelczyk <l.pawelczyk@samsung.com>
Subject: Re: [RFC] kdbus: use LSM hooks to restrict ability to send file descriptors
Date: Fri, 18 Sep 2015 10:14:20 -0400 [thread overview]
Message-ID: <6251998.tInjJR3Jq3@sifl> (raw)
In-Reply-To: <1442582823-7368-1-git-send-email-p.osmialowsk@samsung.com>
On Friday, September 18, 2015 03:27:03 PM Paul Osmialowski wrote:
> The goal of this patch is to reproduce on kdbus the same behavior
> that is expressed by Unix Domain Sockets when it comes to restricting
> ability to pass opened file descriptors.
>
> Signed-off-by: Paul Osmialowski <p.osmialowsk@samsung.com>
> ---
> ipc/kdbus/message.c | 22 ++++++++++++++++++----
> 1 file changed, 18 insertions(+), 4 deletions(-)
Hi Paul,
I've been reworking my original kdbus LSM/SELinux hooks in order to simplify
things and make them a bit more consistent with the binder and other IPC-esque
hooks, I'm hoping to post a RFC for them soon.
A few comments below ...
> diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c
> index ae565cd..b083431 100644
> --- a/ipc/kdbus/message.c
> +++ b/ipc/kdbus/message.c
> @@ -24,6 +24,7 @@
> #include <linux/sizes.h>
> #include <linux/slab.h>
> #include <linux/uaccess.h>
> +#include <linux/security.h>
> #include <net/sock.h>
>
> #include "bus.h"
> @@ -150,13 +151,19 @@ int kdbus_gaps_install(struct kdbus_gaps *gaps, struct
> kdbus_pool_slice *slice, for (i = 0; i < gaps->n_fds; ++i) {
> int fd;
>
> - fd = get_unused_fd_flags(O_CLOEXEC);
> - if (fd < 0)
> + if (gaps->fd_files[i] &&
> + security_file_receive(gaps->fd_files[i])) {
> incomplete_fds = true;
> + fds[n_fds++] = -1;
> + } else {
> + fd = get_unused_fd_flags(O_CLOEXEC);
> + if (fd < 0)
> + incomplete_fds = true;
My patch is a little different (no fd_files[i] validity check, diff if
structure, etc.) but the basic idea is the same.
> - WARN_ON(!gaps->fd_files[i]);
> + WARN_ON(!gaps->fd_files[i]);
You probably want to move this before the LSM hook.
> - fds[n_fds++] = fd < 0 ? -1 : fd;
> + fds[n_fds++] = fd < 0 ? -1 : fd;
> + }
> }
>
> /*
> @@ -178,6 +185,13 @@ int kdbus_gaps_install(struct kdbus_gaps *gaps, struct
> kdbus_pool_slice *slice, for (i = 0; i < gaps->n_memfds; ++i) {
> int memfd;
>
> + if (gaps->memfd_files[i] &&
> + security_file_receive(gaps->memfd_files[i])) {
> + incomplete_fds = true;
> + fds[n_fds++] = -1;
> + continue;
> + }
Similar to above, including the WARN_ON() movement.
> memfd = get_unused_fd_flags(O_CLOEXEC);
> if (memfd < 0) {
> incomplete_fds = true;
--
paul moore
security @ redhat
prev parent reply other threads:[~2015-09-18 14:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-18 13:27 [RFC] kdbus: use LSM hooks to restrict ability to send file descriptors Paul Osmialowski
2015-09-18 14:14 ` Paul Moore [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6251998.tInjJR3Jq3@sifl \
--to=pmoore@redhat.com \
--cc=daniel@zonque.org \
--cc=dh.herrmann@googlemail.com \
--cc=gregkh@linuxfoundation.org \
--cc=l.pawelczyk@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=p.osmialowsk@samsung.com \
--cc=tixxdz@opendz.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox