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: <ed21a6b0-be32-e00a-98c3-f25759a44071@kernel.dk>
Date:   Wed, 8 Sep 2021 06:57:09 -0600
From:   Jens Axboe <axboe@...nel.dk>
To:     Pavel Begunkov <asml.silence@...il.com>,
        Arnd Bergmann <arnd@...db.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org
Cc:     io-uring@...r.kernel.org
Subject: Re: [PATCH] /dev/mem: nowait zero/null ops

On 9/8/21 4:06 AM, Pavel Begunkov wrote:
> Make read_iter_zero() to honor IOCB_NOWAIT, so /dev/zero can be
> advertised as FMODE_NOWAIT. This helps subsystems like io_uring to use
> it more effectively. Set FMODE_NOWAIT for /dev/null as well, it never
> waits and therefore trivially meets the criteria.
> 
> Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
> ---
>  drivers/char/mem.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/char/mem.c b/drivers/char/mem.c
> index 1c596b5cdb27..531f144d7132 100644
> --- a/drivers/char/mem.c
> +++ b/drivers/char/mem.c
> @@ -495,6 +495,8 @@ static ssize_t read_iter_zero(struct kiocb *iocb, struct iov_iter *iter)
>  		written += n;
>  		if (signal_pending(current))
>  			return written ? written : -ERESTARTSYS;
> +		if (iocb->ki_flags & IOCB_NOWAIT)
> +			return written ? written : -EAGAIN;
>  		cond_resched();
>  	}

I don't think this part is needed.

>  	return written;
> @@ -696,11 +698,11 @@ static const struct memdev {
>  #ifdef CONFIG_DEVMEM
>  	 [DEVMEM_MINOR] = { "mem", 0, &mem_fops, FMODE_UNSIGNED_OFFSET },
>  #endif
> -	 [3] = { "null", 0666, &null_fops, 0 },
> +	 [3] = { "null", 0666, &null_fops, FMODE_NOWAIT },
>  #ifdef CONFIG_DEVPORT
>  	 [4] = { "port", 0, &port_fops, 0 },
>  #endif
> -	 [5] = { "zero", 0666, &zero_fops, 0 },
> +	 [5] = { "zero", 0666, &zero_fops, FMODE_NOWAIT },
>  	 [7] = { "full", 0666, &full_fops, 0 },
>  	 [8] = { "random", 0666, &random_fops, 0 },
>  	 [9] = { "urandom", 0666, &urandom_fops, 0 },
> 

This looks fine.

-- 
Jens Axboe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ