@@ -1254,7 +1254,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);
@@ -1392,7 +1393,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;
}
@@ -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)
@@ -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;
@@ -2096,16 +2096,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);
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(-)