Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3819511ybi; Mon, 29 Jul 2019 13:14:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwx7LwdorAe9eXSZTgrextyFXxXbZscR+3hXFy3TEi1gilq/LnQFw60jLdA3X64cw2wOQqL X-Received: by 2002:a17:90a:bb01:: with SMTP id u1mr111504803pjr.92.1564431295149; Mon, 29 Jul 2019 13:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431295; cv=none; d=google.com; s=arc-20160816; b=u1TNmm1Vqk0uKQJBa7HRoNwslxYwhvbhms2JCE5Ba9GbpzxF3sWDNiEdVP99eU1W86 YfYwheL95CRstYVx1/RtqSQ8GbjZoFxNW6jDfj6KkxjaSSeKfh2WawQgORYRlV6iwe6D yccd23ZfnbcoCJZagRnq0oPbR4Mc8DCHCElnZ6WYllwNp2qsgOPUu2WZ09XLlZu0K/oT z28fagjMHAgS1ccFZOrm0GU231rOVo8PikEFBXnf6pBaTsYL7BiFEpvfmUpCI9WeKPz+ /dryp6lZ52iyU/8ODMoXuC20AmoHbUTtDsf+2vI+WJfDdv14yYLMc8odxnVTtR62QdWJ iuHw== 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=3xwsU/aCyuYg7huy58NX2VaSD6VGae7NiqcJsLPGnwA=; b=cKLyyk4iCN1726x8A4DJPA7X91oAMw4zguaytDQqSFL+jRD8BE8eKwRgH8m/uLZo5g xPO2WaHtNc7QunXYKUYbQ9tEl8b0i7LoDanww6ZbcqVLcQmYJp4JwjUXx9lLRnkmuf3d YD6vR4eZNShai8KhIET+oCGBOAVkbIYJA2Z4bbv5RYocRVgeLjsmSA0YvxXpmgyymt7p 9AOIqDQSHOjrl3gCgjWE5k8uyW3QeoUwld0EtF4697LVPS7yXzDDyKdb0tE85rOIcXmN Bp0wQwB8wiQLWtr8l+0s1U1sjmm/xmeobcF0XEUZ0aiAAusz2FKa9qvqTU7fQqFa6gE/ 1LVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nfk1pLnG; 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 gn5si26421674plb.170.2019.07.29.13.14.39; Mon, 29 Jul 2019 13:14:55 -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=nfk1pLnG; 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 S1728760AbfG2TbL (ORCPT + 99 others); Mon, 29 Jul 2019 15:31:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:43712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727655AbfG2TbB (ORCPT ); Mon, 29 Jul 2019 15:31:01 -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 A78D921655; Mon, 29 Jul 2019 19:30:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428660; bh=tb6Wue0nMrY0wThjJWknmrt5Xv4PEKW57ycJTLp7c4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nfk1pLnGyeBMk0jM0wBiiCn8hWnBYmx/KEcZahCUIFmCiRy0yPa0SH0F2B1VVbRzr qmvBiN3xNfSQa6nXf1tTi60yXTelrYBv4pYxzeSJpddr/SeE5XR+I9pPcT6f+9+tYo c3gM0ro8CZVnBCEX2d3mpGp69p1Rac4TdCp0aezE= 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.14 106/293] iavf: fix dereference of null rx_buffer pointer Date: Mon, 29 Jul 2019 21:19:57 +0200 Message-Id: <20190729190832.782080642@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 7368b0dc3af8..4afdabbe95e8 100644 --- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c +++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c @@ -1117,7 +1117,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 @@ -1127,6 +1127,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); @@ -1181,7 +1182,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 @@ -1191,6 +1192,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