Skip to content

Commit

Permalink
netlink: reset extack earlier in netlink_rcv_skb
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
lxin authored and davem330 committed Jan 18, 2018
1 parent 7155f8f commit cd443f1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -2391,6 +2391,7 @@ int netlink_rcv_skb(struct sk_buff *skb, int (*cb)(struct sk_buff *,
while (skb->len >= nlmsg_total_size(0)) {
int msglen;

memset(&extack, 0, sizeof(extack));
nlh = nlmsg_hdr(skb);
err = 0;

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

memset(&extack, 0, sizeof(extack));
err = cb(skb, nlh, &extack);
if (err == -EINTR)
goto skip;
Expand Down

0 comments on commit cd443f1

Please sign in to comment.