linux/fs/iomap
Jan Stancek e9f930ac88 iomap: fix return value of iomap_dio_bio_actor on 32bit systems
Naresh reported LTP diotest4 failing for 32bit x86 and arm -next
kernels on ext4. Same problem exists in 5.4-rc7 on xfs.

The failure comes down to:
  openat(AT_FDCWD, "testdata-4.5918", O_RDWR|O_DIRECT) = 4
  mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f7b000
  read(4, 0xb7f7b000, 4096)              = 0 // expects -EFAULT

Problem is conversion at iomap_dio_bio_actor() return. Ternary
operator has a return type and an attempt is made to convert each
of operands to the type of the other. In this case "ret" (int)
is converted to type of "copied" (unsigned long). Both have size
of 4 bytes:
    size_t copied = 0;
    int ret = -14;
    long long actor_ret = copied ? copied : ret;

    On x86_64: actor_ret == -14;
    On x86   : actor_ret == 4294967282

Replace ternary operator with 2 return statements to avoid this
unwanted conversion.

Fixes: 4721a60109 ("iomap: dio data corruption and spurious errors when pipes fill")
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-11-11 12:58:24 -08:00
..
apply.c iomap: use a srcmap for a read-modify-write I/O 2019-10-21 08:51:59 -07:00
buffered-io.c iomap: Fix overflow in iomap_page_mkwrite 2019-11-07 07:28:18 -08:00
direct-io.c iomap: fix return value of iomap_dio_bio_actor on 32bit systems 2019-11-11 12:58:24 -08:00
fiemap.c iomap: iomap_bmap should check iomap_apply return value 2019-11-08 07:44:12 -08:00
Makefile iomap: lift common tracing code from xfs to iomap 2019-10-21 08:51:59 -07:00
seek.c iomap: use a srcmap for a read-modify-write I/O 2019-10-21 08:51:59 -07:00
swapfile.c iomap: use a srcmap for a read-modify-write I/O 2019-10-21 08:51:59 -07:00
trace.c iomap: lift common tracing code from xfs to iomap 2019-10-21 08:51:59 -07:00
trace.h iomap: lift the xfs writeback code to iomap 2019-10-21 08:51:59 -07:00