Skip to content

Commit cd443f1

Browse files
lxindavem330
authored andcommitted
netlink: reset extack earlier in netlink_rcv_skb
Move up the extack reset/initialization in netlink_rcv_skb, so that those 'goto ack' will not skip it. Otherwise, later on netlink_ack may use the uninitialized extack and cause kernel crash. Fixes: cbbdf84 ("netlink: extack needs to be reset each time through loop") Reported-by: [email protected] Signed-off-by: Xin Long <[email protected]> Acked-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7155f8f commit cd443f1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/netlink/af_netlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2391,6 +2391,7 @@ int netlink_rcv_skb(struct sk_buff *skb, int (*cb)(struct sk_buff *,
23912391
while (skb->len >= nlmsg_total_size(0)) {
23922392
int msglen;
23932393

2394+
memset(&extack, 0, sizeof(extack));
23942395
nlh = nlmsg_hdr(skb);
23952396
err = 0;
23962397

@@ -2405,7 +2406,6 @@ int netlink_rcv_skb(struct sk_buff *skb, int (*cb)(struct sk_buff *,
24052406
if (nlh->nlmsg_type < NLMSG_MIN_TYPE)
24062407
goto ack;
24072408

2408-
memset(&extack, 0, sizeof(extack));
24092409
err = cb(skb, nlh, &extack);
24102410
if (err == -EINTR)
24112411
goto skip;

0 commit comments

Comments
 (0)