From: Roman Kubiak Date: Thu, 17 Dec 2015 12:24:35 +0000 (+0100) Subject: BACKPORT: Smack: type confusion in smak sendmsg() handler X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a15d1561dbd1c7f051ad7f2095c874419a60dca;p=platform%2Fkernel%2Flinux-stable.git BACKPORT: Smack: type confusion in smak sendmsg() handler Smack security handler for sendmsg() syscall is vulnerable to type confusion issue what can allow to privilege escalation into root or cause denial of service. A malicious attacker can create socket of one type for example AF_UNIX and pass is into sendmsg() function ensuring that this is AF_INET socket. Remedy Do not trust user supplied data. Proposed fix below. Signed-off-by: Roman Kubiak Signed-off-by: Mateusz Fruba Acked-by: Casey Schaufler (cherry-picked from upstream 81bd0d56298f93af6ac233d8a7e8b29aa4b094b7) --- diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 4606098584bb..b1eddcec70c9 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -3795,7 +3795,7 @@ static int smack_socket_sendmsg(struct socket *sock, struct msghdr *msg, if (sip == NULL) return 0; - switch (sip->sin_family) { + switch (sock->sk->sk_family) { case AF_INET: rc = smack_netlabel_send(sock->sk, sip); break;