diff mbox

fs: out of bounds on stack in iov_iter_advance

Message ID 55FB75D0.7060403@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sasha Levin Sept. 18, 2015, 2:24 a.m. UTC
On 08/19/2015 01:46 AM, Al Viro wrote:
>> or mapping->a_ops->direct_IO() returned more
>> > than 'count'.
> 	Was there DAX involved?  ->direct_IO() in there is blkdev_direct_IO(),
> which takes rather different paths in those cases...
> 

So I've traced this all the way back to dax_io(). I can trigger this with:

So it seems that iter gets moved twice here: once in dax_io(), and once again
back at generic_file_read_iter().

I don't see how it ever worked. Am I missing something?


Thanks,
Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Sasha Levin Sept. 30, 2015, 9:30 p.m. UTC | #1
On 09/17/2015 10:24 PM, Sasha Levin wrote:
> On 08/19/2015 01:46 AM, Al Viro wrote:
>>> or mapping->a_ops->direct_IO() returned more
>>>> than 'count'.
>> 	Was there DAX involved?  ->direct_IO() in there is blkdev_direct_IO(),
>> which takes rather different paths in those cases...
>>
> 
> So I've traced this all the way back to dax_io(). I can trigger this with:
> 
> diff --git a/fs/dax.c b/fs/dax.c
> index 93bf2f9..2cdb8a5 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -178,6 +178,7 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
>         if (need_wmb)
>                 wmb_pmem();
> 
> +       WARN_ON((pos == start) && (pos - start > iov_iter_count(iter)));
>         return (pos == start) ? retval : pos - start;
>  }
> 
> So it seems that iter gets moved twice here: once in dax_io(), and once again
> back at generic_file_read_iter().
> 
> I don't see how it ever worked. Am I missing something?

Ping?


Thanks,
Sasha

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sasha Levin Oct. 17, 2015, 7:22 p.m. UTC | #2
On 09/30/2015 05:30 PM, Sasha Levin wrote:
> On 09/17/2015 10:24 PM, Sasha Levin wrote:
>> On 08/19/2015 01:46 AM, Al Viro wrote:
>>>> or mapping->a_ops->direct_IO() returned more
>>>>> than 'count'.
>>> 	Was there DAX involved?  ->direct_IO() in there is blkdev_direct_IO(),
>>> which takes rather different paths in those cases...
>>>
>>
>> So I've traced this all the way back to dax_io(). I can trigger this with:
>>
>> diff --git a/fs/dax.c b/fs/dax.c
>> index 93bf2f9..2cdb8a5 100644
>> --- a/fs/dax.c
>> +++ b/fs/dax.c
>> @@ -178,6 +178,7 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
>>         if (need_wmb)
>>                 wmb_pmem();
>>
>> +       WARN_ON((pos == start) && (pos - start > iov_iter_count(iter)));
>>         return (pos == start) ? retval : pos - start;
>>  }
>>
>> So it seems that iter gets moved twice here: once in dax_io(), and once again
>> back at generic_file_read_iter().
>>
>> I don't see how it ever worked. Am I missing something?
> 
> Ping?

Ping?


Thanks,
Sasha

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ross Zwisler Oct. 18, 2015, 4:17 a.m. UTC | #3
On Sat, Oct 17, 2015 at 03:22:19PM -0400, Sasha Levin wrote:
> On 09/30/2015 05:30 PM, Sasha Levin wrote:
> > On 09/17/2015 10:24 PM, Sasha Levin wrote:
> >> On 08/19/2015 01:46 AM, Al Viro wrote:
> >>>> or mapping->a_ops->direct_IO() returned more
> >>>>> than 'count'.
> >>> 	Was there DAX involved?  ->direct_IO() in there is blkdev_direct_IO(),
> >>> which takes rather different paths in those cases...
> >>>
> >>
> >> So I've traced this all the way back to dax_io(). I can trigger this with:
> >>
> >> diff --git a/fs/dax.c b/fs/dax.c
> >> index 93bf2f9..2cdb8a5 100644
> >> --- a/fs/dax.c
> >> +++ b/fs/dax.c
> >> @@ -178,6 +178,7 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
> >>         if (need_wmb)
> >>                 wmb_pmem();
> >>
> >> +       WARN_ON((pos == start) && (pos - start > iov_iter_count(iter)));
> >>         return (pos == start) ? retval : pos - start;
> >>  }
> >>
> >> So it seems that iter gets moved twice here: once in dax_io(), and once again
> >> back at generic_file_read_iter().
> >>
> >> I don't see how it ever worked. Am I missing something?
> > 
> > Ping?
> 
> Ping?

I'll try and find time to look at this issue this week.  Sasha, do you have a
more targeted reproducer, or is still just the trinity fuzzer?
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sasha Levin Oct. 19, 2015, 11:34 p.m. UTC | #4
On 10/18/2015 12:17 AM, Ross Zwisler wrote:
> I'll try and find time to look at this issue this week.  Sasha, do you have a
> more targeted reproducer, or is still just the trinity fuzzer?

Nope, I haven't looked at it much beyond looking into dax_io().


Thanks,
Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/dax.c b/fs/dax.c
index 93bf2f9..2cdb8a5 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -178,6 +178,7 @@  static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
        if (need_wmb)
                wmb_pmem();

+       WARN_ON((pos == start) && (pos - start > iov_iter_count(iter)));
        return (pos == start) ? retval : pos - start;
 }