From 735c736e1814d8ad5b6b0c51f62f6b5210da0e2b Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 26 Mar 2004 21:02:08 -0800 Subject: [PATCH] [PATCH] selinux: check return value for receive node permission From: James Morris This patch fixes a bug where the return value for a permission call is not checked. The bug was introduced when I added some code in the following changeset: Code was added after this line: err = avc_has_perm(isec->sid, node_sid, SECCLASS_NODE, node_perm, NULL, &ad); without adding an explicit check of 'err', which was previously returned from the function rather than being checked. i.e. it would drop through to: out: return err; } With the new code added, err can (and typically would) be overwritten with a successful value, causing the permission check to not deny permission if needed. The intended denial would have been logged. The patch below fixes this problem. --- security/selinux/hooks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 175350d216037..b42eaa71fcc6c 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3039,6 +3039,8 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) goto out; err = avc_has_perm(isec->sid, node_sid, SECCLASS_NODE, node_perm, NULL, &ad); + if (err) + goto out; if (recv_perm) { u32 port_sid; -- 2.53.0