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]
Date: Fri, 5 May 2023 12:37:25 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: ye.xingchen@....com.cn
Cc: davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com, 
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: socket: Use fdget() and fdput()

On Fri, May 5, 2023 at 11:06 AM <ye.xingchen@....com.cn> wrote:
>
> From: Ye Xingchen <ye.xingchen@....com.cn>
>
> By using the fdget function, the socket object, can be quickly obtained
> from the process's file descriptor table without the need to obtain the
> file descriptor first before passing it as a parameter to the fget
> function.
>

net-next is currently closed.

There are good reasons we have sockfd_lookup() and sockfd_lookup_light(),
you probably should take a deeper look at the difference between them.



> Signed-off-by: Ye Xingchen <ye.xingchen@....com.cn>
> ---
>  net/socket.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/net/socket.c b/net/socket.c
> index a7b4b37d86df..84daba774432 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -528,19 +528,18 @@ EXPORT_SYMBOL(sock_from_file);
>
>  struct socket *sockfd_lookup(int fd, int *err)
>  {
> -       struct file *file;
> +       struct fd f = fdget(fd);
>         struct socket *sock;
>
> -       file = fget(fd);
> -       if (!file) {
> +       if (!f.file) {
>                 *err = -EBADF;
>                 return NULL;
>         }
>
> -       sock = sock_from_file(file);
> +       sock = sock_from_file(f.file);
>         if (!sock) {
>                 *err = -ENOTSOCK;
> -               fput(file);
> +               fdput(f);
>         }
>         return sock;
>  }
> --
> 2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ