From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Khorenko Subject: [PATCH 1/1] drivers/net/i40e: define proper net_device::neigh_priv_len Date: Fri, 23 Nov 2018 19:10:28 +0300 Message-ID: <20181123161028.22633-2-khorenko@virtuozzo.com> References: <20181123161028.22633-1-khorenko@virtuozzo.com> Cc: Konstantin Khorenko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, "David S . Miller" To: Jeff Kirsher Return-path: Received: from relay.sw.ru ([185.231.240.75]:47850 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388714AbeKXCz2 (ORCPT ); Fri, 23 Nov 2018 21:55:28 -0500 In-Reply-To: <20181123161028.22633-1-khorenko@virtuozzo.com> Sender: netdev-owner@vger.kernel.org List-ID: Out of bound read reported by KASan. i40iw_net_event() reads unconditionally 16 bytes from neigh->primary_key while the memory allocated for "neighbour" struct is evaluated in neigh_alloc() as tbl->entry_size + dev->neigh_priv_len where "dev" is a net_device. But the driver does not setup dev->neigh_priv_len and we read beyond the neigh entry allocated memory, so the patch in the next mail fixes this. Signed-off-by: Konstantin Khorenko --- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 21c2688d6308..539b8f3738e6 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -12334,6 +12334,9 @@ static int i40e_config_netdev(struct i40e_vsi *vsi) ether_addr_copy(netdev->dev_addr, mac_addr); ether_addr_copy(netdev->perm_addr, mac_addr); + /* i40iw_net_event() reads 16 bytes from neigh->primary_key */ + netdev->neigh_priv_len = sizeof(u32) * 4; + netdev->priv_flags |= IFF_UNICAST_FLT; netdev->priv_flags |= IFF_SUPP_NOFCS; /* Setup netdev TC information */ -- 2.15.1