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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 8 Aug 2014 22:38:47 +0100
From:	Anton Altaparmakov <aia21@....ac.uk>
To:	Al Viro <viro@...iv.linux.org.uk>
Cc:	linux-fsdevel <linux-fsdevel@...r.kernel.org>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: Bug introduced in 3b93f911d5

Hi Al,

On 8 Aug 2014, at 16:54, Al Viro <viro@...iv.linux.org.uk> wrote:
> On Fri, Aug 08, 2014 at 12:11:39AM +0100, Anton Altaparmakov wrote:
>> Hi Al,
>> 
>> Was just looking at __generic_file_write_iter() and found a bug in the code that you added in 3b93f911d5.
>> 
>> Consider the case where generic_file_direct_write() returns a partial write, i.e. written > 0 && written < count.
>> 
>> Also consider that the following generic_perform_write() fails with an error, i.e. status < 0.
> 
> *nod*
> 
> What we ought to do, AFAICS, is this:
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 900edfa..8163e04 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2584,7 +2584,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
> 		 * that this differs from normal direct-io semantics, which
> 		 * will return -EFOO even if some bytes were written.
> 		 */
> -		if (unlikely(status < 0) && !written) {
> +		if (unlikely(status < 0)) {
> 			err = status;
> 			goto out;
> 		}
> 
> Note that we return written ? written : err, so assignment to err will be
> the right thing both when status < 0 && written == 0 and when status < 0 &&
> written > 0.  In the latter case err will be simply ignored.
> 
> Objections?

No objections from me.  As you say, that will do the right thing in all cases.

Best regards,

	Anton
-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
University of Cambridge Information Services, Roger Needham Building
7 JJ Thomson Avenue, Cambridge, CB3 0RB, UK

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists