Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9933949ybi; Wed, 24 Jul 2019 12:35:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwH1rBsjzugrrB8gYFPGA92GAVJ3FT7ynrDJF9/jFxvIR1YM6mZ3LP+f+fop4gV/b3pfnFN X-Received: by 2002:a17:90a:4806:: with SMTP id a6mr89561631pjh.38.1563996943065; Wed, 24 Jul 2019 12:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996943; cv=none; d=google.com; s=arc-20160816; b=ev7XWsOZccYBeteD8vIymr6XnxKJkCigvhw/xIryoZIf4C2cRH6Kt7VZXLTrbafOxP HfRqLNw5Bq5MS1s7fk/q5HjxdBFPFm4PAOo/ko1lHAflb0XocGvZSXXTKar3EoIGTRtt E19p/Ooz4tm3VT8OU2xVe5+lk25jdoCzpu6G3ZDqy4289PIbxDVBlO05t/gd44J1Xsq7 g0k2fcGS7VJSR4V9/OcN767BMMHc7Yq5PwyfEftwCPOZXik1SlaMsMPK1wLOIYty8tAT av6TpqQ4JYyHyIBkgnZopyViOM/b/4yVKcPqguOTMlhi8Sqc1eTuZ+p94AYTcZ1pKRFS IyDw== 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=22RYXkYS+XEogfe5OaqBiSofgHIRnJ+udQ/wjnBEVXI=; b=Wl0La6Ee2tPdLC0da+n/i/3OiGNfxKSj+nMMhgVqbqLiNpsUvu679VULtFIuFEsEXb Rtef+9/PKuHqXm5J/JQmJIWDAtcuhFNV5F2wyVVqQsp9GBXEpvKa+vLFnlimaQFDIrNc iFHVF0SJnu/Pdb2xr5vYIfOQQ7aBcEZYuiLb/p+I/p2QM2zqu6XQmfli18AytB00VhPc VUpN5noyc/IfpNgdwb27ks/TE60W13HR3CNU7cDKiLCr4TB7enxug9NyrY2FjkwrmFPT gngjSRY6XNUhffQM7Ee0Gz+8qSoDYrsxhFdCUKIXMOT8w5oz8SplFy7vuHwZuynlfVlw kbxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="AMBZW9/j"; 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 61si14353503plq.157.2019.07.24.12.35.28; Wed, 24 Jul 2019 12:35:43 -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="AMBZW9/j"; 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 S1728732AbfGXTef (ORCPT + 99 others); Wed, 24 Jul 2019 15:34:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:57076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388095AbfGXTed (ORCPT ); Wed, 24 Jul 2019 15:34:33 -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 EFE1E22BE9; Wed, 24 Jul 2019 19:34:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996873; bh=2JedzVbS3p0gQxDbnhbGdggAoCwQd65/ctQNtr30MIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AMBZW9/jAH+gUfwJ6F6YWM2JGgxaz9Xn1xiwRA8KzmjCPWK6gypR14pX3w2FFR2rS hXHcqXB8CEO3oLp1rDACpL7+nJdcgQkcXI4KecWy4OsWixuwTbNG5NZWrqXQP5zoSR Z/JXPEepmlVoklVaWwQLs/HVusopC7SWpnqrHnuE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Andrew Bowers , Jeff Kirsher , Sasha Levin Subject: [PATCH 5.2 245/413] iavf: fix dereference of null rx_buffer pointer Date: Wed, 24 Jul 2019 21:18:56 +0200 Message-Id: <20190724191753.032383306@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 [ Upstream commit 9fe06a51287b2d41baef7ece94df34b5abf19b90 ] A recent commit efa14c3985828d ("iavf: allow null RX descriptors") added a null pointer sanity check on rx_buffer, however, rx_buffer is being dereferenced before that check, which implies a null pointer dereference bug can potentially occur. Fix this by only dereferencing rx_buffer until after the null pointer check. Addresses-Coverity: ("Dereference before null check") Signed-off-by: Colin Ian King Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/iavf/iavf_txrx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c index c97b9ecf026a..26422bc9ca8c 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c @@ -1296,7 +1296,7 @@ static struct sk_buff *iavf_construct_skb(struct iavf_ring *rx_ring, struct iavf_rx_buffer *rx_buffer, unsigned int size) { - void *va = page_address(rx_buffer->page) + rx_buffer->page_offset; + void *va; #if (PAGE_SIZE < 8192) unsigned int truesize = iavf_rx_pg_size(rx_ring) / 2; #else @@ -1308,6 +1308,7 @@ static struct sk_buff *iavf_construct_skb(struct iavf_ring *rx_ring, if (!rx_buffer) return NULL; /* prefetch first cache line of first page */ + va = page_address(rx_buffer->page) + rx_buffer->page_offset; prefetch(va); #if L1_CACHE_BYTES < 128 prefetch(va + L1_CACHE_BYTES); @@ -1362,7 +1363,7 @@ static struct sk_buff *iavf_build_skb(struct iavf_ring *rx_ring, struct iavf_rx_buffer *rx_buffer, unsigned int size) { - void *va = page_address(rx_buffer->page) + rx_buffer->page_offset; + void *va; #if (PAGE_SIZE < 8192) unsigned int truesize = iavf_rx_pg_size(rx_ring) / 2; #else @@ -1374,6 +1375,7 @@ static struct sk_buff *iavf_build_skb(struct iavf_ring *rx_ring, if (!rx_buffer) return NULL; /* prefetch first cache line of first page */ + va = page_address(rx_buffer->page) + rx_buffer->page_offset; prefetch(va); #if L1_CACHE_BYTES < 128 prefetch(va + L1_CACHE_BYTES); -- 2.20.1