mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
[AF_UNIX]: Kernel memory leak fix for af_unix datagram getpeersec patch
From: Catherine Zhang <[email protected]> This patch implements a cleaner fix for the memory leak problem of the original unix datagram getpeersec patch. Instead of creating a security context each time a unix datagram is sent, we only create the security context when the receiver requests it. This new design requires modification of the current unix_getsecpeer_dgram LSM hook and addition of two new hooks, namely, secid_to_secctx and release_secctx. The former retrieves the security context and the latter releases it. A hook is required for releasing the security context because it is up to the security module to decide how that's done. In the case of Selinux, it's a simple kfree operation. Acked-by: Stephen Smalley <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
2b7e24b66d
commit
dc49c1f94e
7 changed files with 110 additions and 44 deletions
|
|
@ -791,8 +791,7 @@ static int dummy_socket_getpeersec_stream(struct socket *sock, char __user *optv
|
|||
return -ENOPROTOOPT;
|
||||
}
|
||||
|
||||
static int dummy_socket_getpeersec_dgram(struct sk_buff *skb, char **secdata,
|
||||
u32 *seclen)
|
||||
static int dummy_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
|
||||
{
|
||||
return -ENOPROTOOPT;
|
||||
}
|
||||
|
|
@ -876,6 +875,15 @@ static int dummy_setprocattr(struct task_struct *p, char *name, void *value, siz
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int dummy_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static void dummy_release_secctx(char *secdata, u32 seclen)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KEYS
|
||||
static inline int dummy_key_alloc(struct key *key, struct task_struct *ctx,
|
||||
unsigned long flags)
|
||||
|
|
@ -1028,6 +1036,8 @@ void security_fixup_ops (struct security_operations *ops)
|
|||
set_to_dummy_if_null(ops, d_instantiate);
|
||||
set_to_dummy_if_null(ops, getprocattr);
|
||||
set_to_dummy_if_null(ops, setprocattr);
|
||||
set_to_dummy_if_null(ops, secid_to_secctx);
|
||||
set_to_dummy_if_null(ops, release_secctx);
|
||||
#ifdef CONFIG_SECURITY_NETWORK
|
||||
set_to_dummy_if_null(ops, unix_stream_connect);
|
||||
set_to_dummy_if_null(ops, unix_may_send);
|
||||
|
|
|
|||
Loading…
Reference in a new issue