Skip to content

Commit 0e0e367

Browse files
committed
netlabel: add address family checks to netlbl_{sock,req}_delattr()
It seems risky to always rely on the caller to ensure the socket's address family is correct before passing it to the NetLabel kAPI, especially since we see at least one LSM which didn't. Add address family checks to the *_delattr() functions to help prevent future problems. Cc: <stable@vger.kernel.org> Reported-by: Maninder Singh <maninder1.s@samsung.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 7ea5920 commit 0e0e367

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

net/netlabel/netlabel_kapi.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,11 @@ int netlbl_sock_setattr(struct sock *sk,
824824
*/
825825
void netlbl_sock_delattr(struct sock *sk)
826826
{
827-
cipso_v4_sock_delattr(sk);
827+
switch (sk->sk_family) {
828+
case AF_INET:
829+
cipso_v4_sock_delattr(sk);
830+
break;
831+
}
828832
}
829833

830834
/**
@@ -987,7 +991,11 @@ int netlbl_req_setattr(struct request_sock *req,
987991
*/
988992
void netlbl_req_delattr(struct request_sock *req)
989993
{
990-
cipso_v4_req_delattr(req);
994+
switch (req->rsk_ops->family) {
995+
case AF_INET:
996+
cipso_v4_req_delattr(req);
997+
break;
998+
}
991999
}
9921000

9931001
/**

0 commit comments

Comments
 (0)