Skip to content

Commit 213d7f9

Browse files
Richard Hainespcmoore
authored andcommitted
netlabel: If PF_INET6, check sk_buff ip header version
When resolving a fallback label, check the sk_buff version as it is possible (e.g. SCTP) to have family = PF_INET6 while receiving ip_hdr(skb)->version = 4. Signed-off-by: Richard Haines <richard_c_haines@btinternet.com> Acked-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 7928b2c commit 213d7f9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

net/netlabel/netlabel_unlabeled.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,16 @@ int netlbl_unlabel_getattr(const struct sk_buff *skb,
14721472
iface = rcu_dereference(netlbl_unlhsh_def);
14731473
if (iface == NULL || !iface->valid)
14741474
goto unlabel_getattr_nolabel;
1475+
1476+
#if IS_ENABLED(CONFIG_IPV6)
1477+
/* When resolving a fallback label, check the sk_buff version as
1478+
* it is possible (e.g. SCTP) to have family = PF_INET6 while
1479+
* receiving ip_hdr(skb)->version = 4.
1480+
*/
1481+
if (family == PF_INET6 && ip_hdr(skb)->version == 4)
1482+
family = PF_INET;
1483+
#endif /* IPv6 */
1484+
14751485
switch (family) {
14761486
case PF_INET: {
14771487
struct iphdr *hdr4;

0 commit comments

Comments
 (0)