From: Casey Schaufler <casey@schaufler-ca.com>
To: casey.schaufler@intel.com, jmorris@namei.org,
linux-security-module@vger.kernel.org, selinux@vger.kernel.org
Cc: casey@schaufler-ca.com, keescook@chromium.org,
john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp,
paul@paul-moore.com, sds@tycho.nsa.gov
Subject: [PATCH 15/58] LSM: Use lsm_export in security_socket_getpeersec_dgram
Date: Fri, 31 May 2019 16:09:37 -0700 [thread overview]
Message-ID: <20190531231020.628-16-casey@schaufler-ca.com> (raw)
In-Reply-To: <20190531231020.628-1-casey@schaufler-ca.com>
Convert security_socket_getpeersec_dgram to use the lsm_export structure
instead of a u32 secid. There is some scaffolding involved
that will be removed when the related data is updated.
In particular, the le entry in scm_cookie includes the secid
data. The secid will go away.
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
---
include/linux/security.h | 7 +++++--
include/net/scm.h | 4 +++-
net/ipv4/ip_sockglue.c | 4 +++-
security/security.c | 13 ++++---------
4 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/include/linux/security.h b/include/linux/security.h
index 7369cdc3a681..e3f5c61b9b2c 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1270,7 +1270,8 @@ int security_socket_shutdown(struct socket *sock, int how);
int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
int __user *optlen, unsigned len);
-int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
+int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb,
+ struct lsm_export *l);
int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
void security_sk_free(struct sock *sk);
void security_sk_clone(const struct sock *sk, struct sock *newsk);
@@ -1408,7 +1409,9 @@ static inline int security_socket_getpeersec_stream(struct socket *sock, char __
return -ENOPROTOOPT;
}
-static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
+static inline int security_socket_getpeersec_dgram(struct socket *sock,
+ struct sk_buff *skb,
+ struct lsm_export *l)
{
return -ENOPROTOOPT;
}
diff --git a/include/net/scm.h b/include/net/scm.h
index 1ce365f4c256..13b8a369fd89 100644
--- a/include/net/scm.h
+++ b/include/net/scm.h
@@ -34,6 +34,7 @@ struct scm_cookie {
struct scm_creds creds; /* Skb credentials */
#ifdef CONFIG_SECURITY_NETWORK
u32 secid; /* Passed security ID */
+ struct lsm_export le; /* Passed LSM data */
#endif
};
@@ -46,7 +47,8 @@ struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl);
#ifdef CONFIG_SECURITY_NETWORK
static __inline__ void unix_get_peersec_dgram(struct socket *sock, struct scm_cookie *scm)
{
- security_socket_getpeersec_dgram(sock, NULL, &scm->secid);
+ security_socket_getpeersec_dgram(sock, NULL, &scm->le);
+ lsm_export_secid(&scm->le, &scm->secid);
}
#else
static __inline__ void unix_get_peersec_dgram(struct socket *sock, struct scm_cookie *scm)
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 82f341e84fae..b8ef7677a7e5 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -130,14 +130,16 @@ static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb,
static void ip_cmsg_recv_security(struct msghdr *msg, struct sk_buff *skb)
{
+ struct lsm_export le;
char *secdata;
u32 seclen, secid;
int err;
- err = security_socket_getpeersec_dgram(NULL, skb, &secid);
+ err = security_socket_getpeersec_dgram(NULL, skb, &le);
if (err)
return;
+ lsm_export_secid(&le, &secid);
err = security_secid_to_secctx(secid, &secdata, &seclen);
if (err)
return;
diff --git a/security/security.c b/security/security.c
index edaaaef54239..d8300a6400c3 100644
--- a/security/security.c
+++ b/security/security.c
@@ -2110,16 +2110,11 @@ int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
}
int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb,
- u32 *secid)
+ struct lsm_export *l)
{
- int rc;
- struct lsm_export data = { .flags = LSM_EXPORT_NONE };
-
- rc = call_int_hook(socket_getpeersec_dgram, -ENOPROTOOPT, sock, skb,
- &data);
-
- lsm_export_secid(&data, secid);
- return rc;
+ lsm_export_init(l);
+ return call_int_hook(socket_getpeersec_dgram, -ENOPROTOOPT, sock, skb,
+ l);
}
EXPORT_SYMBOL(security_socket_getpeersec_dgram);
--
2.19.1
next prev parent reply other threads:[~2019-05-31 23:12 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-31 23:09 [PATCH 00/58] LSM: Module stacking for AppArmor Casey Schaufler
2019-05-31 23:09 ` [PATCH 01/58] LSM: Infrastructure management of the superblock Casey Schaufler
2019-06-01 15:15 ` Kees Cook
2019-05-31 23:09 ` [PATCH 02/58] LSM: Infrastructure management of the sock security Casey Schaufler
2019-06-01 15:17 ` Kees Cook
2019-05-31 23:09 ` [PATCH 03/58] LSM: Infrastructure management of the key security blob Casey Schaufler
2019-06-01 15:18 ` Kees Cook
2019-05-31 23:09 ` [PATCH 04/58] LSM: Create an lsm_export data structure Casey Schaufler
2019-06-01 15:23 ` Kees Cook
2019-06-03 20:07 ` Casey Schaufler
2019-05-31 23:09 ` [PATCH 05/58] LSM: Use lsm_export in the inode_getsecid hooks Casey Schaufler
2019-06-02 1:57 ` Kees Cook
2019-06-04 0:29 ` Casey Schaufler
2019-06-06 19:11 ` Kees Cook
2019-05-31 23:09 ` [PATCH 06/58] LSM: Use lsm_export in the cred_getsecid hooks Casey Schaufler
2019-05-31 23:09 ` [PATCH 07/58] LSM: Use lsm_export in the ipc_getsecid and task_getsecid hooks Casey Schaufler
2019-05-31 23:09 ` [PATCH 08/58] LSM: Use lsm_export in the kernel_ask_as hooks Casey Schaufler
2019-05-31 23:09 ` [PATCH 09/58] LSM: Use lsm_export in the getpeersec_dgram hooks Casey Schaufler
2019-05-31 23:09 ` [PATCH 10/58] LSM: Use lsm_export in the audit_rule_match hooks Casey Schaufler
2019-05-31 23:09 ` [PATCH 11/58] LSM: Use lsm_export in the secid_to_secctx hooks Casey Schaufler
2019-05-31 23:09 ` [PATCH 12/58] LSM: Use lsm_export in the secctx_to_secid hooks Casey Schaufler
2019-05-31 23:09 ` [PATCH 13/58] LSM: Use lsm_export in security_audit_rule_match Casey Schaufler
2019-05-31 23:09 ` [PATCH 14/58] LSM: Use lsm_export in security_kernel_act_as Casey Schaufler
2019-05-31 23:09 ` Casey Schaufler [this message]
2019-05-31 23:09 ` [PATCH 16/58] LSM: Use lsm_export in security_secctx_to_secid Casey Schaufler
2019-05-31 23:09 ` [PATCH 17/58] LSM: Use lsm_export in security_secid_to_secctx Casey Schaufler
2019-05-31 23:09 ` [PATCH 18/58] LSM: Use lsm_export in security_ipc_getsecid Casey Schaufler
2019-05-31 23:09 ` [PATCH 19/58] LSM: Use lsm_export in security_task_getsecid Casey Schaufler
2019-05-31 23:09 ` [PATCH 20/58] LSM: Use lsm_export in security_inode_getsecid Casey Schaufler
2019-05-31 23:09 ` [PATCH 21/58] LSM: Use lsm_export in security_cred_getsecid Casey Schaufler
2019-05-31 23:09 ` [PATCH 22/58] Audit: Change audit_sig_sid to audit_sig_lsm Casey Schaufler
2019-06-02 2:03 ` Kees Cook
2019-06-03 22:23 ` Casey Schaufler
2019-06-06 18:41 ` Kees Cook
2019-06-06 19:17 ` Casey Schaufler
2019-06-06 20:53 ` Kees Cook
2019-06-06 21:06 ` Casey Schaufler
2019-06-06 22:53 ` Kees Cook
2019-05-31 23:09 ` [PATCH 23/58] Audit: Convert target_sid to an lsm_export structure Casey Schaufler
2019-05-31 23:09 ` [PATCH 24/58] Audit: Convert osid " Casey Schaufler
2019-05-31 23:09 ` [PATCH 25/58] IMA: Clean out lsm_export scaffolding Casey Schaufler
2019-06-02 2:06 ` Kees Cook
2019-06-03 21:40 ` Casey Schaufler
2019-05-31 23:09 ` [PATCH 26/58] NET: Change the UNIXCB from a secid to an lsm_export Casey Schaufler
2019-05-31 23:09 ` [PATCH 27/58] NET: Remove scaffolding on secmarks Casey Schaufler
2019-05-31 23:09 ` [PATCH 28/58] NET: Remove scaffolding on new secmarks Casey Schaufler
2019-05-31 23:09 ` [PATCH 29/58] NET: Remove netfilter scaffolding for lsm_export Casey Schaufler
2019-05-31 23:09 ` [PATCH 30/58] Netlabel: Replace secids with lsm_export Casey Schaufler
2019-05-31 23:09 ` [PATCH 31/58] LSM: Remove lsm_export scaffolding functions Casey Schaufler
2019-05-31 23:09 ` [PATCH 32/58] IMA: FIXUP prototype using lsm_export Casey Schaufler
2019-05-31 23:09 ` [PATCH 33/58] Smack: Restore the release_secctx hook Casey Schaufler
2019-05-31 23:09 ` [PATCH 34/58] AppArmor: Remove unnecessary hook stub Casey Schaufler
2019-05-31 23:09 ` [PATCH 35/58] LSM: Limit calls to certain module hooks Casey Schaufler
2019-05-31 23:09 ` [PATCH 36/58] LSM: Create a data structure for a security context Casey Schaufler
2019-05-31 23:09 ` [PATCH 37/58] LSM: Use lsm_context in secid_to_secctx hooks Casey Schaufler
2019-05-31 23:10 ` [PATCH 38/58] LSM: Use lsm_context in secctx_to_secid hooks Casey Schaufler
2019-05-31 23:10 ` [PATCH 39/58] LSM: Use lsm_context in inode_getsecctx hooks Casey Schaufler
2019-05-31 23:10 ` [PATCH 40/58] LSM: Use lsm_context in inode_notifysecctx hooks Casey Schaufler
2019-05-31 23:10 ` [PATCH 41/58] LSM: Use lsm_context in dentry_init_security hooks Casey Schaufler
2019-05-31 23:10 ` [PATCH 42/58] LSM: Use lsm_context in security_dentry_init_security Casey Schaufler
2019-05-31 23:10 ` [PATCH 43/58] LSM: Use lsm_context in security_inode_notifysecctx Casey Schaufler
2019-05-31 23:10 ` [PATCH 44/58] LSM: Use lsm_context in security_inode_getsecctx Casey Schaufler
2019-05-31 23:10 ` [PATCH 45/58] LSM: Use lsm_context in security_secctx_to_secid Casey Schaufler
2019-05-31 23:10 ` [PATCH 46/58] LSM: Use lsm_context in release_secctx hooks Casey Schaufler
2019-06-02 2:27 ` Kees Cook
2019-06-03 21:57 ` Casey Schaufler
2019-05-31 23:10 ` [PATCH 47/58] LSM: Use lsm_context in security_release_secctx Casey Schaufler
2019-05-31 23:10 ` [PATCH 48/58] LSM: Use lsm_context in security_secid_to_secctx Casey Schaufler
2019-05-31 23:10 ` [PATCH 49/58] fs: remove lsm_context scaffolding Casey Schaufler
2019-05-31 23:10 ` [PATCH 50/58] LSM: Add the release function to the lsm_context Casey Schaufler
2019-06-01 15:13 ` [PATCH 00/58] LSM: Module stacking for AppArmor Kees Cook
2019-06-02 2:56 ` Kees Cook
2019-05-31 23:30 Casey Schaufler
2019-05-31 23:31 ` [PATCH 15/58] LSM: Use lsm_export in security_socket_getpeersec_dgram Casey Schaufler
2019-06-02 16:50 [PATCH 00/58] LSM: Module stacking for AppArmor Casey Schaufler
2019-06-02 16:50 ` [PATCH 15/58] LSM: Use lsm_export in security_socket_getpeersec_dgram 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=20190531231020.628-16-casey@schaufler-ca.com \
--to=casey@schaufler-ca.com \
--cc=casey.schaufler@intel.com \
--cc=jmorris@namei.org \
--cc=john.johansen@canonical.com \
--cc=keescook@chromium.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=sds@tycho.nsa.gov \
--cc=selinux@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).