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: <20230505084155.63839-1-ye.xingchen@zte.com.cn>
Date: Fri,  5 May 2023 16:41:55 +0800
From: ye xingchen <yexingchen116@...il.com>
To: jasowang@...hat.com
Cc: kvm@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	mst@...hat.com,
	netdev@...r.kernel.org,
	virtualization@...ts.linux-foundation.org,
	ye.xingchen@....com.cn
Subject: Re: [PATCH] vhost_net: Use fdget() and fdput()

>>
>> From: Ye Xingchen <ye.xingchen@....com.cn>
>>
>> convert the fget()/fput() uses to fdget()/fdput().
>What's the advantages of this?
>
>Thanks
>>
>> Signed-off-by: Ye Xingchen <ye.xingchen@....com.cn>
>> ---
>>  drivers/vhost/net.c | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
>> index ae2273196b0c..5b3fe4805182 100644
>> --- a/drivers/vhost/net.c
>> +++ b/drivers/vhost/net.c
>> @@ -1466,17 +1466,17 @@ static struct ptr_ring *get_tap_ptr_ring(struct file *file)
>>
>>  static struct socket *get_tap_socket(int fd)
>>  {
>> -       struct file *file = fget(fd);
>> +       struct fd f = fdget(fd);
>>         struct socket *sock;
>>
>> -       if (!file)
>> +       if (!f.file)
>>                 return ERR_PTR(-EBADF);
>> -       sock = tun_get_socket(file);
>> +       sock = tun_get_socket(f.file);
>>         if (!IS_ERR(sock))
>>                 return sock;
>> -       sock = tap_get_socket(file);
>> +       sock = tap_get_socket(f.file);
>>         if (IS_ERR(sock))
>> -               fput(file);
>> +               fdput(f);
>>         return sock;
>>  }
>>
>> --
>> 2.25.1
>>
fdget requires an integer type file descriptor as its parameter, 
and fget requires a pointer to the file structure as its parameter.

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. This reduces unnecessary 
operations, improves system efficiency and performance.

Best Regards
Ye

Powered by blists - more mailing lists