From: Lukasz Pawelczyk <l.pawelczyk@samsung.com>
To: Paul Osmialowski <p.osmialowsk@samsung.com>,
Paul Moore <pmoore@redhat.com>,
James Morris <james.l.morris@oracle.com>,
Casey Schaufler <casey@schaufler-ca.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
Kees Cook <keescook@chromium.org>,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
Stephen Smalley <sds@tycho.nsa.gov>, Neil Brown <neilb@suse.de>,
Mark Rustad <mark.d.rustad@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Daniel Mack <daniel@zonque.org>,
David Herrmann <dh.herrmann@googlemail.com>,
Djalal Harouni <tixxdz@opendz.org>,
Shuah Khan <shuahkh@osg.samsung.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-api@vger.kernel.org
Cc: Karol Lewandowski <k.lewandowsk@samsung.com>,
Lukasz Skalski <l.skalski@samsung.com>
Subject: Re: [RFC 3/8] lsm: kdbus security hooks
Date: Wed, 08 Jul 2015 13:00:58 +0200 [thread overview]
Message-ID: <1436353258.2331.0.camel@samsung.com> (raw)
In-Reply-To: <1436351110-5902-4-git-send-email-p.osmialowsk@samsung.com>
On śro, 2015-07-08 at 12:25 +0200, Paul Osmialowski wrote:
> This is combination of the work by Karol Lewandowski and Paul Moore
> on LSM hooks for kdbus.
>
> Originates from:
>
> git://git.infradead.org/users/pcmoore/selinux (branch: working-kdbus)
> commit: 7050f206a79564886938d0edc4e1e9da5972c72d
>
> https://github.com/lmctl/linux.git (branch: kdbus-lsm-v4.for-systemd
> -v212)
> commit: a9fe4c33b6e5ab25a243e0590df406aabb6add12
>
> Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
> Signed-off-by: Paul Moore <pmoore@redhat.com>
> Signed-off-by: Paul Osmialowski <p.osmialowsk@samsung.com>
> ---
> include/linux/lsm_hooks.h | 67 ++++++++++++++++++++++++++
> include/linux/security.h | 99
> +++++++++++++++++++++++++++++++++++++++
> security/security.c | 117
> ++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 283 insertions(+)
>
> diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
> index 9429f05..2a8d8fc 100644
> --- a/include/linux/lsm_hooks.h
> +++ b/include/linux/lsm_hooks.h
> @@ -1297,6 +1297,36 @@
> * @inode we wish to get the security context of.
> * @ctx is a pointer in which to place the allocated security
> context.
> * @ctxlen points to the place to put the length of @ctx.
> + *
> + * @kdbus_domain_alloc:
> + * Allocate kdbus domain.
> + * @kdbus_domain_free:
> + * Deallocate kdbus domain.
> + * @kdbus_bus_alloc:
> + * Allocate kdbus bus.
> + * @kdbus_bus_free:
> + * Deallocate kdbus bus.
> + * @kdbus_send:
> + * Send message.
> + * @kdbus_recv:
> + * Receive message.
> + * @kdbus_name_acquire:
> + * Request a well-known bus name to associate with the
> connection.
> + * @kdbus_name_list:
> + * Retrieve the list of all currently registered well-known and
> unique
> + * names.
> + * @kdbus_ep_create:
> + * Endpoint create
> + * @kdbus_connect:
> + * Connect
> + * @kdbus_conn_free:
> + * Deallocate connection
> + * @kdbus_conn_info:
> + * Retrieve credentials and properties of the initial creator
> of the
> + * connection.
> + * @kdbus_talk:
> + * Talk to a given peer.
> + *
> * This is the main security structure.
> */
>
> @@ -1520,6 +1550,29 @@ union security_list_options {
> int (*inode_setsecctx)(struct dentry *dentry, void *ctx, u32
> ctxlen);
> int (*inode_getsecctx)(struct inode *inode, void **ctx, u32
> *ctxlen);
>
> + int (*kdbus_domain_alloc)(struct kdbus_domain *domain);
> + void (*kdbus_domain_free)(struct kdbus_domain *domain);
Shouldn't all of this be inside some #ifdef CONFIG_KDBUS (or whatever
the CONFIG for kdbus is)?
> +
> + int (*kdbus_bus_alloc)(struct kdbus_bus *bus);
> + void (*kdbus_bus_free)(struct kdbus_bus *bus);
> + int (*kdbus_send)(const struct kdbus_conn *conn,
> + const struct kdbus_bus *bus);
> + int (*kdbus_recv)(const struct kdbus_conn *conn,
> + const struct kdbus_bus *bus);
> + int (*kdbus_name_acquire)(const struct kdbus_conn *conn,
> + const char *name);
> + int (*kdbus_name_list)(const struct kdbus_bus *bus);
> +
> + int (*kdbus_ep_create)(const struct kdbus_bus *bus);
> + int (*kdbus_ep_setpolicy)(const struct kdbus_bus *bus);
> +
> + int (*kdbus_connect)(struct kdbus_conn *conn,
> + const char *secctx, u32 seclen);
> + void (*kdbus_conn_free)(struct kdbus_conn *conn);
> + int (*kdbus_conn_info)(const struct kdbus_conn *conn);
> + int (*kdbus_talk)(const struct kdbus_conn *src,
> + const struct kdbus_conn *dst);
> +
> #ifdef CONFIG_SECURITY_NETWORK
> int (*unix_stream_connect)(struct sock *sock, struct sock
> *other,
> struct sock *newsk);
> @@ -1760,6 +1813,20 @@ struct security_hook_heads {
> struct list_head inode_notifysecctx;
> struct list_head inode_setsecctx;
> struct list_head inode_getsecctx;
> + struct list_head kdbus_domain_alloc;
> + struct list_head kdbus_domain_free;
> + struct list_head kdbus_bus_alloc;
> + struct list_head kdbus_bus_free;
> + struct list_head kdbus_send;
> + struct list_head kdbus_recv;
> + struct list_head kdbus_name_acquire;
> + struct list_head kdbus_name_list;
> + struct list_head kdbus_ep_create;
> + struct list_head kdbus_ep_setpolicy;
> + struct list_head kdbus_connect;
> + struct list_head kdbus_conn_free;
> + struct list_head kdbus_conn_info;
> + struct list_head kdbus_talk;
> #ifdef CONFIG_SECURITY_NETWORK
> struct list_head unix_stream_connect;
> struct list_head unix_may_send;
> diff --git a/include/linux/security.h b/include/linux/security.h
> index 79d85dd..5f257b9 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -53,6 +53,10 @@ struct msg_queue;
> struct xattr;
> struct xfrm_sec_ctx;
> struct mm_struct;
> +struct kdbus_ep;
> +struct kdbus_bus;
> +struct kdbus_conn;
> +struct kdbus_domain;
>
> /* If capable should audit the security request */
> #define SECURITY_CAP_NOAUDIT 0
> @@ -356,6 +360,28 @@ void security_release_secctx(char *secdata, u32
> seclen);
> int security_inode_notifysecctx(struct inode *inode, void *ctx, u32
> ctxlen);
> int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32
> ctxlen);
> int security_inode_getsecctx(struct inode *inode, void **ctx, u32
> *ctxlen);
> +
> +int security_kdbus_domain_alloc(struct kdbus_domain *domain);
> +void security_kdbus_domain_free(struct kdbus_domain *domain);
> +
> +int security_kdbus_bus_alloc(struct kdbus_bus *bus);
> +void security_kdbus_bus_free(struct kdbus_bus *bus);
> +int security_kdbus_send(const struct kdbus_conn *conn,
> + const struct kdbus_bus *bus);
> +int security_kdbus_recv(const struct kdbus_conn *conn,
> + const struct kdbus_bus *bus);
> +int security_kdbus_name_acquire(const struct kdbus_conn *conn,
> + const char *name);
> +int security_kdbus_name_list(const struct kdbus_bus *bus);
> +int security_kdbus_ep_create(struct kdbus_bus *bus);
> +int security_kdbus_ep_setpolicy(struct kdbus_bus *bus);
> +int security_kdbus_connect(struct kdbus_conn *conn,
> + const char *secctx, u32 seclen);
> +void security_kdbus_conn_free(struct kdbus_conn *conn);
> +int security_kdbus_conn_info(const struct kdbus_conn *conn);
> +int security_kdbus_talk(const struct kdbus_conn *src,
> + const struct kdbus_conn *dst);
> +
> #else /* CONFIG_SECURITY */
> struct security_mnt_opts {
> };
> @@ -1105,6 +1131,79 @@ static inline int
> security_inode_getsecctx(struct inode *inode, void **ctx, u32
> {
> return -EOPNOTSUPP;
> }
> +
> +static inline int security_kdbus_domain_alloc(struct kdbus_domain
> *domain)
> +{
> + return 0;
> +}
> +
> +static inline void security_kdbus_domain_free(struct kdbus_domain
> *domain)
> +{
> +}
> +
> +static inline int security_kdbus_bus_alloc(struct kdbus_bus *bus)
> +{
> + return 0;
> +}
> +
> +static inline void security_kdbus_bus_free(struct kdbus_bus *bus)
> +{
> +}
> +
> +static inline int security_kdbus_send(const struct kdbus_conn *conn,
> + const struct kdbus_bus *bus)
> +{
> + return 0;
> +}
> +
> +static inline int security_kdbus_recv(const struct kdbus_conn *conn,
> + const struct kdbus_bus *bus)
> +{
> + return 0;
> +}
> +
> +static inline int security_kdbus_name_acquire(const struct
> kdbus_conn *conn,
> + const char *name)
> +{
> + return 0;
> +}
> +
> +static inline int security_kdbus_name_list(const struct kdbus_bus
> *bus)
> +{
> + return 0;
> +}
> +
> +static inline int security_kdbus_ep_create(const struct kdbus_bus
> *bus)
> +{
> + return 0;
> +}
> +
> +static inline int security_kdbus_ep_setpolicy(const struct kdbus_bus
> *bus)
> +{
> + return 0;
> +}
> +
> +static inline int security_kdbus_connect(struct kdbus_conn *conn,
> + const char *secctx, u32
> seclen)
> +{
> + return 0;
> +}
> +
> +static inline void security_kdbus_conn_free(struct kdbus_conn *conn)
> +{
> +}
> +
> +static inline int security_kdbus_conn_info(const struct kdbus_conn
> *conn)
> +{
> + return 0;
> +}
> +
> +static inline int security_kdbus_talk(const struct kdbus_conn *src,
> + const struct kdbus_conn *dst)
> +{
> + return 0;
> +}
> +
> #endif /* CONFIG_SECURITY */
>
> #ifdef CONFIG_SECURITY_NETWORK
> diff --git a/security/security.c b/security/security.c
> index b1e935b..7fb46d1 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -1185,6 +1185,95 @@ int security_inode_getsecctx(struct inode
> *inode, void **ctx, u32 *ctxlen)
> }
> EXPORT_SYMBOL(security_inode_getsecctx);
>
> +int security_kdbus_domain_alloc(struct kdbus_domain *domain)
> +{
> + return call_int_hook(kdbus_domain_alloc, 0, domain);
> +}
> +EXPORT_SYMBOL(security_kdbus_domain_alloc);
> +
> +void security_kdbus_domain_free(struct kdbus_domain *domain)
> +{
> + call_void_hook(kdbus_domain_free, domain);
> +}
> +EXPORT_SYMBOL(security_kdbus_domain_free);
> +
> +int security_kdbus_bus_alloc(struct kdbus_bus *bus)
> +{
> + return call_int_hook(kdbus_bus_alloc, 0, bus);
> +}
> +EXPORT_SYMBOL(security_kdbus_bus_alloc);
> +
> +void security_kdbus_bus_free(struct kdbus_bus *bus)
> +{
> + call_void_hook(kdbus_bus_free, bus);
> +}
> +EXPORT_SYMBOL(security_kdbus_bus_free);
> +
> +int security_kdbus_send(const struct kdbus_conn *conn,
> + const struct kdbus_bus *bus)
> +{
> + return call_int_hook(kdbus_send, 0, conn, bus);
> +}
> +EXPORT_SYMBOL(security_kdbus_send);
> +
> +int security_kdbus_recv(const struct kdbus_conn *conn,
> + const struct kdbus_bus *bus)
> +{
> + return call_int_hook(kdbus_recv, 0, conn, bus);
> +}
> +EXPORT_SYMBOL(security_kdbus_recv);
> +
> +int security_kdbus_name_acquire(const struct kdbus_conn *conn,
> + const char *name)
> +{
> + return call_int_hook(kdbus_name_acquire, 0, conn, name);
> +}
> +EXPORT_SYMBOL(security_kdbus_name_acquire);
> +
> +int security_kdbus_name_list(const struct kdbus_bus *bus)
> +{
> + return call_int_hook(kdbus_name_list, 0, bus);
> +}
> +EXPORT_SYMBOL(security_kdbus_name_list);
> +
> +int security_kdbus_ep_create(struct kdbus_bus *bus)
> +{
> + return call_int_hook(kdbus_ep_create, 0, bus);
> +}
> +EXPORT_SYMBOL(security_kdbus_ep_create);
> +
> +int security_kdbus_ep_setpolicy(struct kdbus_bus *bus)
> +{
> + return call_int_hook(kdbus_ep_setpolicy, 0, bus);
> +}
> +EXPORT_SYMBOL(security_kdbus_ep_setpolicy);
> +
> +int security_kdbus_connect(struct kdbus_conn *conn,
> + const char *secctx, u32 seclen)
> +{
> + return call_int_hook(kdbus_connect, 0, conn, secctx,
> seclen);
> +}
> +EXPORT_SYMBOL(security_kdbus_connect);
> +
> +void security_kdbus_conn_free(struct kdbus_conn *conn)
> +{
> + call_void_hook(kdbus_conn_free, conn);
> +}
> +EXPORT_SYMBOL(security_kdbus_conn_free);
> +
> +int security_kdbus_conn_info(const struct kdbus_conn *conn)
> +{
> + return call_int_hook(kdbus_conn_info, 0, conn);
> +}
> +EXPORT_SYMBOL(security_kdbus_conn_info);
> +
> +int security_kdbus_talk(const struct kdbus_conn *src,
> + const struct kdbus_conn *dst)
> +{
> + return call_int_hook(kdbus_talk, 0, src, dst);
> +}
> +EXPORT_SYMBOL(security_kdbus_talk);
> +
> #ifdef CONFIG_SECURITY_NETWORK
>
> int security_unix_stream_connect(struct sock *sock, struct sock
> *other, struct sock *newsk)
> @@ -1774,6 +1863,34 @@ struct security_hook_heads security_hook_heads
> = {
> LIST_HEAD_INIT(security_hook_heads.inode_setsecctx),
> .inode_getsecctx =
> LIST_HEAD_INIT(security_hook_heads.inode_getsecctx),
> + .kdbus_domain_alloc =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_domain_allo
> c),
> + .kdbus_domain_free =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_domain_free
> ),
> + .kdbus_bus_alloc =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_bus_alloc),
> + .kdbus_bus_free =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_bus_free),
> + .kdbus_send =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_send),
> + .kdbus_recv =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_recv),
> + .kdbus_name_acquire =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_name_acquir
> e),
> + .kdbus_name_list =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_name_list),
> + .kdbus_ep_create =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_ep_create),
> + .kdbus_ep_setpolicy =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_ep_setpolic
> y),
> + .kdbus_connect =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_connect),
> + .kdbus_conn_free =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_conn_free),
> + .kdbus_conn_info =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_conn_info),
> + .kdbus_talk =
> + LIST_HEAD_INIT(security_hook_heads.kdbus_talk),
> #ifdef CONFIG_SECURITY_NETWORK
> .unix_stream_connect =
> LIST_HEAD_INIT(security_hook_heads.unix_stream_conne
> ct),
--
Lukasz Pawelczyk
Samsung R&D Institute Poland
Samsung Electronics
next prev parent reply other threads:[~2015-07-08 11:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 10:25 [RFC 0/8] Introduce LSM to KDBUS Paul Osmialowski
2015-07-08 10:25 ` [RFC 1/8] lsm: make security_file_receive available for external modules Paul Osmialowski
2015-07-08 10:25 ` [RFC 2/8] lsm: smack: Make ipc/kdbus includes visible so smack callbacks could see them Paul Osmialowski
2015-07-08 16:43 ` Daniel Mack
2015-07-08 10:25 ` [RFC 3/8] lsm: kdbus security hooks Paul Osmialowski
2015-07-08 11:00 ` Lukasz Pawelczyk [this message]
2015-07-08 14:14 ` Greg Kroah-Hartman
2015-07-08 10:25 ` [RFC 4/8] lsm: smack: smack callbacks for " Paul Osmialowski
2015-07-08 13:42 ` Stephen Smalley
2015-07-08 16:38 ` Casey Schaufler
2015-07-08 20:07 ` Paul Moore
2015-07-09 10:08 ` Sergei Zviagintsev
2015-07-09 15:24 ` Casey Schaufler
2015-07-08 10:25 ` [RFC 5/8] kdbus: use LSM hooks in kdbus code Paul Osmialowski
2015-07-08 11:06 ` Lukasz Pawelczyk
2015-07-08 11:09 ` Lukasz Pawelczyk
2015-07-08 12:12 ` Paul Osmialowski
2015-07-09 10:55 ` Sergei Zviagintsev
2015-07-09 11:28 ` Paul Osmialowski
2015-07-08 13:37 ` Stephen Smalley
2015-07-10 16:56 ` Stephen Smalley
2015-07-10 18:20 ` Stephen Smalley
2015-07-08 14:13 ` Greg Kroah-Hartman
2015-07-08 16:24 ` Casey Schaufler
2015-07-08 10:25 ` [RFC 6/8] kdbus: TEST_CREATE_CONN now does no depend on TEST_CREATE_BUS Paul Osmialowski
2015-07-08 10:25 ` [RFC 7/8] kdbus: selftests extended Paul Osmialowski
2015-07-08 10:25 ` [RFC 8/8] kdbus: Ability to run kdbus test by executable binary name Paul Osmialowski
2015-07-08 14:16 ` Greg Kroah-Hartman
2015-07-08 14:58 ` Paul Osmialowski
2015-07-08 16:46 ` [RFC 0/8] Introduce LSM to KDBUS Casey Schaufler
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=1436353258.2331.0.camel@samsung.com \
--to=l.pawelczyk@samsung.com \
--cc=casey@schaufler-ca.com \
--cc=daniel@zonque.org \
--cc=dh.herrmann@googlemail.com \
--cc=gregkh@linuxfoundation.org \
--cc=james.l.morris@oracle.com \
--cc=k.lewandowsk@samsung.com \
--cc=keescook@chromium.org \
--cc=l.skalski@samsung.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mark.d.rustad@intel.com \
--cc=neilb@suse.de \
--cc=p.osmialowsk@samsung.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=pmoore@redhat.com \
--cc=sds@tycho.nsa.gov \
--cc=serge@hallyn.com \
--cc=shuahkh@osg.samsung.com \
--cc=tixxdz@opendz.org \
--cc=viro@zeniv.linux.org.uk \
/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
Powered by JetHome