mptcp/pm_netlink.c : add check for nla_put_in/6_addr
Subsystems (3)
PATCH v2 1/1 mptcp/pm_netlink.c : add check for nla_put_in/6_addr
Normal there should be checked for nla_put_in6_addr like other usage in net.
Detected by CoverityScan, CID# 1461639
---
V2: Add check for nla_put_in_addr suggested by Paolo Abeni
--- net/mptcp/pm_netlink.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
net/mptcp/pm_netlink.c +7 -4
@@ -599,12 +599,15 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, nla_put_s32(skb, MPTCP_PM_ADDR_ATTR_IF_IDX, entry->ifindex)) goto nla_put_failure; -if (addr->family ==AF_INET ) +if (addr->family ==AF_INET &&nla_put_in_addr (skb,MPTCP_PM_ADDR_ATTR_ADDR4 , - addr->addr.s_addr); + addr->addr.s_addr)) + goto nla_put_failure; + #if IS_ENABLED(CONFIG_MPTCP_IPV6) - else if (addr->family == AF_INET6) - nla_put_in6_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR6, &addr->addr6); + else if (addr->family == AF_INET6 && + nla_put_in6_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR6, &addr->addr6)) + goto nla_put_failure;#endif nla_nest_end (skb, attr);return 0 ;
--
2.11.0
Paolo Abeni
maintainerQuoted 9 lines · Bo YU
Normal there should be checked for
nla_put_in6_addrlike other usage in net.Detected by CoverityScan, CID# 1461639
Fixes 01cacb00b35c("mptcp: add netlink-based PM")Signed-off-by Bo YU <tsu.yubo(a)gmail.com>---
V2: Add check fornla_put_in_addrsuggested by Paolo Abeni
Thank you for addressing my feedback!
Quoted 9 lines
--- net/mptcp/pm_netlink.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)net/mptcp/pm_netlink.c +0
-0
net/mptcp/pm_netlink.c static int mptcp_nl_fill_addr(struct sk_buff *skb, · line 606
Quoted 10 lines
net/mptcp/pm_netlink.c +4
-2@@ -599,12 +599,15 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, nla_put_s32(skb, MPTCP_PM_ADDR_ATTR_IF_IDX, entry->ifindex)) goto nla_put_failure; -if (addr->family ==AF_INET ) +if (addr->family ==AF_INET &&nla_put_in_addr (skb,MPTCP_PM_ADDR_ATTR_ADDR4 , - addr->addr.s_addr); + addr->addr.s_addr)) + goto nla_put_failure; +
I'm very sorry about the nit-picking, but the above is now a single statement, and indentation should be adjusted accordingly:
'nla_put_in_addr()' should be aligned with 'addr->family'.
The same applies to the chunk below.
net/mptcp/pm_netlink.c static int mptcp_nl_fill_addr(struct sk_buff *skb, · line 613
Quoted 9 lines
net/mptcp/pm_netlink.c +3
-2#if IS_ENABLED(CONFIG_MPTCP_IPV6) - else if (addr->family == AF_INET6) - nla_put_in6_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR6, &addr->addr6); + else if (addr->family == AF_INET6 && + nla_put_in6_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR6, &addr->addr6)) + goto nla_put_failure;#endif nla_nest_end (skb, attr);return 0 ;
Otherwise LGTM, thanks!
Paolo
Quoted 25 lines · Paolo Abeni
Quoted 9 lines · Bo YU
Normal there should be checked for
nla_put_in6_addrlike other usage in net.Detected by CoverityScan, CID# 1461639
Fixes 01cacb00b35c("mptcp: add netlink-based PM")Signed-off-by Bo YU <tsu.yubo(a)gmail.com>---
V2: Add check fornla_put_in_addrsuggested by Paolo AbeniThank you for addressing my feedback!
Quoted 12 lines
--- net/mptcp/pm_netlink.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)net/mptcp/pm_netlink.c +0
-0@@ -599,12 +599,15 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, nla_put_s32(skb, MPTCP_PM_ADDR_ATTR_IF_IDX, entry->ifindex)) goto nla_put_failure;
Quoted 11 lines
net/mptcp/pm_netlink.c static int mptcp_nl_fill_addr(struct sk_buff *skb, · line 606
Quoted 7 lines
net/mptcp/pm_netlink.c +4
-2-if (addr->family ==AF_INET ) +if (addr->family ==AF_INET &&nla_put_in_addr (skb,MPTCP_PM_ADDR_ATTR_ADDR4 , - addr->addr.s_addr); + addr->addr.s_addr)) + goto nla_put_failure; +I'm very sorry about the nit-picking, but the above is now a single statement, and indentation should be adjusted accordingly:
'nla_put_in_addr()' should be aligned with 'addr->family'.
Ok, but i just want to make clear for that, do you mean:
if (addr->family == AF_INET && nla_put_in_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR4, addr->addr.s_addr))
In fact, i was upset by checkpatch about over 80 chars warning. This is my originally version patch to fix it :(. If i was wrong to understand your means, please correct me. Thank you.
Quoted 17 lines
The same applies to the chunk below.
net/mptcp/pm_netlink.c static int mptcp_nl_fill_addr(struct sk_buff *skb, · line 613
Quoted 9 lines
net/mptcp/pm_netlink.c +3
-2#if IS_ENABLED(CONFIG_MPTCP_IPV6) - else if (addr->family == AF_INET6) - nla_put_in6_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR6, &addr->addr6); + else if (addr->family == AF_INET6 && + nla_put_in6_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR6, &addr->addr6)) + goto nla_put_failure;#endif nla_nest_end (skb, attr);return 0 ;Otherwise LGTM, thanks!
Paolo
Paolo Abeni
maintainerQuoted 40 lines · Bo YU
Quoted 25 lines · Paolo Abeni
Quoted 9 lines · Bo YU
Normal there should be checked for
nla_put_in6_addrlike other usage in net.Detected by CoverityScan, CID# 1461639
Fixes 01cacb00b35c("mptcp: add netlink-based PM")Signed-off-by Bo YU <tsu.yubo(a)gmail.com>---
V2: Add check fornla_put_in_addrsuggested by Paolo AbeniThank you for addressing my feedback!
Quoted 12 lines
--- net/mptcp/pm_netlink.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)net/mptcp/pm_netlink.c +0
-0@@ -599,12 +599,15 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, nla_put_s32(skb, MPTCP_PM_ADDR_ATTR_IF_IDX, entry->ifindex)) goto nla_put_failure;Quoted 11 lines
net/mptcp/pm_netlink.c static int mptcp_nl_fill_addr(struct sk_buff *skb, · line 606
Quoted 7 lines
net/mptcp/pm_netlink.c +4
-2-if (addr->family ==AF_INET ) +if (addr->family ==AF_INET &&nla_put_in_addr (skb,MPTCP_PM_ADDR_ATTR_ADDR4 , - addr->addr.s_addr); + addr->addr.s_addr)) + goto nla_put_failure; +I'm very sorry about the nit-picking, but the above is now a single statement, and indentation should be adjusted accordingly:
'nla_put_in_addr()' should be aligned with 'addr->family'.Ok, but i just want to make clear for that, do you mean:
Quoted 6 lines
if (addr->family == AF_INET && nla_put_in_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR4, addr->addr.s_addr))In fact, i was upset by checkpatch about over 80 chars warning. This is my originally version patch to fix it :(. If i was wrong to understand your means, please correct me. Thank you.
I mean:
if (addr->family == AF_INET && nla_put_in_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR4, addr->addr.s_addr))
note that [the first char of] 'nla_put_in_addr' is aligned with [the first char of] 'addr->family', and 'addr->addr.s_addr' with 'skb'.
Please, nota that the same applies to nla_put_in6_addr() below.
Thanks!
Paolo