Received: by 10.223.164.197 with SMTP id h5csp653238wrb; Sat, 4 Nov 2017 21:44:57 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QWXY3Yc8mGi8nlMHROE1hPNQOX5jIF/mjGnvCTLslT/NrijQMSTM66MGzbhI+mhCwzzqyY X-Received: by 10.98.66.206 with SMTP id h75mr12843457pfd.76.1509857097436; Sat, 04 Nov 2017 21:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509857097; cv=none; d=google.com; s=arc-20160816; b=OX4tYJ6xgp6Kx+9hhgnAiVExTlgzMzRgg417rCxFIlegWalP/k8TajU11/s2ZQj3k4 XIUkIrjBsmx/WZ4Q9va4aJNINFrbM2o1dK83U+DWnhHws7z6Wy5BAEA+9zQEqKgnlMLS gSqqREpRoTEon9SIqHuB0tky5fiP2cW0c+TrG2E4tAO/daA9LrLvEZdtxGxt9ol4TAbF tWb2wym9pzztL5A0v9wF1OjJiKDcBuKLllM5Iy2rG6q4xMl+JwahELauRZJIgvS1VgbV HOT1Ip50I6LcgNeYR0epIIAA/Iu4tO4E4tL06P7pYbWqAGfYKNvh7fGzctsVbjYQY8af a2gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=MumqPmiy3Zsy/U9KCTewALs5mBnL5gg5j5kb+pBYBlc=; b=pldMf5HSYw+lAfI7wdUkTWANTqzPbdfHxtkqmn9qhomChfjPe9JX1AcfjYw23oZi29 mNEMmkAVorruJuGW0lnqEfcZVh5S8NS9LtQFtfAoLcj83gEc0zfaE48LdZH+wjiRasuW +vkff8xxQslO76XZ33Z6hng3raUVFcHg/DVtkq+kBiSunvNSaqU6scUj6qI/1VMvJ/Yr dbdgF8k516gkUoBan0X08TqxhFNxR4iXfyhrc4dDKVYPkMpI2Ocp0oXU/SLPD2oXQ85a 16fC7mZV53dz0H8tVab6WBwX2GZc1wrifoSHNn5K06evMxC+V+PM8imjbhpPuX21FuyZ 3qlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dev-mellanox-co-il.20150623.gappssmtp.com header.s=20150623 header.b=yV4pmCiU; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.co.il Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v61si7987938plb.248.2017.11.04.21.44.33; Sat, 04 Nov 2017 21:44:57 -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=@dev-mellanox-co-il.20150623.gappssmtp.com header.s=20150623 header.b=yV4pmCiU; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.co.il Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751184AbdKEEni (ORCPT + 97 others); Sun, 5 Nov 2017 00:43:38 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:53365 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750751AbdKEEng (ORCPT ); Sun, 5 Nov 2017 00:43:36 -0400 Received: by mail-lf0-f66.google.com with SMTP id l23so7126759lfk.10 for ; Sat, 04 Nov 2017 21:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=MumqPmiy3Zsy/U9KCTewALs5mBnL5gg5j5kb+pBYBlc=; b=yV4pmCiUeOIHrf8Oyf5NSSjMY1Yiq4abRnwG+CNa/H/Hal6X45SinuNbEvkA/fntuQ r20jiPHzQV4dmt3LfcaZAuf1sYqz3wHQgm6dNJT7rRV5hu4HUVkeEzxRQ4+8JQQcXD5i IXywvi5BdoHVxtWrUqOUQnI8kX2kJqVXJrBRdwJN3tKJtzydOfZy2Mboxs7H/gG61X5N SpkpM3K7PUcqJMQzhozYUaEH88GsMJQwdOlGR1bkM5sFvYoq5JmMSn30XFfwVgzbZ4i1 ATQEYemynuxhu8MtlEKTQb/srwPDODYkgtVcDxhKBZTqOQNRWK10o3Gp3LjnnfkgRILm TaIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=MumqPmiy3Zsy/U9KCTewALs5mBnL5gg5j5kb+pBYBlc=; b=GVd+JCoJfa9TxVlotTNKSr3RZvT52wDLN3vZzIanxm1jJk4rLgvG6oxO3vOIU3P2RY gHfR7PKoc9GSkrRhGGW2L2mSjXtcoK2idaJ9E43Z7L8dF79HM5RH5uzDgwhesc4L2Q1X V7vzNpp5L4LygiSbf7h9TnQwAvs9VsyLOvhFCTurpcl4mq0EEYr6oK91xeCISBt0FRAW lZVy63eA3ZKXO58TTr89MPo2gmkEBb6g8WE7r7ZEnIGADaZ/MfFoop3qyT2jBWElgbWR A9mm01ZeZLQh8eMXsI1vzZJAWoxB7n4SMBGIsWxmI5bxWIXeV2bDyagAy6bX3hblwcKI oZiw== X-Gm-Message-State: AJaThX4MrT9M2w1kZX6xlksndlTfHYG8VB4kRFz3jnkT/4TALARW8Iy7 50lBN33nSDVMMAv5Tct8m3/jgWB8NAW61tBwzC8Dmg== X-Received: by 10.25.17.21 with SMTP id g21mr3839321lfi.170.1509857014818; Sat, 04 Nov 2017 21:43:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.59.142 with HTTP; Sat, 4 Nov 2017 21:43:14 -0700 (PDT) In-Reply-To: <20171105035453.GA10908@embeddedor.com> References: <20171105035453.GA10908@embeddedor.com> From: Saeed Mahameed Date: Sat, 4 Nov 2017 21:43:14 -0700 Message-ID: Subject: Re: [PATCH] net/mlx5e/core/en_fs: fix pointer dereference after free in mlx5e_execute_l2_action To: "Gustavo A. R. Silva" Cc: Saeed Mahameed , Matan Barak , Leon Romanovsky , Linux Netdev List , linux-rdma@vger.kernel.org, linux-kernel , Jes Sorensen , Martin KaFai Lau Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 4, 2017 at 8:54 PM, Gustavo A. R. Silva wrote: > hn is being kfree'd in mlx5e_del_l2_from_hash and then dereferenced > by accessing hn->ai.addr > > Fix this by copying the MAC address into a local variable for its safe use > in all possible execution paths within function mlx5e_execute_l2_action. > > Addresses-Coverity-ID: 1417789 > Fixes: eeb66cdb6826 ("net/mlx5: Separate between E-Switch and MPFS") > Signed-off-by: Gustavo A. R. Silva Acked-by: Saeed Mahameed Looks good. Thank you Gustavo. > --- > drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c > index 850cdc9..4837045 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c > @@ -365,21 +365,24 @@ static void mlx5e_execute_l2_action(struct mlx5e_priv *priv, > struct mlx5e_l2_hash_node *hn) > { > u8 action = hn->action; > + u8 mac_addr[ETH_ALEN]; > int l2_err = 0; > > + ether_addr_copy(mac_addr, hn->ai.addr); > + > switch (action) { > case MLX5E_ACTION_ADD: > mlx5e_add_l2_flow_rule(priv, &hn->ai, MLX5E_FULLMATCH); > - if (!is_multicast_ether_addr(hn->ai.addr)) { > - l2_err = mlx5_mpfs_add_mac(priv->mdev, hn->ai.addr); > + if (!is_multicast_ether_addr(mac_addr)) { > + l2_err = mlx5_mpfs_add_mac(priv->mdev, mac_addr); > hn->mpfs = !l2_err; > } > hn->action = MLX5E_ACTION_NONE; > break; > > case MLX5E_ACTION_DEL: > - if (!is_multicast_ether_addr(hn->ai.addr) && hn->mpfs) > - l2_err = mlx5_mpfs_del_mac(priv->mdev, hn->ai.addr); > + if (!is_multicast_ether_addr(mac_addr) && hn->mpfs) > + l2_err = mlx5_mpfs_del_mac(priv->mdev, mac_addr); > mlx5e_del_l2_flow_rule(priv, &hn->ai); > mlx5e_del_l2_from_hash(hn); > break; > @@ -387,7 +390,7 @@ static void mlx5e_execute_l2_action(struct mlx5e_priv *priv, > > if (l2_err) > netdev_warn(priv->netdev, "MPFS, failed to %s mac %pM, err(%d)\n", > - action == MLX5E_ACTION_ADD ? "add" : "del", hn->ai.addr, l2_err); > + action == MLX5E_ACTION_ADD ? "add" : "del", mac_addr, l2_err); > } > > static void mlx5e_sync_netdev_addr(struct mlx5e_priv *priv) > -- > 2.7.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html From 1583196851542878610@xxx Sun Nov 05 03:56:15 +0000 2017 X-GM-THRID: 1583196851542878610 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread