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: <2c9c9ffe-13c4-44b8-982a-a3b4070b8a11@linux.alibaba.com>
Date: Wed, 6 Mar 2024 22:45:56 +0800
From: Wen Gu <guwen@...ux.alibaba.com>
To: Dmitry Antipov <dmantipov@...dex.ru>,
 "wenjia@...ux.ibm.com" <wenjia@...ux.ibm.com>
Cc: "lvc-project@...uxtesting.org" <lvc-project@...uxtesting.org>,
 "linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
 "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
 "jaka@...ux.ibm.com" <jaka@...ux.ibm.com>
Subject: Re: [lvc-project] [PATCH] [RFC] net: smc: fix fasync leak in
 smc_release()



On 2024/3/5 00:35, Dmitry Antipov wrote:
> On 2/23/24 06:36, Wen Gu wrote:
> 
>> One solution to this issue I can think of is to check whether
>> filp->private_data has been changed when the sock_fasync holds the sock lock,
>> but it inevitably changes the general code..
>>
>> diff --git a/net/socket.c b/net/socket.c
>> index ed3df2f749bf..a28435195854 100644
>> --- a/net/socket.c
>> +++ b/net/socket.c
>> @@ -1443,6 +1443,11 @@ static int sock_fasync(int fd, struct file *filp, int on)
>>                  return -EINVAL;
>>
>>          lock_sock(sk);
>> +       /* filp->private_data has changed */
>> +       if (on && unlikely(sock != filp->private_data)) {
>> +               release_sock(sk);
>> +               return -EAGAIN;
>> +       }
>>          fasync_helper(fd, filp, on, &wq->fasync_list);
>>
>>          if (!wq->fasync_list)
>>
>> Let's see if anyone else has a better idea.
> 
> IIUC this is not a solution just because it decreases the probability of the race
> but doesn't eliminate it completely - an underlying socket switch (e.g. changing
> 'filp->private_data') may happen when 'fasync_helper()' is in progress.
> 
Hi Dmitry,

IIUC, the fallback (or more precisely the private_data change) essentially
always happens when the lock_sock(smc->sk) is held, except in smc_listen_work()
or smc_listen_decline(), but at that moment, userspace program can not yet
acquire this new socket to add fasync entries to the fasync_list.

So IMHO, the above patch should work, since it checks the private_data under
the lock_sock(sk). But if I missed something, please correct me.

And I wonder if you can still see the leak with the patch above through
your reproducer or syzbot's reproducer? I once ran your reproducer for about
50 mins and didn't see the leak.

Thanks!

> Dmitry
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ