<div dir="auto"><div>On mobile, sorry for html crud and top posting, but here:<div dir="auto"><br><div dir="auto"><a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e9092d0d97961146655ce51f43850907d95f68c3">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e9092d0d97961146655ce51f43850907d95f68c3</a><br></div><div dir="auto"><br></div><div dir="auto"> Should fix it.</div><div dir="auto"><br></div><div dir="auto">     Linus</div><div dir="auto"><br></div><div dir="auto"><br></div></div><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Apr 9, 2018, 14:56 Jens Axboe <<a href="mailto:axboe@kernel.dk">axboe@kernel.dk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 4/9/18 3:26 PM, Jens Axboe wrote:<br>
> On 4/9/18 1:32 PM, Jens Axboe wrote:<br>
>> On 4/9/18 12:38 PM, Mike Snitzer wrote:<br>
>>> On Mon, Apr 09 2018 at 11:51am -0400,<br>
>>> Mike Snitzer <<a href="mailto:snitzer@redhat.com" target="_blank" rel="noreferrer">snitzer@redhat.com</a>> wrote:<br>
>>><br>
>>>> On Sun, Apr 08 2018 at 12:00am -0400,<br>
>>>> Ming Lei <<a href="mailto:ming.lei@redhat.com" target="_blank" rel="noreferrer">ming.lei@redhat.com</a>> wrote:<br>
>>>><br>
>>>>> Hi,<br>
>>>>><br>
>>>>> The following kernel oops(divide error) is triggered when running<br>
>>>>> xfstest(generic/347) on ext4.<br>
>>>>><br>
>>>>> [  442.632954] run fstests generic/347 at 2018-04-07 18:06:44<br>
>>>>> [  443.839480] divide error: 0000 [#1] PREEMPT SMP PTI<br>
>>>>> [  443.840201] Dumping ftrace buffer:<br>
>>>>> [  443.840692]    (ftrace buffer empty)<br>
>>> ...<br>
>>>>> [  443.845756] CPU: 1 PID: 29607 Comm: dmsetup Not tainted 4.16.0_f605ba97fb80_master+ #1<br>
>>>>> [  443.846968] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.10.2-2.fc27 04/01/2014<br>
>>>>> [  443.848147] RIP: 0010:pool_io_hints+0x77/0x153 [dm_thin_pool]<br>
>>><br>
>>> ...<br>
>>><br>
>>>> I was able to reproduce (in my case RIP was pool_io_hints+0x45)<br>
>>>><br>
>>>> Which on my kernel, is:<br>
>>>><br>
>>>> crash> dis -l pool_io_hints+0x45<br>
>>>> /root/snitm/git/linux/drivers/md/dm-thin.c: 2748<br>
>>>> 0xffffffffc0765165 <pool_io_hints+69>:  div    %rdi<br>
>>>><br>
>>>> Which is drivers/md/dm-thin.c:is_factor()'s return<br>
>>>> !sector_div(block_size, n);<br>
>>>><br>
>>>> SO looking at pool_io_hints() it would seem limits->max_sectors is 0 for<br>
>>>> this xfstests device... why would that be!?<br>
>>>><br>
>>>> Clearly pool_io_hints() could stand to be more defensive with a<br>
>>>> !limits->max_sectors negative check but is it ever really valid for<br>
>>>> max_sectors to be 0?<br>
>>>><br>
>>>> Pretty sure the ultimate bug is outside DM (but not seeing an obvious<br>
>>>> place where block core would set max_sectors to 0, all blk-settings.c<br>
>>>> uses min_not_zero(), etc).<br>
>>><br>
>>> I successfully ran this test against the linux-dm.git<br>
>>> "for-4.17/dm-changes" tag that Linus merged after the block changes:<br>
>>>  git://<a href="http://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git" rel="noreferrer noreferrer" target="_blank">git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git</a> tags/for-4.17/dm-changes<br>
>>><br>
>>> # ./check tests/generic/347<br>
>>> FSTYP         -- ext4<br>
>>> PLATFORM      -- Linux/x86_64 thegoat 4.16.0-rc5.snitm<br>
>>> MKFS_OPTIONS  -- /dev/mapper/test-xfstests_scratch<br>
>>> MOUNT_OPTIONS -- -o acl,user_xattr /dev/mapper/test-xfstests_scratch /scratch<br>
>>><br>
>>> generic/347      65s<br>
>>> Ran: generic/347<br>
>>> Passed all 1 tests<br>
>>><br>
>>> SO this would seem to implicate some regression in the 4.17 block layer<br>
>>> changes.<br>
>><br>
>> No immediate ideas come to mind, we didn't have a lot of changes and I<br>
>> don't see anything that looks problematic. Maybe you can try and<br>
>> bisect it and see what you come up with?<br>
><br>
> I ran it, problematic commit is:<br>
><br>
> commit 3c8ba0d61d04ced9f8d9ff93977995a9e4e96e91<br>
> Author: Kees Cook <<a href="mailto:keescook@chromium.org" target="_blank" rel="noreferrer">keescook@chromium.org</a>><br>
> Date:   Fri Mar 30 18:52:36 2018 -0700<br>
><br>
>     kernel.h: Retain constant expression output for max()/min()<br>
><br>
<br>
The fun continues. Thinking I'd try a userspace repro and thinking it<br>
would be difficult to reproduce, try the attached min.c that just copies<br>
all the bits from include/linux/kernel.h<br>
<br>
axboe@x1:~ $ gcc -Wall -O2 -o min min.c<br>
axboe@x1:~ $ ./min 128 256<br>
min_not_zero(128, 256) = 0<br>
<br>
--<br>
Jens Axboe<br>
<br>
</blockquote></div></div></div>