Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netlink: Fix bugs in nlmsg_end() conversions.

Commit 053c095a82cf ("netlink: make nlmsg_end() and genlmsg_end()
void") didn't catch all of the cases where callers were breaking out
on the return value being equal to zero, which they no longer should
when zero means success.

Fix all such cases.

Reported-by: Marcel Holtmann <marcel@holtmann.org>
Reported-by: Scott Feldman <sfeldma@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

+11 -14
+4 -4
net/core/neighbour.c
··· 2128 2128 2129 2129 if (neightbl_fill_info(skb, tbl, NETLINK_CB(cb->skb).portid, 2130 2130 cb->nlh->nlmsg_seq, RTM_NEWNEIGHTBL, 2131 - NLM_F_MULTI) <= 0) 2131 + NLM_F_MULTI) < 0) 2132 2132 break; 2133 2133 2134 2134 nidx = 0; ··· 2144 2144 NETLINK_CB(cb->skb).portid, 2145 2145 cb->nlh->nlmsg_seq, 2146 2146 RTM_NEWNEIGHTBL, 2147 - NLM_F_MULTI) <= 0) 2147 + NLM_F_MULTI) < 0) 2148 2148 goto out; 2149 2149 next: 2150 2150 nidx++; ··· 2274 2274 if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).portid, 2275 2275 cb->nlh->nlmsg_seq, 2276 2276 RTM_NEWNEIGH, 2277 - NLM_F_MULTI) <= 0) { 2277 + NLM_F_MULTI) < 0) { 2278 2278 rc = -1; 2279 2279 goto out; 2280 2280 } ··· 2311 2311 if (pneigh_fill_info(skb, n, NETLINK_CB(cb->skb).portid, 2312 2312 cb->nlh->nlmsg_seq, 2313 2313 RTM_NEWNEIGH, 2314 - NLM_F_MULTI, tbl) <= 0) { 2314 + NLM_F_MULTI, tbl) < 0) { 2315 2315 read_unlock_bh(&tbl->lock); 2316 2316 rc = -1; 2317 2317 goto out;
+1 -1
net/core/rtnetlink.c
··· 1327 1327 */ 1328 1328 WARN_ON((err == -EMSGSIZE) && (skb->len == 0)); 1329 1329 1330 - if (err <= 0) 1330 + if (err < 0) 1331 1331 goto out; 1332 1332 1333 1333 nl_dump_check_consistent(cb, nlmsg_hdr(skb));
+1 -4
net/decnet/dn_route.c
··· 1710 1710 rt->rt_flags |= RTCF_NOTIFY; 1711 1711 1712 1712 err = dn_rt_fill_info(skb, NETLINK_CB(in_skb).portid, nlh->nlmsg_seq, RTM_NEWROUTE, 0, 0); 1713 - 1714 - if (err == 0) 1715 - goto out_free; 1716 1713 if (err < 0) { 1717 1714 err = -EMSGSIZE; 1718 1715 goto out_free; ··· 1760 1763 skb_dst_set(skb, dst_clone(&rt->dst)); 1761 1764 if (dn_rt_fill_info(skb, NETLINK_CB(cb->skb).portid, 1762 1765 cb->nlh->nlmsg_seq, RTM_NEWROUTE, 1763 - 1, NLM_F_MULTI) <= 0) { 1766 + 1, NLM_F_MULTI) < 0) { 1764 1767 skb_dst_drop(skb); 1765 1768 rcu_read_unlock_bh(); 1766 1769 goto done;
+3 -3
net/ipv4/devinet.c
··· 1883 1883 cb->nlh->nlmsg_seq, 1884 1884 RTM_NEWNETCONF, 1885 1885 NLM_F_MULTI, 1886 - -1) <= 0) { 1886 + -1) < 0) { 1887 1887 rcu_read_unlock(); 1888 1888 goto done; 1889 1889 } ··· 1899 1899 NETLINK_CB(cb->skb).portid, 1900 1900 cb->nlh->nlmsg_seq, 1901 1901 RTM_NEWNETCONF, NLM_F_MULTI, 1902 - -1) <= 0) 1902 + -1) < 0) 1903 1903 goto done; 1904 1904 else 1905 1905 h++; ··· 1910 1910 NETLINK_CB(cb->skb).portid, 1911 1911 cb->nlh->nlmsg_seq, 1912 1912 RTM_NEWNETCONF, NLM_F_MULTI, 1913 - -1) <= 0) 1913 + -1) < 0) 1914 1914 goto done; 1915 1915 else 1916 1916 h++;
+1 -1
net/ipv4/route.c
··· 2483 2483 err = rt_fill_info(net, dst, src, &fl4, skb, 2484 2484 NETLINK_CB(in_skb).portid, nlh->nlmsg_seq, 2485 2485 RTM_NEWROUTE, 0, 0); 2486 - if (err <= 0) 2486 + if (err < 0) 2487 2487 goto errout_free; 2488 2488 2489 2489 err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+1 -1
net/ipv6/addrconf.c
··· 4213 4213 goto cont; 4214 4214 4215 4215 if (in6_dump_addrs(idev, skb, cb, type, 4216 - s_ip_idx, &ip_idx) <= 0) 4216 + s_ip_idx, &ip_idx) < 0) 4217 4217 goto done; 4218 4218 cont: 4219 4219 idx++;