lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <VI1PR0502MB30089D06B9C95D682E21511BD17D0@VI1PR0502MB3008.eurprd05.prod.outlook.com>
Date:   Mon, 2 Oct 2017 20:36:29 +0000
From:   Parav Pandit <parav@...lanox.com>
To:     Ursula Braun <ubraun@...ux.vnet.ibm.com>,
        "davem@...emloft.net" <davem@...emloft.net>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
        "linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
        "jwi@...ux.vnet.ibm.com" <jwi@...ux.vnet.ibm.com>,
        "schwidefsky@...ibm.com" <schwidefsky@...ibm.com>,
        "heiko.carstens@...ibm.com" <heiko.carstens@...ibm.com>,
        "raspl@...ux.vnet.ibm.com" <raspl@...ux.vnet.ibm.com>
Subject: RE: [PATCH net-next 01/10] net/smc: add missing dev_put

Hi Ursula, Dave, Hans,

> -----Original Message-----
> From: linux-rdma-owner@...r.kernel.org [mailto:linux-rdma-
> owner@...r.kernel.org] On Behalf Of Ursula Braun
> Sent: Wednesday, September 20, 2017 6:58 AM
> To: davem@...emloft.net
> Cc: netdev@...r.kernel.org; linux-rdma@...r.kernel.org; linux-
> s390@...r.kernel.org; jwi@...ux.vnet.ibm.com; schwidefsky@...ibm.com;
> heiko.carstens@...ibm.com; raspl@...ux.vnet.ibm.com;
> ubraun@...ux.vnet.ibm.com
> Subject: [PATCH net-next 01/10] net/smc: add missing dev_put
> 
> From: Hans Wippel <hwippel@...ux.vnet.ibm.com>
> 
> In the infiniband part, SMC currently uses get_netdev which calls dev_hold on
> the returned net device. However, the SMC code never calls dev_put on that net
> device resulting in a wrong reference count.
> 
> This patch adds a dev_put after the usage of the net device to fix the issue.
> 
> Signed-off-by: Hans Wippel <hwippel@...ux.vnet.ibm.com>
> Signed-off-by: Ursula Braun <ubraun@...ux.vnet.ibm.com>
> ---
>  net/smc/smc_ib.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c index
> 547e0e113b17..0b5852299158 100644
> --- a/net/smc/smc_ib.c
> +++ b/net/smc/smc_ib.c
> @@ -380,6 +380,7 @@ static int smc_ib_fill_gid_and_mac(struct smc_ib_device
> *smcibdev, u8 ibport)
>  	ndev = smcibdev->ibdev->get_netdev(smcibdev->ibdev, ibport);
>  	if (ndev) {
>  		memcpy(&smcibdev->mac, ndev->dev_addr, ETH_ALEN);
> +		dev_put(ndev);

I am sorry for providing late comments. smc_ib_fill_gid_and_mac() is not coded correctly.
Few fixes are needed.
1. ULP such as SMC should not open code/deference any function pointer like get_netdev() of the IB device.
2. Replace ib_query_gid(..., NULL)
With
ib_query_gid(..., gid_attr);

Use gid_attr.ndev to get the MAC address.
Do dev_put(gid_attr.ndev);

Code should look like below,

struct ib_gid_attr gid_attr;

rc = ib_query_gid(..., &gid_attr);
if (rc || !gid_addr.ndev)
	return -ENODEV;
else
	memcpy(smcibdev->mac, ndev->dev_addr, ETH_ALEN);
dev_put(gid_addr.ndev);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ