stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
	Balazs Nemeth <bnemeth@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	syzbot <syzkaller@googlegroups.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 5.4 028/111] net: ensure mac header is set in virtio_net_hdr_to_skb()
Date: Mon, 12 Apr 2021 10:40:06 +0200	[thread overview]
Message-ID: <20210412084005.172136699@linuxfoundation.org> (raw)
In-Reply-To: <20210412084004.200986670@linuxfoundation.org>

From: Eric Dumazet <edumazet@google.com>

commit 61431a5907fc36d0738e9a547c7e1556349a03e9 upstream.

Commit 924a9bc362a5 ("net: check if protocol extracted by virtio_net_hdr_set_proto is correct")
added a call to dev_parse_header_protocol() but mac_header is not yet set.

This means that eth_hdr() reads complete garbage, and syzbot complained about it [1]

This patch resets mac_header earlier, to get more coverage about this change.

Audit of virtio_net_hdr_to_skb() callers shows that this change should be safe.

[1]

BUG: KASAN: use-after-free in eth_header_parse_protocol+0xdc/0xe0 net/ethernet/eth.c:282
Read of size 2 at addr ffff888017a6200b by task syz-executor313/8409

CPU: 1 PID: 8409 Comm: syz-executor313 Not tainted 5.12.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x141/0x1d7 lib/dump_stack.c:120
 print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:232
 __kasan_report mm/kasan/report.c:399 [inline]
 kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:416
 eth_header_parse_protocol+0xdc/0xe0 net/ethernet/eth.c:282
 dev_parse_header_protocol include/linux/netdevice.h:3177 [inline]
 virtio_net_hdr_to_skb.constprop.0+0x99d/0xcd0 include/linux/virtio_net.h:83
 packet_snd net/packet/af_packet.c:2994 [inline]
 packet_sendmsg+0x2325/0x52b0 net/packet/af_packet.c:3031
 sock_sendmsg_nosec net/socket.c:654 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:674
 sock_no_sendpage+0xf3/0x130 net/core/sock.c:2860
 kernel_sendpage.part.0+0x1ab/0x350 net/socket.c:3631
 kernel_sendpage net/socket.c:3628 [inline]
 sock_sendpage+0xe5/0x140 net/socket.c:947
 pipe_to_sendpage+0x2ad/0x380 fs/splice.c:364
 splice_from_pipe_feed fs/splice.c:418 [inline]
 __splice_from_pipe+0x43e/0x8a0 fs/splice.c:562
 splice_from_pipe fs/splice.c:597 [inline]
 generic_splice_sendpage+0xd4/0x140 fs/splice.c:746
 do_splice_from fs/splice.c:767 [inline]
 do_splice+0xb7e/0x1940 fs/splice.c:1079
 __do_splice+0x134/0x250 fs/splice.c:1144
 __do_sys_splice fs/splice.c:1350 [inline]
 __se_sys_splice fs/splice.c:1332 [inline]
 __x64_sys_splice+0x198/0x250 fs/splice.c:1332
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46

Fixes: 924a9bc362a5 ("net: check if protocol extracted by virtio_net_hdr_set_proto is correct")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Balazs Nemeth <bnemeth@redhat.com>
Cc: Willem de Bruijn <willemb@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/virtio_net.h |    2 ++
 1 file changed, 2 insertions(+)

--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -62,6 +62,8 @@ static inline int virtio_net_hdr_to_skb(
 			return -EINVAL;
 	}
 
+	skb_reset_mac_header(skb);
+
 	if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
 		u16 start = __virtio16_to_cpu(little_endian, hdr->csum_start);
 		u16 off = __virtio16_to_cpu(little_endian, hdr->csum_offset);



  parent reply	other threads:[~2021-04-12  8:46 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12  8:39 [PATCH 5.4 000/111] 5.4.112-rc1 review Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 001/111] counter: stm32-timer-cnt: fix ceiling miss-alignment with reload register Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 002/111] ALSA: aloop: Fix initialization of controls Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 003/111] ALSA: hda/realtek: Fix speaker amp setup on Acer Aspire E1 Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 004/111] ASoC: intel: atom: Stop advertising non working S24LE support Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 005/111] nfc: fix refcount leak in llcp_sock_bind() Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 006/111] nfc: fix refcount leak in llcp_sock_connect() Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 007/111] nfc: fix memory " Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 008/111] nfc: Avoid endless loops caused by repeated llcp_sock_connect() Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 009/111] xen/evtchn: Change irq_info lock to raw_spinlock_t Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 010/111] net: ipv6: check for validity before dereferencing cfg->fc_nlinfo.nlh Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 011/111] net: dsa: lantiq_gswip: Let GSWIP automatically set the xMII clock Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 012/111] drm/i915: Fix invalid access to ACPI _DSM objects Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 013/111] gcov: re-fix clang-11+ support Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 014/111] ia64: fix user_stack_pointer() for ptrace() Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 015/111] nds32: flush_dcache_page: use page_mapping_file to avoid races with swapoff Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 016/111] ocfs2: fix deadlock between setattr and dio_end_io_write Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 017/111] fs: direct-io: fix missing sdio->boundary Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 018/111] parisc: parisc-agp requires SBA IOMMU driver Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 019/111] parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 020/111] ARM: dts: turris-omnia: configure LED[2]/INTn pin as interrupt pin Greg Kroah-Hartman
2021-04-12  8:39 ` [PATCH 5.4 021/111] batman-adv: initialize "struct batadv_tvlv_tt_vlan_data"->reserved field Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 022/111] ice: Increase control queue timeout Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 023/111] ice: Fix for dereference of NULL pointer Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 024/111] ice: Cleanup fltr list in case of allocation issues Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 025/111] net: hso: fix null-ptr-deref during tty device unregistration Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 026/111] ethernet/netronome/nfp: Fix a use after free in nfp_bpf_ctrl_msg_rx Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 027/111] bpf, sockmap: Fix sk->prot unhash op reset Greg Kroah-Hartman
2021-04-12  8:40 ` Greg Kroah-Hartman [this message]
2021-04-12  8:40 ` [PATCH 5.4 029/111] i40e: Fix sparse warning: missing error code err Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 030/111] i40e: Fix sparse error: vsi->netdev could be null Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 031/111] net: sched: sch_teql: fix null-pointer dereference Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 032/111] mac80211: fix TXQ AC confusion Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 033/111] net: hsr: Reset MAC header for Tx path Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 034/111] net-ipv6: bugfix - raw & sctp - switch to ipv6_can_nonlocal_bind() Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 035/111] net: let skb_orphan_partial wake-up waiters Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 036/111] usbip: add sysfs_lock to synchronize sysfs code paths Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 037/111] usbip: stub-dev " Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 038/111] usbip: vudc " Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 039/111] usbip: synchronize event handler with " Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 040/111] i2c: turn recovery error on init to debug Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 041/111] virtio_net: Add XDP meta data support Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 042/111] virtio_net: Do not pull payload in skb->head Greg Kroah-Hartman
2021-04-12  9:12   ` Michael S. Tsirkin
2021-05-18 19:35     ` Eric Dumazet
2021-05-19  0:04       ` Sasha Levin
2021-04-12  8:40 ` [PATCH 5.4 043/111] net: dsa: lantiq_gswip: Dont use PHY auto polling Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 044/111] net: dsa: lantiq_gswip: Configure all remaining GSWIP_MII_CFG bits Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 045/111] xfrm: interface: fix ipv4 pmtu check to honor ip header df Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 046/111] regulator: bd9571mwv: Fix AVS and DVFS voltage range Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 047/111] net: xfrm: Localize sequence counter per network namespace Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 048/111] esp: delete NETIF_F_SCTP_CRC bit from features for esp offload Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 049/111] ASoC: SOF: Intel: hda: remove unnecessary parentheses Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 050/111] ASoC: SOF: Intel: HDA: fix core status verification Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 051/111] ASoC: wm8960: Fix wrong bclk and lrclk with pll enabled for some chips Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 052/111] xfrm: Fix NULL pointer dereference on policy lookup Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 053/111] i40e: Added Asym_Pause to supported link modes Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 054/111] i40e: Fix kernel oops when i40e driver removes VFs Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 055/111] hostfs: Use kasprintf() instead of fixed buffer formatting Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 056/111] hostfs: fix memory handling in follow_link() Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 057/111] amd-xgbe: Update DMA coherency values Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 058/111] sch_red: fix off-by-one checks in red_check_params() Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 059/111] arm64: dts: imx8mm/q: Fix pad control of SD1_DATA0 Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 060/111] can: bcm/raw: fix msg_namelen values depending on CAN_REQUIRED_SIZE Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 061/111] gianfar: Handle error code at MAC address change Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 062/111] cxgb4: avoid collecting SGE_QBASE regs during traffic Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 063/111] net:tipc: Fix a double free in tipc_sk_mcast_rcv Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 064/111] ARM: dts: imx6: pbab01: Set vmmc supply for both SD interfaces Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 065/111] net/ncsi: Avoid channel_monitor hrtimer deadlock Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 066/111] nfp: flower: ignore duplicate merge hints from FW Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 067/111] net: phy: broadcom: Only advertise EEE for supported modes Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 068/111] ASoC: sunxi: sun4i-codec: fill ASoC card owner Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 069/111] net/mlx5e: Fix ethtool indication of connector type Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 070/111] net/mlx5: Dont request more than supported EQs Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 071/111] net/rds: Fix a use after free in rds_message_map_pages Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 072/111] soc/fsl: qbman: fix conflicting alignment attributes Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 073/111] i40e: Fix display statistics for veb_tc Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 074/111] drm/msm: Set drvdata to NULL when msm_drm_init() fails Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 075/111] net: udp: Add support for getsockopt(..., ..., UDP_GRO, ..., ...); Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 076/111] scsi: ufs: Fix irq return code Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 077/111] scsi: ufs: Avoid busy-waiting by eliminating tag conflicts Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 078/111] scsi: ufs: Use blk_{get,put}_request() to allocate and free TMFs Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 079/111] scsi: ufs: core: Fix task management request completion timeout Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 080/111] scsi: ufs: core: Fix wrong Task Tag used in task management request UPIUs Greg Kroah-Hartman
2021-04-12  8:40 ` [PATCH 5.4 081/111] net: macb: restore cmp registers on resume path Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 082/111] clk: fix invalid usage of list cursor in register Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 083/111] clk: fix invalid usage of list cursor in unregister Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 084/111] workqueue: Move the position of debug_work_activate() in __queue_work() Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 085/111] s390/cpcmd: fix inline assembly register clobbering Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 086/111] perf inject: Fix repipe usage Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 087/111] net: openvswitch: conntrack: simplify the return expression of ovs_ct_limit_get_default_limit() Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 088/111] openvswitch: fix send of uninitialized stack memory in ct limit reply Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 089/111] net: hns3: clear VF down state bit before request link status Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 090/111] net/mlx5: Fix placement of log_max_flow_counter Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 091/111] net/mlx5: Fix PBMC register mapping Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 092/111] RDMA/cxgb4: check for ipv6 address properly while destroying listener Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 093/111] RDMA/addr: Be strict with gid size Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 094/111] RAS/CEC: Correct ce_add_elem()s returned values Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 095/111] clk: socfpga: fix iomem pointer cast on 64-bit Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 096/111] dt-bindings: net: ethernet-controller: fix typo in NVMEM Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 097/111] net: sched: bump refcount for new action in ACT replace mode Greg Kroah-Hartman
2021-04-13 10:36   ` Sudip Mukherjee
2021-04-13 10:51     ` Greg Kroah-Hartman
2021-04-13 12:40       ` Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 098/111] cfg80211: remove WARN_ON() in cfg80211_sme_connect Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 099/111] net: tun: set tun->dev->addr_len during TUNSETLINK processing Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 100/111] drivers: net: fix memory leak in atusb_probe Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 101/111] drivers: net: fix memory leak in peak_usb_create_dev Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 102/111] net: mac802154: Fix general protection fault Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 103/111] net: ieee802154: nl-mac: fix check on panid Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 104/111] net: ieee802154: fix nl802154 del llsec key Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 105/111] net: ieee802154: fix nl802154 del llsec dev Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 106/111] net: ieee802154: fix nl802154 add llsec key Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 107/111] net: ieee802154: fix nl802154 del llsec devkey Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 108/111] net: ieee802154: forbid monitor for set llsec params Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 109/111] net: ieee802154: forbid monitor for del llsec seclevel Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 110/111] net: ieee802154: stop dump llsec params for monitors Greg Kroah-Hartman
2021-04-12  8:41 ` [PATCH 5.4 111/111] Revert "cifs: Set CIFS_MOUNT_USE_PREFIX_PATH flag on setting cifs_sb->prepath." Greg Kroah-Hartman
2021-04-12 13:12 ` [PATCH 5.4 000/111] 5.4.112-rc1 review Jon Hunter
2021-04-12 18:57 ` Florian Fainelli
2021-04-12 22:08 ` Guenter Roeck
2021-04-13  1:35 ` Shuah Khan
2021-04-13  5:17 ` Naresh Kamboju
2021-04-13 10:31 ` Samuel Zou
2021-04-13 10:42 ` Sudip Mukherjee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210412084005.172136699@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=bnemeth@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzkaller@googlegroups.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).