* [PATCH] netlink: use "unsigned int" in nla_next()
@ 2016-11-19 0:54 Alexey Dobriyan
2016-11-20 3:11 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2016-11-19 0:54 UTC (permalink / raw)
To: davem; +Cc: netdev
->nla_len is unsigned entity (it's length after all) and u16,
thus it can't overflow when being aligned into int/unsigned int.
(nlmsg_next has the same code, but I didn't yet convince myself
it is correct to do so).
There is pointer arithmetic in this function and offset being
unsigned is better:
add/remove: 0/0 grow/shrink: 1/64 up/down: 5/-309 (-304)
function old new delta
nl80211_set_wiphy 1444 1449 +5
team_nl_cmd_options_set 997 995 -2
tcf_em_tree_validate 872 870 -2
switchdev_port_bridge_setlink 352 350 -2
switchdev_port_br_afspec 312 310 -2
rtm_to_fib_config 428 426 -2
qla4xxx_sysfs_ddb_set_param 2193 2191 -2
qla4xxx_iface_set_param 4470 4468 -2
ovs_nla_free_flow_actions 152 150 -2
output_userspace 518 516 -2
...
nl80211_set_reg 654 649 -5
validate_scan_freqs 148 142 -6
validate_linkmsg 288 282 -6
nl80211_parse_connkeys 489 483 -6
nlattr_set 231 224 -7
nf_tables_delsetelem 267 260 -7
do_setlink 3416 3408 -8
netlbl_cipsov4_add_std 1672 1659 -13
nl80211_parse_sched_scan 2902 2888 -14
nl80211_trigger_scan 1738 1720 -18
do_execute_actions 2821 2738 -83
Total: Before=154865355, After=154865051, chg -0.00%
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
include/net/netlink.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -713,7 +713,7 @@ static inline bool nla_ok(const struct nlattr *nla, int remaining)
*/
static inline struct nlattr *nla_next(const struct nlattr *nla, int *remaining)
{
- int totlen = NLA_ALIGN(nla->nla_len);
+ unsigned int totlen = NLA_ALIGN(nla->nla_len);
*remaining -= totlen;
return (struct nlattr *) ((char *) nla + totlen);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] netlink: use "unsigned int" in nla_next()
2016-11-19 0:54 [PATCH] netlink: use "unsigned int" in nla_next() Alexey Dobriyan
@ 2016-11-20 3:11 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-11-20 3:11 UTC (permalink / raw)
To: adobriyan; +Cc: netdev
From: Alexey Dobriyan <adobriyan@gmail.com>
Date: Sat, 19 Nov 2016 03:54:35 +0300
> ->nla_len is unsigned entity (it's length after all) and u16,
> thus it can't overflow when being aligned into int/unsigned int.
>
> (nlmsg_next has the same code, but I didn't yet convince myself
> it is correct to do so).
>
> There is pointer arithmetic in this function and offset being
> unsigned is better:
...
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Applied to net-next.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-20 3:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-19 0:54 [PATCH] netlink: use "unsigned int" in nla_next() Alexey Dobriyan
2016-11-20 3:11 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.