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: <20251021070353.96705-7-mngyadam@amazon.de>
Date: Tue, 21 Oct 2025 09:03:40 +0200
From: Mahmoud Adam <mngyadam@...zon.de>
To: <stable@...r.kernel.org>
CC: <gregkh@...uxfoundation.org>, <nagy@...aternagy.com>, Al Viro
	<viro@...iv.linux.org.uk>, Christian Brauner <brauner@...nel.org>, Jens Axboe
	<axboe@...nel.dk>, Xiubo Li <xiubli@...hat.com>, Ilya Dryomov
	<idryomov@...il.com>, Jeff Layton <jlayton@...nel.org>, Theodore Ts'o
	<tytso@....edu>, Andreas Dilger <adilger.kernel@...ger.ca>, Jaegeuk Kim
	<jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>, Christoph Hellwig
	<hch@...radead.org>, "Darrick J. Wong" <djwong@...nel.org>, Trond Myklebust
	<trond.myklebust@...merspace.com>, Anna Schumaker <anna@...nel.org>, "Ryusuke
 Konishi" <konishi.ryusuke@...il.com>, "Matthew Wilcox (Oracle)"
	<willy@...radead.org>, Andrew Morton <akpm@...ux-foundation.org>, "Hannes
 Reinecke" <hare@...e.de>, Damien Le Moal <dlemoal@...nel.org>, "Luis
 Chamberlain" <mcgrof@...nel.org>, <linux-block@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, <ceph-devel@...r.kernel.org>,
	<linux-fsdevel@...r.kernel.org>, <linux-ext4@...r.kernel.org>,
	<linux-f2fs-devel@...ts.sourceforge.net>, <linux-xfs@...r.kernel.org>,
	<linux-nfs@...r.kernel.org>, <linux-nilfs@...r.kernel.org>,
	<linux-mm@...ck.org>
Subject: [PATCH 6.1 5/8] direct_write_fallback(): on error revert the ->ki_pos update from buffered write

From: Al Viro <viro@...iv.linux.org.uk>

commit 8287474aa5ffb41df52552c4ae4748e791d2faf2 upstream.

If we fail filemap_write_and_wait_range() on the range the buffered write went
into, we only report the "number of bytes which we direct-written", to quote
the comment in there.  Which is fine, but buffered write has already advanced
iocb->ki_pos, so we need to roll that back.  Otherwise we end up with e.g.
write(2) advancing position by more than the amount it reports having written.

Fixes: 182c25e9c157 "filemap: update ki_pos in generic_perform_write"
Signed-off-by: Al Viro <viro@...iv.linux.org.uk>
Message-Id: <20230827214518.GU3390869@...IV>
Signed-off-by: Christian Brauner <brauner@...nel.org>
Signed-off-by: Mahmoud Adam <mngyadam@...zon.de>
---
 fs/libfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/libfs.c b/fs/libfs.c
index a5bbe8e31d6616..63bc52c20f7e03 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1615,6 +1615,7 @@ ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter,
 		 * We don't know how much we wrote, so just return the number of
 		 * bytes which were direct-written
 		 */
+		iocb->ki_pos -= buffered_written;
 		if (direct_written)
 			return direct_written;
 		return err;
-- 
2.47.3




Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christian Schlaeger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ