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] [day] [month] [year] [list]
Message-ID: <ba103154-ff05-47e1-98be-5204c26f345f@suse.de>
Date: Thu, 28 Mar 2024 15:18:02 +0300
From: Denis Kirjanov <dkirjanov@...e.de>
To: Eric Dumazet <edumazet@...gle.com>, Denis Kirjanov <kirjanov@...il.com>
Cc: netdev@...r.kernel.org, jgg@...pe.ca, leon@...nel.org,
 syzbot+5fe14f2ff4ccbace9a26@...kaller.appspotmail.com
Subject: Re: [PATCH v2 net] RDMA/core: fix UAF in ib_get_eth_speed



On 3/28/24 14:51, Eric Dumazet wrote:
> On Thu, Mar 28, 2024 at 12:32 PM Denis Kirjanov <kirjanov@...il.com> wrote:
>>
>> A call to ib_device_get_netdev from ib_get_eth_speed
>> may lead to a race condition while accessing a netdevice
>> instance since we don't hold the rtnl lock while checking
>> the registration state:
>>         if (res && res->reg_state != NETREG_REGISTERED) {
>>
>> v2: unlock rtnl on error patch
>>
> 
> What about other callers of ib_device_get_netdev() ?

I'll add ASSERT_RTNL() to ib_device_get_netdev and update the remaining callers.

Thanks!

> 
> It seems they also could be racy.
> 
>> Reported-by: syzbot+5fe14f2ff4ccbace9a26@...kaller.appspotmail.com
>> Fixes: d41861942fc55 ("IB/core: Add generic function to extract IB speed from netdev")
>> Signed-off-by: Denis Kirjanov <dkirjanov@...e.de>
>> ---
>>  drivers/infiniband/core/verbs.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
>> index 94a7f3b0c71c..9c09d8c328b4 100644
>> --- a/drivers/infiniband/core/verbs.c
>> +++ b/drivers/infiniband/core/verbs.c
>> @@ -1976,11 +1976,13 @@ int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width)
>>         if (rdma_port_get_link_layer(dev, port_num) != IB_LINK_LAYER_ETHERNET)
>>                 return -EINVAL;
>>
>> +       rtnl_lock();
>>         netdev = ib_device_get_netdev(dev, port_num);
>> -       if (!netdev)
>> +       if (!netdev) {
>> +               rtnl_unlock()
>>                 return -ENODEV;
>> +       }
>>
>> -       rtnl_lock();
>>         rc = __ethtool_get_link_ksettings(netdev, &lksettings);
>>         rtnl_unlock();
>>
>> --
>> 2.30.2
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ