Public bug reported:

[Impact]

On 64K page-size arm64 kernels, an O_DIRECT buffer that violates the block
device's dma_alignment is dispatched to the driver unvalidated. NVMe rejects
it with Invalid Field in Command (sct 0x0 / sc 0x13), so userspace gets EIO
instead of the documented EINVAL and dmesg logs an I/O error per request. 4K
kernels are unaffected.

Regression from 7eac33186957 and 5ff3f74e145a, both v6.18-rc1. Affects v6.18
through v7.1; <= 6.17 is fine.

[Fix]

https://git.kernel.org/linus/9b0c3673c88588d613d8f09f5931b2b466c6a83d
"block: check bio split for unaligned bvec" (Keith Busch, v7.2-rc1)

Two lines in bio_may_need_split(). Cherry-picks cleanly. Carries no Cc: stable
and no v7.0.x / v7.1.x tag contains it, so it will not arrive on its own.

[Test Plan]

On a 64K page-size kernel, on a filesystem that honours O_DIRECT (ext4 mounted
data=journal falls back to buffered I/O, so check tune2fs -l first):

    /opt/ltp/testcases/bin/diotest4            # dio04
    /opt/ltp/testcases/bin/diotest4 -b 65536   # dio10

Bad:  subtests 14/15/16 TFAIL "Input/output error", 1/15 blocks failed, and
      dmesg logs nvme "I/O Error (sct 0x0 / sc 0x13)" with phys_seg 1.
Good: "15 testblocks completed", dmesg clean.

Without LTP: O_DIRECT pread/pwrite of 4096 bytes at offset 0 from a
page-aligned buffer + 1. Bad returns EIO, good returns EINVAL.

[Where problems could occur]

Two lines in one static inline in block/blk.h, private to block/, single
caller - no exported symbol or module ABI surface. Over-triggering only costs
the slow path: the predicate tests the raw bvec, and bio_split_io_at()
re-tests the iterator-adjusted values.

The behavioural change is that bios genuinely violating dma_alignment now fail
EINVAL rather than being dispatched. They were already rejected whenever they
took the split path, and <= 6.17 rejected them in iomap, so this restores prior
behaviour. Residual risk is out-of-spec O_DIRECT that currently succeeds on a
device tolerating misaligned DMA; userspace has depended on lax O_DIRECT before
(LP#2137698), so exercising O_DIRECT-sensitive tooling is worthwhile.

** Affects: linux-nvidia-bos (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2165055

Title:
  Backport: "block: check bio split for unaligned bvec"

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux-nvidia-bos/+bug/2165055/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to