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: <380043fa-3208-4856-92b1-be9c87caeeb6@yandex.ru>
Date: Mon, 4 Mar 2024 19:35:04 +0300
From: Dmitry Antipov <dmantipov@...dex.ru>
To: Wen Gu <guwen@...ux.alibaba.com>,
 "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 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.

Dmitry


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ