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: <ZtQRKfuawk6borTL@visitorckw-System-Product-Name>
Date: Sun, 1 Sep 2024 15:00:57 +0800
From: Kuan-Wei Chiu <visitorckw@...il.com>
To: imandevel@...il.com
Cc: jack@...e.cz, amir73il@...il.com, linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] inotify: set ret in inotify_read() to -EAGAIN only when
 O_NONBLOCK is set

On Sat, Aug 31, 2024 at 11:01:50PM -0400, imandevel@...il.com wrote:
> From: Iman Seyed <ImanDevel@...il.com>
> 
> Avoid setting ret to -EAGAIN unnecessarily. Only set
> it when O_NONBLOCK is specified; otherwise, leave ret
> unchanged and proceed to set it to -ERESTARTSYS.
>

Hi Iman,

Have you checked the code generated by gcc before and after applying
this patch? My intuition suggests that the compiler optimization might
result in the same code being produced.

Regards,
Kuan-Wei

> Signed-off-by: Iman Seyed <ImanDevel@...il.com>
> ---
>  fs/notify/inotify/inotify_user.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
> index 4ffc30606e0b..d5d4b306a33d 100644
> --- a/fs/notify/inotify/inotify_user.c
> +++ b/fs/notify/inotify/inotify_user.c
> @@ -279,9 +279,11 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
>  			continue;
>  		}
>  
> -		ret = -EAGAIN;
> -		if (file->f_flags & O_NONBLOCK)
> +		if (file->f_flags & O_NONBLOCK) {
> +			ret = -EAGAIN;
>  			break;
> +		}
> +
>  		ret = -ERESTARTSYS;
>  		if (signal_pending(current))
>  			break;
> -- 
> 2.46.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ