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:   Mon, 7 Sep 2020 08:20:26 +0200
From:   Christoph Hellwig <hch@....de>
To:     Rasmus Villemoes <linux@...musvillemoes.dk>
Cc:     Christoph Hellwig <hch@....de>, arnd@...db.de,
        gregkh@...uxfoundation.org, christophe.leroy@...roup.eu,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] /dev/zero: also implement ->read

On Mon, Sep 07, 2020 at 12:34:37AM +0200, Rasmus Villemoes wrote:
> On 03/09/2020 17.59, Christoph Hellwig wrote:
> > Christophe reported a major speedup due to avoiding the iov_iter
> > overhead, so just add this trivial function.  Note that /dev/zero
> > already implements both an iter and non-iter writes so this just
> > makes it more symmetric.
> > 
> > Christophe Leroy <christophe.leroy@...roup.eu>
> 
> ?-by ?

Suggested-by,

> > +static ssize_t read_zero(struct file *file, char __user *buf,
> > +			 size_t count, loff_t *ppos)
> > +{
> > +	size_t cleared = 0;
> > +
> > +	while (count) {
> > +		size_t chunk = min_t(size_t, count, PAGE_SIZE);
> > +
> > +		if (clear_user(buf + cleared, chunk))
> > +			return cleared ? cleared : -EFAULT;
> 
> Probably nobody really cares, but currently doing
> 
> read(fd, &unmapped_page - 5, 123);
> 
> returns 5, and those five bytes do get cleared; if I'm reading the above
> right you'd return -EFAULT for that case.
> 
> 
> > +		cleared += chunk;
> > +		count -= chunk;
> > +
> > +		if (signal_pending(current))
> > +			return cleared ? cleared : -ERESTARTSYS;
> 
> I can't see how we can get here without 'cleared' being positive, so
> this can just be 'return cleared' (and if you fix the above EFAULT case
> to more accurately track how much got cleared, there's probably no
> longer any code to be symmetric with anyway).

Yeah, I'll fix these up and resend.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ