linux-stable/net/core
Ido Schimmel c6e087cad4 rtnetlink: Reject negative ifindexes in RTM_NEWLINK
commit 30188bd783 upstream.

Negative ifindexes are illegal, but the kernel does not validate the
ifindex in the ancillary header of RTM_NEWLINK messages, resulting in
the kernel generating a warning [1] when such an ifindex is specified.

Fix by rejecting negative ifindexes.

[1]
WARNING: CPU: 0 PID: 5031 at net/core/dev.c:9593 dev_index_reserve+0x1a2/0x1c0 net/core/dev.c:9593
[...]
Call Trace:
 <TASK>
 register_netdevice+0x69a/0x1490 net/core/dev.c:10081
 br_dev_newlink+0x27/0x110 net/bridge/br_netlink.c:1552
 rtnl_newlink_create net/core/rtnetlink.c:3471 [inline]
 __rtnl_newlink+0x115e/0x18c0 net/core/rtnetlink.c:3688
 rtnl_newlink+0x67/0xa0 net/core/rtnetlink.c:3701
 rtnetlink_rcv_msg+0x439/0xd30 net/core/rtnetlink.c:6427
 netlink_rcv_skb+0x16b/0x440 net/netlink/af_netlink.c:2545
 netlink_unicast_kernel net/netlink/af_netlink.c:1342 [inline]
 netlink_unicast+0x536/0x810 net/netlink/af_netlink.c:1368
 netlink_sendmsg+0x93c/0xe40 net/netlink/af_netlink.c:1910
 sock_sendmsg_nosec net/socket.c:728 [inline]
 sock_sendmsg+0xd9/0x180 net/socket.c:751
 ____sys_sendmsg+0x6ac/0x940 net/socket.c:2538
 ___sys_sendmsg+0x135/0x1d0 net/socket.c:2592
 __sys_sendmsg+0x117/0x1e0 net/socket.c:2621
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Fixes: 38f7b870d4 ("[RTNETLINK]: Link creation API")
Reported-by: syzbot+5ba06978f34abb058571@syzkaller.appspotmail.com
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/20230823064348.2252280-1-idosch@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-10-10 21:43:42 +02:00
..
datagram.c net: use skb_queue_empty_lockless() in busy poll contexts 2019-11-10 11:25:35 +01:00
dev.c Remove DECnet support from kernel 2023-06-21 15:38:58 +02:00
dev_addr_lists.c
dev_ioctl.c
devlink.c devlink: Add missing genlmsg_cancel() in devlink_nl_sb_port_pool_fill() 2020-11-24 13:05:36 +01:00
drop_monitor.c drop_monitor: fix data-race in dropmon_net_event / trace_napi_poll_hit 2022-02-23 11:57:34 +01:00
dst.c
dst_cache.c
ethtool.c net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats 2023-01-24 07:05:18 +01:00
fib_notifier.c
fib_rules.c fib: Return the correct errno code 2021-06-30 08:48:47 -04:00
filter.c bpf: fix subprog verifier bypass by div/mod by 0 exception 2023-03-11 16:26:32 +01:00
flow_dissector.c flow_dissector: Fix out-of-bounds warnings 2021-09-22 11:45:28 +02:00
gen_estimator.c net_sched: gen_estimator: support large ewma log 2021-02-07 14:47:40 +01:00
gen_stats.c gen_stats: Fix netlink stats dumping in the presence of padding 2018-07-25 11:25:09 +02:00
gro_cells.c gro_cells: make sure device is up in gro_cells_receive() 2019-03-19 13:13:21 +01:00
hwbm.c
link_watch.c
lwt_bpf.c bpf: in __bpf_redirect_no_mac pull mac only if present 2019-01-23 08:09:50 +01:00
lwtunnel.c
Makefile
neighbour.c neighbour: delete neigh_lookup_nodev as not used 2023-06-21 15:38:59 +02:00
net-procfs.c net-procfs: show net devices bound packet types 2022-02-08 18:16:26 +01:00
net-sysfs.c net-sysfs: add check for netdevice being present to speed_show 2022-03-16 12:57:08 +01:00
net-sysfs.h
net-traces.c
net_namespace.c netns: add schedule point in ops_exit_list() 2022-01-27 09:01:00 +01:00
netclassid_cgroup.c cgroup, netclassid: remove double cond_resched 2020-05-10 10:29:03 +02:00
netevent.c
netpoll.c net: Have netpoll bring-up DSA management interface 2020-11-24 13:05:39 +01:00
netprio_cgroup.c netprio_cgroup: Fix unlimited memory leak of v2 cgroups 2020-05-20 08:17:13 +02:00
pktgen.c pktgen: fix misuse of BUG_ON() in pktgen_thread_worker() 2021-03-07 11:27:44 +01:00
ptp_classifier.c
request_sock.c
rtnetlink.c rtnetlink: Reject negative ifindexes in RTM_NEWLINK 2023-10-10 21:43:42 +02:00
scm.c
secure_seq.c secure_seq: use the 64 bits of the siphash for port offset calculation 2022-06-06 08:20:56 +02:00
skbuff.c net: fix skb leak in __skb_tstamp_tx() 2023-05-30 12:38:38 +01:00
sock.c af_unix: Fix data race around sk->sk_err. 2023-09-23 10:47:02 +02:00
sock_diag.c
sock_reuseport.c
stream.c net: Remove WARN_ON_ONCE(sk->sk_forward_alloc) from sk_stream_kill_queues(). 2023-03-11 16:26:32 +01:00
sysctl_net_core.c net: Fix data-races around weight_p and dev_weight_[rt]x_bias. 2022-09-05 10:25:03 +02:00
timestamping.c
tso.c
utils.c net: Fix skb->csum update in inet_proto_csum_replace16(). 2020-02-05 14:18:28 +00:00