Commit 3ba9cf6
netlabel: Fix NULL pointer exception caused by CALIPSO on IPv4 sockets
[ Upstream commit 078aabd ]
When calling netlbl_conn_setattr(), addr->sa_family is used
to determine the function behavior. If sk is an IPv4 socket,
but the connect function is called with an IPv6 address,
the function calipso_sock_setattr() is triggered.
Inside this function, the following code is executed:
sk_fullsock(__sk) ? inet_sk(__sk)->pinet6 : NULL;
Since sk is an IPv4 socket, pinet6 is NULL, leading to a
null pointer dereference.
This patch fixes the issue by checking if inet6_sk(sk)
returns a NULL pointer before accessing pinet6.
Signed-off-by: Debin Zhu <mowenroot@163.com>
Signed-off-by: Bitao Ouyang <1985755126@qq.com>
Acked-by: Paul Moore <paul@paul-moore.com>
Fixes: ceba183 ("calipso: Set the calipso socket label to match the secattr.")
Link: https://patch.msgid.link/20250401124018.4763-1-mowenroot@163.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent feb1fa2 commit 3ba9cf6
1 file changed
+18
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1072 | 1072 | | |
1073 | 1073 | | |
1074 | 1074 | | |
1075 | | - | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
1076 | 1080 | | |
| 1081 | + | |
1077 | 1082 | | |
1078 | 1083 | | |
1079 | 1084 | | |
| |||
1125 | 1130 | | |
1126 | 1131 | | |
1127 | 1132 | | |
1128 | | - | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
1129 | 1138 | | |
| 1139 | + | |
1130 | 1140 | | |
1131 | 1141 | | |
1132 | 1142 | | |
| |||
1153 | 1163 | | |
1154 | 1164 | | |
1155 | 1165 | | |
1156 | | - | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
1157 | 1171 | | |
| 1172 | + | |
1158 | 1173 | | |
1159 | 1174 | | |
1160 | 1175 | | |
| |||
0 commit comments