iomap: enforce DIO alignment check in iomap]#949
Conversation
|
Upstream branch: acb7500 |
5e41a3b to
c3a084b
Compare
|
Upstream branch: 9716c08 |
5c01bcc to
49966b2
Compare
c3a084b to
5f78e5d
Compare
|
Upstream branch: 2a2974b |
49966b2 to
d12b2d3
Compare
5f78e5d to
e48f9db
Compare
|
Upstream branch: 062871f |
d12b2d3 to
e9dad41
Compare
e48f9db to
199644a
Compare
|
Upstream branch: 5b33fc6 |
e9dad41 to
bfce834
Compare
199644a to
e6d9eb8
Compare
|
Upstream branch: 66affa3 |
bfce834 to
ae9bcf5
Compare
e6d9eb8 to
7d8604f
Compare
|
Upstream branch: bade58e |
ae9bcf5 to
510d1f6
Compare
7d8604f to
4cc45a3
Compare
|
Upstream branch: 4edcdef |
510d1f6 to
7da2c3f
Compare
4cc45a3 to
90ffd56
Compare
Sorry, I screwed up two addresses, bouncing them to the right addresses to avoid spamming the lists again. ----- Forwarded message from cem@kernel.org ----- Date: Wed, 10 Jun 2026 16:52:11 +0200 From: cem@kernel.org To: brauner@vger.kernel.org Cc: linux-block@vger.kernel.devel, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, Carlos Maiolino <cem@kernel.org>, Keith Busch <kbusch@kernel.org>, Hannes Reinecke <hare@suse.de>, "Martin K. Petersen" <martin.petersen@oracle.com>, Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk> Subject: [PATCH] iomap: enforce DIO alignment check in iomap Message-ID: <20260610145218.141369-1-cem@kernel.org> X-Mailer: git-send-email 2.54.0 Tags: sent From: Carlos Maiolino <cem@kernel.org> The DIO alignment check has been lifted from iomap layer to rely on the block layer to enforce proper alignment when issuing direct IO operations. This though, depending on the IO size and buffer address passed to the IO operation may lead to user-visible behavior change. This has been caught initially by LTP test diotest4 running on PPC architecture, where the test fails because a read() operation with a supposedly misaligned buffer succeeds instead of an expected -EINVAL. This has no direct relationship with PPC, but seems to do with the IO size crossing page borders or not. The test allocates a 4k buffer, and then increments the buffer pointer by a single byte to enforce a misaligned address. It then issues a 4k read() using such buffer. The read is supposed to return an -EINVAL but it ends up succeeding. The allocated buffer is at least a single page, so the read() size being smaller will end up most of the time within the very same page initially allocated which seems to suffice the block layer to accept the IO. On x86 though, the same 4k read will end up crossing page boundaries causing a bio_split which ends up properly checking the address and rejecting it due to misalignment. The test itself is buggy (which seems by design) because it ends up attempting to read 4096 bytes into a 4095, but I believe the test expected the address to be rejected prior to any write attempt. The problematic behavior is reproducible on x86 by reducing the IO size to something < PAGE_SIZE, so the misaligned read()s will also be accepted by the block layer. Fixing this is just a matter of enforcing daddr and memory alignment back into iomap. This behavior is reproducible in ext4 and xfs due to both relying on iomap layer, btrfs does not present this behavior change as it does its own DIO alignment checking. Fixes: 7eac331 ("iomap: simplify direct io validity check") Cc: Keith Busch <kbusch@kernel.org> Cc: Hannes Reinecke <hare@suse.de> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
|
Upstream branch: dc59e4f |
7da2c3f to
75e9a60
Compare
Pull request for series with
subject: iomap: enforce DIO alignment check in iomap]
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1109391