Received: by 10.213.65.16 with SMTP id m16csp14981imf; Sun, 11 Mar 2018 12:26:14 -0700 (PDT) X-Google-Smtp-Source: AG47ELtSdWC10vDnHvXT8M/hExBIwNHowTKp5luvlmPUk4y2E1XLX8Z5sAgnpCG3nOXWTbpWY/s2 X-Received: by 2002:a17:902:b691:: with SMTP id c17-v6mr5720358pls.308.1520796374029; Sun, 11 Mar 2018 12:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520796373; cv=none; d=google.com; s=arc-20160816; b=Q3VDH/tgk4Ulj7CyXkkX91IPXUFWeemRBg8jlxH3Z3KZdfx0IpP4aIgCDAOFKELPbE PJpyTVC4eWEkLbshVrTWr3pv5w1M/XPdTQPNFMdEWrMuCLkAynwduTurVt5Rftpejuq6 kP6N38LB7lprynpFjhUcTZRlul8ZFf5Ao/74rMENpLKvkfNoua7qzUx55hylDrZYp00V OSrJuFeh/b1/DPVV7s8zwWQKhu+/DmqxbUp4EM4NRRbI0YRzM2zMxs2v+9xAdQCMdHfD QAdzeDAx9Gu8UhhiEHjEMoLLj3cl/g9U6UTQxBRjdTxMqcCAFkOef2FxRq/fXAC8jhw8 LV2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Ma/gtyU8jEHFiwVDecb14yecvM5eV0bTE+1obKTH3oI=; b=BGvaX5WafvAUlxqN7pb0HZ6DrrkL9GBx7t29E57M4Fo6jIFpqRhzuDP6Nu+R/X1JPZ 3lKc6K6QDXySgBtjfAi3stfok83FTP2en8GbXblbGbv8HgLwVQUDzdwaXfvT7M9eZWHj eNI2IcSIN+lnpuCepXJj9dEYYuX66b28Cih/2c5qxlO+1RGTR0mUIdEdxDZYdfau/nCf 052+gEkY55JzQPnbjH5i6TQDTjuRsI6foWSwGA3+tk+J60pOZ9OcblYJBadisnnCrFkH 67O6oX7mN5ymAds9cFPmdm/1WAe8RoGTey9YpC+g9cgv9ckc/qaZhwHBcA4mQN5CBZhE UhVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@appneta.com header.s=google header.b=bWXoGl8h; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=appneta.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17si3935377pgq.421.2018.03.11.12.25.59; Sun, 11 Mar 2018 12:26:13 -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=@appneta.com header.s=google header.b=bWXoGl8h; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=appneta.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932314AbeCKTY5 (ORCPT + 99 others); Sun, 11 Mar 2018 15:24:57 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:42055 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932139AbeCKTYx (ORCPT ); Sun, 11 Mar 2018 15:24:53 -0400 Received: by mail-pf0-f194.google.com with SMTP id a16so3427899pfn.9 for ; Sun, 11 Mar 2018 12:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=appneta.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ma/gtyU8jEHFiwVDecb14yecvM5eV0bTE+1obKTH3oI=; b=bWXoGl8htgDInDuVbBXJ4Y2WvQYe4cYXT2atgtac6DsSPjJY4340cU2IfwvK9MDSDK EHjDQI4c1IjwofO0Nund8ZJSSBVePl30ARX462sA6Umz7c4FQWxgsIv5mwiD9TeTMEk3 IJJojG1I+61nf/MmYbE/4Klzv8s+m8cKU7aMg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ma/gtyU8jEHFiwVDecb14yecvM5eV0bTE+1obKTH3oI=; b=oXuFRSzTDYz1XIVlxkiLArIHIyXkezI8+pk4aOZ7LfyFP8ZLiUJuVHXZ+CsRW1/qAq pOS9NYkY2nxVa/Tyq+Grj24TEPRn5R5hWadlJFRjH3QBBlngwrug5bG+1U0/Sx/pYyZ9 OBbBFuwX7HOwvCuWmuQDZ86MvsJvOSoE29/1XhMvf69GyZn/lypjJPLgx6CGLQbtcFxE EjI1PNKP9jVbcnZYyIe/t6xJylJ6VkatdGfOiz9eTXOTZMEwFlzrycMN1RSyLrri4pcT tlP453KJBMjTmQRMjzONPR3LACPuENmJE4j7RviqMIn8HbCMckbYh2MoXplezDVHl3Wc w5sQ== X-Gm-Message-State: AElRT7FNcoeWSqC5sNs7G1zglxO3lk/Qm6H0NxVU1labrScD4/KcGHqF pWM366BbQjozFqka8lxxd92I X-Received: by 10.99.177.6 with SMTP id r6mr4586089pgf.76.1520796292914; Sun, 11 Mar 2018 12:24:52 -0700 (PDT) Received: from debian8-stable-jae.jaalam.net (d173-180-161-165.bchsia.telus.net. [173.180.161.165]) by smtp.gmail.com with ESMTPSA id l19sm11736753pgn.31.2018.03.11.12.24.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 11 Mar 2018 12:24:52 -0700 (PDT) From: Josh Elsasser To: davem@davemloft.net Cc: Josh Elsasser , Greg Kroah-Hartman , Eric Dumazet , Sasha Levin , Willem de Bruijn , Alexander Potapenko , Cong Wang , =?UTF-8?q?Michal=20Kube=C4=8Dek?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] net: check dev->reg_state before deref of napi netdev_ops Date: Sun, 11 Mar 2018 12:22:55 -0700 Message-Id: <20180311192322.101598-2-jelsasser@appneta.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180311192322.101598-1-jelsasser@appneta.com> References: <20180311192322.101598-1-jelsasser@appneta.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 that napi->dev is not a dummy device before dereferencing napi dev's netdev_ops, preventing the following panic: 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: 060212928670 ("net: add low latency socket poll") Fixes: ce6aea93f751 ("net: network drivers no longer need to implement ndo_busy_poll()") - 4.9.y Signed-off-by: Josh Elsasser --- net/core/dev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index 8898618bf341..d0f67d544587 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5042,7 +5042,10 @@ bool sk_busy_loop(struct sock *sk, int nonblock) 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->reg_state != NETREG_DUMMY) + busy_poll = napi->dev->netdev_ops->ndo_busy_poll; + else + busy_poll = NULL; do { rc = 0; -- 2.11.0