Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10424310ybi; Wed, 24 Jul 2019 22:59:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQUzM/EHk8GpMOV2svr5rPcsfVjx5G8Nsfelvh0ctMLTLrcADVoCoab+jt+EkSyb+sQ/JG X-Received: by 2002:a17:90a:1b0c:: with SMTP id q12mr91896609pjq.76.1564034369476; Wed, 24 Jul 2019 22:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034369; cv=none; d=google.com; s=arc-20160816; b=G16aN+GDKMj/wJ1CeNuDD9EhR9CaHDFVMhCFCOM2hW+CYQ98mhrIrYvyqd/wVez11D hDNUmVU7VDGU+UOASMqSII9ub91KFUcrOnwS/1uc4EMcyshrB92MMB3n4totzEXKUeau Bs1H9hn16sccTSje6hRSy3KhbqaUbJQB9KqjS1qnieI2ScBNEkaOf2EPT6EtQxHWjUdy txDGaOUY+iRMpT9zMRp/dL9xBrUlk9o9qc551e8vJZBuJcJf76zC5F6hdadva/j3XLk4 /hHH85Z7nHqnS0vxLHvdSSFaw8fgTISySxkHJFPfWmvumjwWdvEfocnj1Kvw5w9FG7FL zD3g== 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=Gq/qxQfqUJxWuliDVSkI8vc7BGIS9TPAerRijGYqA7k=; b=DRUUuT0j1nM4w+249w1RfzLBy77HxlugmrS3y34tUNcz44beYjFMy38lja4ata2QWj yEQFm0jI9viqtgSroXM7tdFlSE6vD/oGJsgHAGyM+ZnoTo4ud94uaG5s3HkSW8lQmRAm qA/2vui9H+Wp3gLnD9g+J+DwXy8ssU01LboGYAAQWpCF7IVwDEh3LAaNWBR892jbZtvB zZhaZ4rCA4cXp8tz2B3bfudwuzJ0CgaAOoH9TtvwStzKIN7N3MK3kacpXmBZ/EwJWHMl lwAgnUupweaAXag7UO59ZJQ2KkVD8euoDci3bbE8LDWTfBPqVKbIixlgHIQKfoMcGcAJ Tg+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=reSjXI02; 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 c127si19667316pfc.191.2019.07.24.22.59.14; Wed, 24 Jul 2019 22:59:29 -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=reSjXI02; 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 S2404715AbfGYFlk (ORCPT + 99 others); Thu, 25 Jul 2019 01:41:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:56480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404699AbfGYFli (ORCPT ); Thu, 25 Jul 2019 01:41:38 -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 A41B422C7D; Thu, 25 Jul 2019 05:41:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033298; bh=UMjFdv0pAN4qfa6lMaz4weRI/u2D4aVqZjz25cfTr4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=reSjXI02HGPzM1Gemc7DmJSqQtMVg/+J9Wctzyj6AE+avvXL3vbNr46hrmoDwYi83 rctpNt1A8oy3QVOCsjNgVoIxAlLhgruDq8gYTrXSKwO6fzkolAirByUpZRlbu8oLKM K/xZ1szKL/szOAITSZaQJmAtBDbFsEN7mD4vOEnU= 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 4.19 159/271] iavf: fix dereference of null rx_buffer pointer Date: Wed, 24 Jul 2019 21:20:28 +0200 Message-Id: <20190724191708.823074164@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@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/i40evf/i40e_txrx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c index a9730711e257..b56d22b530a7 100644 --- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c +++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c @@ -1291,7 +1291,7 @@ static struct sk_buff *i40e_construct_skb(struct i40e_ring *rx_ring, struct i40e_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 = i40e_rx_pg_size(rx_ring) / 2; #else @@ -1301,6 +1301,7 @@ static struct sk_buff *i40e_construct_skb(struct i40e_ring *rx_ring, struct sk_buff *skb; /* 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); @@ -1355,7 +1356,7 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring, struct i40e_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 = i40e_rx_pg_size(rx_ring) / 2; #else @@ -1365,6 +1366,7 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring, struct sk_buff *skb; /* 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