diff mbox

libceph: fix oops in ceph_msg_data_pagelist_advance()

Message ID 1395528897-26031-1-git-send-email-zheng.z.yan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yan, Zheng March 22, 2014, 10:54 p.m. UTC
When there is no more data, ceph_msg_data_pagelist_advance() should
not move on to the next page.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
---
 net/ceph/messenger.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Alex Elder March 22, 2014, 11:10 p.m. UTC | #1
On 03/22/2014 05:54 PM, Yan, Zheng wrote:
> When there is no more data, ceph_msg_data_pagelist_advance() should
> not move on to the next page.

Without looking very hard at this, this looks right.
Does ceph_msg_data_pages_advance() need the same fix?
And ceph_msg_data_bio_advance()?

I'm going to spend a little more time to refresh my
memory on these things.

					-Alex

> Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
> ---
>  net/ceph/messenger.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
> index 30efc5c..8859f2e 100644
> --- a/net/ceph/messenger.c
> +++ b/net/ceph/messenger.c
> @@ -1004,6 +1004,9 @@ static bool ceph_msg_data_pagelist_advance(struct ceph_msg_data_cursor *cursor,
>  	if (!bytes || cursor->offset & ~PAGE_MASK)
>  		return false;	/* more bytes to process in the current page */
>  
> +	if (!cursor->resid)
> +		return false;   /* no more data */
> +
>  	/* Move on to the next page */
>  
>  	BUG_ON(list_is_last(&cursor->page->lru, &pagelist->head));
> 

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yan, Zheng March 22, 2014, 11:38 p.m. UTC | #2
On Sun, Mar 23, 2014 at 7:10 AM, Alex Elder <elder@ieee.org> wrote:
> On 03/22/2014 05:54 PM, Yan, Zheng wrote:
>> When there is no more data, ceph_msg_data_pagelist_advance() should
>> not move on to the next page.
>
> Without looking very hard at this, this looks right.
> Does ceph_msg_data_pages_advance() need the same fix?
> And ceph_msg_data_bio_advance()?
>
ceph_msg_data_pages_advance() needs it, ceph_msg_data_bio_advance() does not.


> I'm going to spend a little more time to refresh my
> memory on these things.
>
>                                         -Alex
>
>> Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
>> ---
>>  net/ceph/messenger.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
>> index 30efc5c..8859f2e 100644
>> --- a/net/ceph/messenger.c
>> +++ b/net/ceph/messenger.c
>> @@ -1004,6 +1004,9 @@ static bool ceph_msg_data_pagelist_advance(struct ceph_msg_data_cursor *cursor,
>>       if (!bytes || cursor->offset & ~PAGE_MASK)
>>               return false;   /* more bytes to process in the current page */
>>
>> +     if (!cursor->resid)
>> +             return false;   /* no more data */
>> +
>>       /* Move on to the next page */
>>
>>       BUG_ON(list_is_last(&cursor->page->lru, &pagelist->head));
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" 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/net/ceph/messenger.c b/net/ceph/messenger.c
index 30efc5c..8859f2e 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1004,6 +1004,9 @@  static bool ceph_msg_data_pagelist_advance(struct ceph_msg_data_cursor *cursor,
 	if (!bytes || cursor->offset & ~PAGE_MASK)
 		return false;	/* more bytes to process in the current page */
 
+	if (!cursor->resid)
+		return false;   /* no more data */
+
 	/* Move on to the next page */
 
 	BUG_ON(list_is_last(&cursor->page->lru, &pagelist->head));