Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2111604ima; Mon, 22 Oct 2018 04:36:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV61BLeE2UXtWo1V4Xu+mUPWETianbxFTrfS63jKy7WpaYuY7ey1+1ElkIZYRWImSUb9Du9bw X-Received: by 2002:a17:902:4383:: with SMTP id j3-v6mr41097157pld.265.1540208181798; Mon, 22 Oct 2018 04:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540208181; cv=none; d=google.com; s=arc-20160816; b=loQ0YGUU1vZ2Ge3VcgQCLkbnhvPHo3xRAGnwLhG5lJMvTPSmU2yzvDNTroLuuoQnn+ x1W/EYWumVGwb/AJ7Darc84ERbsR6f20K66ruEGpECCGclfLZFbykxUtGKog4pm2uEaJ X/P/E8I8s1ZRysBRmA/k1Bnn/v/DkuqNjRyLsObWjbFFo7D8EjTOBhPPHsPyv3qLJgpy FIxLoxJO2ejhcOwuTqrWd7Mw+amAXnYningTd9/AfBr4pm0POl7znxkhwmaDDuIfkfLT zSUvj1A8yHAIZamA7fska1pT4J4G6fx9mvrA8kLKkAt/oVUaDlcEQJIPsZCJ02oBGhPz Y7eA== 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; bh=UiQ89a4LifMIGHe7o/iqdCZuvm2pwEkRoLbvpeUcHqQ=; b=fyg8kJ9xB4sCZCiTN3oBukNXTjK4OWW2R338KDpWpjnnCDgWvsWrLFbxwfjGyrHWM+ GV0TjuMVUmpWnZCIA3ht1on/oQxVhX+QSf26eFCl3FhvmmXHJDvcN0RCkbV4IYk62os8 1ynv/J/fkWsjb/CNOzNwuKR5VduVxv3qpTVntgDuGYyQh4DJkrSOj1K1yarS2d1AyanQ 7KaZGPEtWBoy8bzDf+bHAKEP1CQoLsoVxc6Vnbdk7qnDXFJR098KZWp3eIU3clc0G27r asE5RSiAYAygrXab0bxA81WM9SrdxLUW2hspDvF0Ssqjr6uzPTBoEcd0Y3/PiWiizWIX +ZNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="fw/LidHf"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p6-v6si34331986pgp.243.2018.10.22.04.36.05; Mon, 22 Oct 2018 04:36:21 -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="fw/LidHf"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729172AbeJVSiz (ORCPT + 99 others); Mon, 22 Oct 2018 14:38:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:49876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729148AbeJVSiy (ORCPT ); Mon, 22 Oct 2018 14:38:54 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2450120853; Mon, 22 Oct 2018 10:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540203658; bh=yTlQ0NOnq48KyUTcR2usO/FvIIwgRG2J/ynRRnM/ffM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fw/LidHfIQDgyfpTlUzgkFxa92DEJ1caEJOmPPI5n1W+K/ve3tbC6WKFdxwje4aVu 2Fo0uVJjHE0/V7bcs+LIK7ZehuspE6RQWmsaqm1OY1k2W/t2+nyKIYWZFKP4bKVrfm 8VHhpgkE1h67OQp4wGxU6yZn6E8BtJETQDCgQ0ME= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Arthur Kiyanovski , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.14 12/15] net: ena: fix NULL dereference due to untimely napi initialization Date: Mon, 22 Oct 2018 06:20:23 -0400 Message-Id: <20181022102026.40869-12-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181022102026.40869-1-sashal@kernel.org> References: <20181022102026.40869-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arthur Kiyanovski [ Upstream commit 78a55d05def95144ca5fa9a64c49b2a0636a9866 ] napi poll functions should be initialized before running request_irq(), to handle a rare condition where there is a pending interrupt, causing the ISR to fire immediately while the poll function wasn't set yet, causing a NULL dereference. Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)") Signed-off-by: Arthur Kiyanovski Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 08c9c99a8331..3c7813f04962 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -1571,8 +1571,6 @@ static int ena_up_complete(struct ena_adapter *adapter) if (rc) return rc; - ena_init_napi(adapter); - ena_change_mtu(adapter->netdev, adapter->netdev->mtu); ena_refill_all_rx_bufs(adapter); @@ -1726,6 +1724,13 @@ static int ena_up(struct ena_adapter *adapter) ena_setup_io_intr(adapter); + /* napi poll functions should be initialized before running + * request_irq(), to handle a rare condition where there is a pending + * interrupt, causing the ISR to fire immediately while the poll + * function wasn't set yet, causing a null dereference + */ + ena_init_napi(adapter); + rc = ena_request_io_irq(adapter); if (rc) goto err_req_irq; -- 2.17.1