nexthop: use nlmsg_parse_deprecated()
Subsystems (3)
PATCH 1/1 nexthop: use nlmsg_parse_deprecated()
David missed that commit 8cb081746c03 ("netlink: make validation more configurable for future strictness") has renamed nlmsg_parse()
syzbot reported :
BUG: KMSAN: uninit-value in nh_valid_get_del_req+0x6f1/0x8c0 net/ipv4/nexthop.c:1510 CPU: 0 PID: 11812 Comm: syz-executor444 Not tainted 5.3.0-rc3+ #17 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x191/0x1f0 lib/dump_stack.c:113 kmsan_report+0x162/0x2d0 mm/kmsan/kmsan_report.c:109 __msan_warning+0x75/0xe0 mm/kmsan/kmsan_instr.c:294 nh_valid_get_del_req+0x6f1/0x8c0 net/ipv4/nexthop.c:1510 rtm_del_nexthop+0x1b1/0x610 net/ipv4/nexthop.c:1543 rtnetlink_rcv_msg+0x115a/0x1580 net/core/rtnetlink.c:5223 netlink_rcv_skb+0x431/0x620 net/netlink/af_netlink.c:2477 rtnetlink_rcv+0x50/0x60 net/core/rtnetlink.c:5241 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline] netlink_unicast+0xf6c/0x1050 net/netlink/af_netlink.c:1328 netlink_sendmsg+0x110f/0x1330 net/netlink/af_netlink.c:1917 sock_sendmsg_nosec net/socket.c:637 [inline] sock_sendmsg net/socket.c:657 [inline] ___sys_sendmsg+0x14ff/0x1590 net/socket.c:2311 __sys_sendmmsg+0x53a/0xae0 net/socket.c:2413 __do_sys_sendmmsg net/socket.c:2442 [inline] __se_sys_sendmmsg+0xbd/0xe0 net/socket.c:2439 __x64_sys_sendmmsg+0x56/0x70 net/socket.c:2439 do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:297 entry_SYSCALL_64_after_hwframe+0x63/0xe7
--- net/ipv4/nexthop.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/ipv4/nexthop.c +6 -6
@@ -1304,8 +1304,8 @@ static int rtm_to_nh_config(struct net *net, struct sk_buff *skb,struct nlattr *tb[NHA_MAX +1 ];int err; - err =nlmsg_parse (nlh,sizeof (*nhm), tb,NHA_MAX , rtm_nh_policy, - extack); + err =nlmsg_parse_deprecated (nlh,sizeof (*nhm), tb,NHA_MAX , + rtm_nh_policy, extack);if (err <0 )return err;
@@ -1488,8 +1488,8 @@ static int nh_valid_get_del_req(struct nlmsghdr *nlh, u32 *id,struct nlattr *tb[NHA_MAX +1 ];int err, i; - err =nlmsg_parse (nlh,sizeof (*nhm), tb,NHA_MAX , rtm_nh_policy, - extack); + err =nlmsg_parse_deprecated (nlh,sizeof (*nhm), tb,NHA_MAX , + rtm_nh_policy, extack);if (err <0 )return err;
@@ -1639,8 +1639,8 @@ static int nh_valid_dump_req(const struct nlmsghdr *nlh, int *dev_idx,int err, i;u32 idx; - err =nlmsg_parse (nlh,sizeof (*nhm), tb,NHA_MAX , rtm_nh_policy, -NULL ); + err =nlmsg_parse_deprecated (nlh,sizeof (*nhm), tb,NHA_MAX , + rtm_nh_policy,NULL );if (err <0 )return err;
Signature · 1 line
2.23.0.rc1.153.gdeed80330f-goog
Quoted 2 lines · Eric Dumazet
David missed that commit
8cb081746c03("netlink: make validation more configurable for future strictness") has renamednlmsg_parse()
Thanks for the report, Eric. It is quite likely I overlooked something with that rename given the timing. However, the nexthop code being a new feature is expected to use all of the strict parsing and checking. I can take a look at this later today.
Quoted 2 lines · Eric Dumazet
David missed that commit
8cb081746c03("netlink: make validation more configurable for future strictness") has renamednlmsg_parse()
I think the root cause is nlmsg_parse() calling __nla_parse and not __nlmsg_parse. Users of nlmsg_parse are missing the header validation.