Received: by 10.213.65.68 with SMTP id h4csp151287imn; Mon, 12 Mar 2018 22:38:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELufrsppbmHg562kJaiII5zoji+lX332ky5VoiApDoPLZ/3IRd5puUJTvEuKhJmaZ8ynnJzV X-Received: by 10.99.119.133 with SMTP id s127mr8422049pgc.441.1520919483109; Mon, 12 Mar 2018 22:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520919483; cv=none; d=google.com; s=arc-20160816; b=aeubKlc/F1BOoy4hG+MsrnY7T0Q2cczhUxwrmX8sbxPCHtRlXwFiXqNi+rD7rWddOO BkVlI6PjWR5kvOAMkBzLBmA5KwHXcWn31osgnsD6LMM9kAstQPX3++R28vQv5gSAgmHI QesxXKqsfdWcnNvABXZv6xI3qUFPsYHS2PbuPDcHYtSckciTDnZZ79rNehu0GeID9Zuh 6f/3nBXlDONZmTf71GjuA9UL0GaLQbg18ceRILadki+R9zBt9VVD0I3Vavp7Xh4zQAY1 3Pc7mh0b3FHsVfaaGnNLfji/QeGb0rFxkAvElzxSO9Vef/F3QOSE7cnUcM9Lt4DJJ2LF V+RQ== 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=+C9QRfiazf9HUsqnEssuj2nDukPSST/RcV5959A9/EA=; b=Bj1Jgxn9ZwXb3pfBIbGaxQ03GPCDdNMMlGt8Vcur2ml+NV441tXWPkQ6VTEgrpLzV8 9c4Ykec5qu6YWteZ+TINyNkKGTH59xoAdVP6HmGOLX3EnjyWmGjzS1yQJC6H5h60EFFW 6Xgv2ZO9UtmeY+wP8Mz8PUnbUbKsAuvqvky1xWFYpu8kw304BAM97Z7XjUWIBZay7Q7c yTfpJdSB7Ftc5Y2G3PlaoJjCIhIEOMXuaCfvkJoZbjBprL5aQhCt4yhzr6Og2gGvF4ed mMyN7uI8z+0y3WZR9N/eW0d1IAu3Nf65mO+KJLxl+kTyHt7iNcij5H2zn/l8yDze57Jh UutA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@appneta.com header.s=google header.b=GioQIY8O; 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 u19-v6si7284850plq.120.2018.03.12.22.37.49; Mon, 12 Mar 2018 22:38:03 -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=GioQIY8O; 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 S1751719AbeCMFe5 (ORCPT + 99 others); Tue, 13 Mar 2018 01:34:57 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:40051 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750854AbeCMFez (ORCPT ); Tue, 13 Mar 2018 01:34:55 -0400 Received: by mail-pg0-f67.google.com with SMTP id g8so7533628pgv.7 for ; Mon, 12 Mar 2018 22:34:55 -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=+C9QRfiazf9HUsqnEssuj2nDukPSST/RcV5959A9/EA=; b=GioQIY8OBjHH4XskJhzMQ9kbRd+B9GtQoR1mHb16CbI8+AxAaZqipkTfiIXOpalYhw nMDRPDdqEp1IEH6tkzYMhSFmLmCAzzmKRhvgGa++aZKBueSGbZJ3pTA5edqIUfZlpVCP WLQi3MAup3qnvZe5d0b4kxtfYF2vcbBsOfL1M= 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=+C9QRfiazf9HUsqnEssuj2nDukPSST/RcV5959A9/EA=; b=YvizcBktvx5zu41Mkmfbb7yGhqPH+VG3clR0l9mUxet/uluJ2GMriHxFHWtUSmwiaE VX86UlektXtjhH+WC8Z6olQmtx1YRGLAs+6xOw+ZJjqhGOwXvwNEOvMoVRnFHdHpkUvO TUw4E5J39VE7hgQpm+XC4WpV/kszcSQWFHPofCpjvC9mGqUB0+2KLQX5FeY+VN8wzgcE RFbdgXV/WNMq1IyvNh9x7U9/vrwnF6bnH/elTbnV7r5A+N1smPxieQsWR9SV9lbELnw9 NYIBRLKEengAb/cVekfVUvEzClxH1pDunSJH+KMGCgSqFNxa/v6UAhxkj91ZBqGPrEoM 2sQQ== X-Gm-Message-State: AElRT7FJqp0D9n+b3dEcPnBB1dIdtMWpC32H3D/3oLA5xxglo9XON3Xj 5MP6Hi4/z/26ChxfDF8g0miy X-Received: by 10.99.63.14 with SMTP id m14mr8579894pga.174.1520919294909; Mon, 12 Mar 2018 22:34:54 -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 c14sm16695807pfn.185.2018.03.12.22.34.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Mar 2018 22:34:54 -0700 (PDT) From: Josh Elsasser To: davem@davemloft.net Cc: Josh Elsasser , Greg Kroah-Hartman , Eric Dumazet , Willem de Bruijn , Alexander Potapenko , Cong Wang , Vlad Yasevich , =?UTF-8?q?Michal=20Kube=C4=8Dek?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/1] net: check before dereferencing netdev_ops during busy poll Date: Mon, 12 Mar 2018 22:32:00 -0700 Message-Id: <20180313053248.13654-2-jelsasser@appneta.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180313053248.13654-1-jelsasser@appneta.com> References: <20180313053248.13654-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 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: 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..1f50c131ed15 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->netdev_ops) + busy_poll = napi->dev->netdev_ops->ndo_busy_poll; + else + busy_poll = NULL; do { rc = 0; -- 2.11.0