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] [day] [month] [year] [list]
Message-ID: <8138f79c-7390-4754-b5f0-8320e82f81f8@oracle.com>
Date: Tue, 1 Oct 2024 16:48:51 +0100
From: John Garry <john.g.garry@...cle.com>
To: "Darrick J. Wong" <djwong@...nel.org>
Cc: axboe@...nel.dk, brauner@...nel.org, viro@...iv.linux.org.uk, jack@...e.cz,
        dchinner@...hat.com, hch@....de, cem@...nel.org,
        linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-xfs@...r.kernel.org, linux-fsdevel@...r.kernel.org, hare@...e.de,
        martin.petersen@...cle.com, catherine.hoang@...cle.com,
        mcgrof@...nel.org, ritesh.list@...il.com, ojaswin@...ux.ibm.com
Subject: Re: [PATCH v6 6/7] xfs: Validate atomic writes

On 01/10/2024 15:48, Darrick J. Wong wrote:
>> --- a/fs/iomap/direct-io.c
>> +++ b/fs/iomap/direct-io.c
>> @@ -679,7 +679,12 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter
>> *iter,
>>   			if (ret != -EAGAIN) {
>>   				trace_iomap_dio_invalidate_fail(inode, iomi.pos,
>>   								iomi.len);
>> -				ret = -ENOTBLK;
>> +				if (iocb->ki_flags & IOCB_ATOMIC) {
>> +					if (ret == -ENOTBLK)
>> +						ret = -EAGAIN;
> I don't follow the logic here -- all the error codes except for EAGAIN
> are squashed into ENOTBLK, so why would we let them through for an
> atomic write?

Right, the errors apart from EAGAIN are normally squashed to ENOTBLK; 
but I thought that since we would not do this for IOCB_ATOMIC, then just 
return the actual error from kiocb_invalidate_pages() - apart from 
ENOTBLK, which has this special treatment.

But I can always just return EAGAIN for IOCB_ATOMIC when 
kiocb_invalidate_pages() errors, as you suggest below.

> 
> 	if (ret != -EAGAIN) {
> 		trace_iomap_dio_invalidate_fail(inode, iomi.pos,
> 						iomi.len);
> 
> 		if (iocb->ki_flags & IOCB_ATOMIC) {
> 			/*
> 			 * folio invalidation failed, maybe this is
> 			 * transient, unlock and see if the caller
> 			 * tries again
> 			 */
> 			return -EAGAIN;
> 		} else {
> 			/* fall back to buffered write */
> 			return -ENOTBLK;
> 		}
> 	}

Cheers,
John

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ