Re: [syzbot] KASAN: stack-out-of-bounds Read in iov_iter_revert

From: Jens Axboe
Date: Mon Nov 08 2021 - 10:41:56 EST


On 11/8/21 8:29 AM, Pavel Begunkov wrote:
> On 11/3/21 17:01, Lee Jones wrote:
>> Good afternoon Pavel,
>>
>>> syzbot has tested the proposed patch and the reproducer did not trigger any issue:
>>>
>>> Reported-and-tested-by: syzbot+9671693590ef5aad8953@xxxxxxxxxxxxxxxxxxxxxxxxx
>>>
>>> Tested on:
>>>
>>> commit: bff2c168 io_uring: don't retry with truncated iter
>>> git tree: https://github.com/isilence/linux.git truncate
>>> kernel config: https://syzkaller.appspot.com/x/.config?x=730106bfb5bf8ace
>>> dashboard link: https://syzkaller.appspot.com/bug?extid=9671693590ef5aad8953
>>> compiler: Debian clang version 11.0.1-2, GNU ld (GNU Binutils for Debian) 2.35.1
>>>
>>> Note: testing is done by a robot and is best-effort only.
>>
>> As you can see in the 'dashboard link' above this bug also affects
>> android-5-10 which is currently based on v5.10.75.
>>
>> I see that the back-port of this patch failed in v5.10.y:
>>
>> https://lore.kernel.org/stable/163152589512611@xxxxxxxxx/
>>
>> And after solving the build-error by back-porting both:
>>
>> 2112ff5ce0c11 iov_iter: track truncated size
>> 89c2b3b749182 io_uring: reexpand under-reexpanded iters
>>
>> I now see execution tripping the WARN() in iov_iter_revert():
>>
>> if (WARN_ON(unroll > MAX_RW_COUNT))
>> return
>>
>> Am I missing any additional patches required to fix stable/v5.10.y?
>
> Is it the same syz test? There was a couple more patches for
> IORING_SETUP_IOPOLL, but strange if that's not the case.
>
>
> fwiw, Jens decided to replace it with another mechanism shortly
> after, so it may be a better idea to backport those. Jens,
> what do you think?
>
>
> commit 8fb0f47a9d7acf620d0fd97831b69da9bc5e22ed
> Author: Jens Axboe <axboe@xxxxxxxxx>
> Date: Fri Sep 10 11:18:36 2021 -0600
>
> iov_iter: add helper to save iov_iter state
>
> commit cd65869512ab5668a5d16f789bc4da1319c435c4
> Author: Jens Axboe <axboe@xxxxxxxxx>
> Date: Fri Sep 10 11:19:14 2021 -0600
>
> io_uring: use iov_iter state save/restore helpers

Yes, I think backporting based on the save/restore setup is the
sanest way by far.

--
Jens Axboe