Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7148078ybi; Mon, 8 Jul 2019 15:36:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxBMffVo9WWuZAVwwGqQ7xOC/3bzfB3BZZHDlJ6vXdar96rRBKYg5qZB2VVcp+m8lmpPw1 X-Received: by 2002:a63:2246:: with SMTP id t6mr26301689pgm.209.1562625387679; Mon, 08 Jul 2019 15:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625387; cv=none; d=google.com; s=arc-20160816; b=S6cK6ChAowX/aogn1Opf+W1aV1Td5N7Q05b1goJetgWRld/1OLwA7CYwQBWV4LhtRJ USnkEMWTcjmm9Sqtf9WUUf7y4I0kZvJoN02HJlm2EjxlR1+YIv/yKP40eq7bDaLCgLdE rWzaUfJEl9Vr8XCoSDApcW0YRct9xsAV6bbCPlzXz9ZqMPx0EUHDgNY1zc650348YP4F KcclR2R+pm9UGyoJi8BzFur3vir06rg0ffKkkG6DiKQybKcqZdzMGgidimljjIEQfVLr TUWt/zf33dSkoR0pUuzkxVMQ80CRILCpyQJXYhRF4EtuY/9nYtI2rzxU4zI6pUMGl3ZI NECw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iiaZXzH5c0GzDOE4NvstQKEGiulX+MjL0/wiDsjOrLI=; b=HM2JZY9iHDb+hkkMXsvaS8RR5QqeZlprLObXqYuUZooQ2NNBiaw+yMCTDpuvHWS66Z UXD7tyNPuaMTNgI9cu5nhhfkuS/rYw3WQzWnV/AHqEVrs7W7w73O1r7/uPa9+TuIufAC i3nnz1AHyNTvo87Mf5kO8SfVtwdSIs9fSjHjzh8Ts4dRIGVo1ce5zyHmhPNRK3WGOE1j 7pVOUtyWIA5PvnTzaFDVj9s6oAK3DNY6pkN9mX/C1PHYiVCuGU65LJfaGmSiJrW0LzMQ 2iiDEgVEqUUF2yEULB/yDX8k7pQXGttN2Ikga4m2Hb4qkY3DeNikQiXkVIKI9Zv2Cj4M hIOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MbUErqVT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cl7si19967512plb.267.2019.07.08.15.36.13; Mon, 08 Jul 2019 15:36:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MbUErqVT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387492AbfGHPVQ (ORCPT + 99 others); Mon, 8 Jul 2019 11:21:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:46784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387473AbfGHPVO (ORCPT ); Mon, 8 Jul 2019 11:21:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E4206217D8; Mon, 8 Jul 2019 15:21:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599273; bh=mwOelXsrCuuMKCyZ0wYPajpulkmxdXMTo78dRT5AWPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MbUErqVTmgjCKVfFiU7BRxEV2AsD4evkJned2Ep5FHUxxm+2qz03VUoQSFmtlgYVB mREcJQ0igO70jP8XuGh9h/jQBY582JgUdSzJ/ZPTSuWKmpZBbLmKMEBFDmyv+RJAd6 ynFxY8r73UnaJ4Lk2cv98Sps5Ekg2ZDLuf7eUvoc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Josh Elsasser , Eric Dumazet , Matteo Croce Subject: [PATCH 4.9 061/102] net: check before dereferencing netdev_ops during busy poll Date: Mon, 8 Jul 2019 17:12:54 +0200 Message-Id: <20190708150529.620430598@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150525.973820964@linuxfoundation.org> References: <20190708150525.973820964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josh Elsasser init_dummy_netdev() leaves its netdev_ops pointer zeroed. This leads to a NULL pointer dereference when sk_busy_loop fires against an iwlwifi wireless adapter and checks napi->dev->netdev_ops->ndo_busy_poll. Avoid this by ensuring napi->dev->netdev_ops is valid before following the pointer, avoiding the following panic when busy polling on a dummy netdev: BUG: unable to handle kernel NULL pointer dereference at 00000000000000c8 IP: [] sk_busy_loop+0x92/0x2f0 Call Trace: [] ? uart_write_room+0x74/0xf0 [] sock_poll+0x99/0xa0 [] do_sys_poll+0x2e2/0x520 [] ? get_page_from_freelist+0x3bc/0xa30 [] ? update_curr+0x62/0x140 [] ? __slab_free+0xa1/0x2a0 [] ? __slab_free+0xa1/0x2a0 [] ? skb_free_head+0x21/0x30 [] ? poll_initwait+0x50/0x50 [] ? kmem_cache_free+0x1c6/0x1e0 [] ? uart_write+0x124/0x1d0 [] ? remove_wait_queue+0x4d/0x60 [] ? __wake_up+0x44/0x50 [] ? tty_write_unlock+0x31/0x40 [] ? tty_ldisc_deref+0x16/0x20 [] ? tty_write+0x1e0/0x2f0 [] ? process_echoes+0x80/0x80 [] ? __vfs_write+0x2b/0x130 [] ? vfs_write+0x15a/0x1a0 [] SyS_poll+0x75/0x100 [] entry_SYSCALL_64_fastpath+0x24/0xcf Commit 79e7fff47b7b ("net: remove support for per driver ndo_busy_poll()") indirectly fixed this upstream in linux-4.11 by removing the offending pointer usage. No other users of napi->dev touch its netdev_ops. Fixes: ce6aea93f751 ("net: network drivers no longer need to implement ndo_busy_poll()") # 4.9.y Signed-off-by: Josh Elsasser Reviewed-by: Eric Dumazet Tested-by: Matteo Croce Signed-off-by: Greg Kroah-Hartman --- No changes since V2[1], resent as per discussiond on -stable[2]. I hope this is the correct way to send net fixes for older LTS releases, I'm going off of the latest netdev FAQ: For earlier stable releases, each stable branch maintainer is supposed to take care of them. If you find any patch is missing from an earlier stable branch, please notify stable@vger.kernel.org with either a commit ID or a formal patch backported, and CC Dave and other relevant networking developers. [1]: https://patchwork.ozlabs.org/patch/884986/ [2]: https://lore.kernel.org/stable/CAGnkfhx3ykbEsW+=FtpMFWU=_Vnie7RpPYWpWqa1S1HPMXj9kw@mail.gmail.com/ net/core/dev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5083,7 +5083,10 @@ bool sk_busy_loop(struct sock *sk, int n goto out; /* Note: ndo_busy_poll method is optional in linux-4.5 */ - busy_poll = napi->dev->netdev_ops->ndo_busy_poll; + if (napi->dev->netdev_ops) + busy_poll = napi->dev->netdev_ops->ndo_busy_poll; + else + busy_poll = NULL; do { rc = 0;