Commit 5c553a0
net: marvell: prestera: fix incorrect structure access
[ Upstream commit 2efc225 ]
In line:
upper = info->upper_dev;
We access upper_dev field, which is related only for particular events
(e.g. event == NETDEV_CHANGEUPPER). So, this line cause invalid memory
access for another events,
when ptr is not netdev_notifier_changeupper_info.
The KASAN logs are as follows:
[ 30.123165] BUG: KASAN: stack-out-of-bounds in prestera_netdev_port_event.constprop.0+0x68/0x538 [prestera]
[ 30.133336] Read of size 8 at addr ffff80000cf772b0 by task udevd/778
[ 30.139866]
[ 30.141398] CPU: 0 PID: 778 Comm: udevd Not tainted 5.16.0-rc3 #6
[ 30.147588] Hardware name: DNI AmazonGo1 A7040 board (DT)
[ 30.153056] Call trace:
[ 30.155547] dump_backtrace+0x0/0x2c0
[ 30.159320] show_stack+0x18/0x30
[ 30.162729] dump_stack_lvl+0x68/0x84
[ 30.166491] print_address_description.constprop.0+0x74/0x2b8
[ 30.172346] kasan_report+0x1e8/0x250
[ 30.176102] __asan_load8+0x98/0xe0
[ 30.179682] prestera_netdev_port_event.constprop.0+0x68/0x538 [prestera]
[ 30.186847] prestera_netdev_event_handler+0x1b4/0x1c0 [prestera]
[ 30.193313] raw_notifier_call_chain+0x74/0xa0
[ 30.197860] call_netdevice_notifiers_info+0x68/0xc0
[ 30.202924] register_netdevice+0x3cc/0x760
[ 30.207190] register_netdev+0x24/0x50
[ 30.211015] prestera_device_register+0x8a0/0xba0 [prestera]
Fixes: 3d5048c ("net: marvell: prestera: move netdev topology validation to prestera_main")
Signed-off-by: Yevhen Orlov <yevhen.orlov@plvision.eu>
Link: https://lore.kernel.org/r/20211216171714.11341-1-yevhen.orlov@plvision.eu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent da3feb8 commit 5c553a0
1 file changed
+12
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
707 | 707 | | |
708 | 708 | | |
709 | 709 | | |
710 | | - | |
| 710 | + | |
| 711 | + | |
711 | 712 | | |
712 | 713 | | |
713 | 714 | | |
714 | 715 | | |
715 | | - | |
716 | | - | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
717 | 720 | | |
718 | 721 | | |
719 | 722 | | |
| 723 | + | |
720 | 724 | | |
721 | 725 | | |
722 | 726 | | |
723 | 727 | | |
724 | 728 | | |
725 | 729 | | |
726 | | - | |
| 730 | + | |
727 | 731 | | |
728 | 732 | | |
729 | 733 | | |
| |||
732 | 736 | | |
733 | 737 | | |
734 | 738 | | |
735 | | - | |
| 739 | + | |
736 | 740 | | |
737 | 741 | | |
738 | 742 | | |
| |||
748 | 752 | | |
749 | 753 | | |
750 | 754 | | |
| 755 | + | |
751 | 756 | | |
752 | | - | |
| 757 | + | |
753 | 758 | | |
754 | 759 | | |
755 | 760 | | |
756 | 761 | | |
757 | 762 | | |
758 | | - | |
| 763 | + | |
759 | 764 | | |
760 | 765 | | |
761 | 766 | | |
| |||
0 commit comments