Skip to contentSkip to conversation

rnfs: rq_respages pointer is bad

DISCUSSION David J. Wilder 3 participants 8 messages Mar 2, 2010 – May 6, 2010 4 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

Tom

I have been chasing an rnfs related Oops in svc_process(). I have found the source of the Oops but I am not sure of my fix. I am seeing the problem on ppc64, kernel 2.6.32, I have not tried other arch yet.

The source of the problem is in rdma_read_complete(), I am finding that rqstp->rq_respages is set to point past the end of the rqstp->rq_pages page list. This results in a NULL reference in svc_process() when passing rq_respages[0] to page_address().

In rdma_read_complete() we are using rqstp->rq_arg.pages as the base of the page list then indexing by page_no, however rq_arg.pages is not pointing to the start of the list so rq_respages ends up pointing to:

rqstp->rq_pages[(head->count+1) + head->hdr_count]

In my case, it ends up pointing one past the end of the list by one.

Here is the change I made.

static int rdma_read_complete(struct svc_rqst *rqstp,
struct svc_rdma_op_ctxt *head)

{
        int page_no;
        int ret;

        BUG_ON(!head);

        /* Copy RPC pages */
        for (page_no = 0; page_no < head->count; page_no++) {
                put_page(rqstp->rq_pages[page_no]);
                rqstp->rq_pages[page_no] = head->pages[page_no];
        }
        /* Point rq_arg.pages past header */
        rqstp->rq_arg.pages = &rqstp->rq_pages[head->hdr_count];
        rqstp->rq_arg.page_len = head->arg.page_len;
        rqstp->rq_arg.page_base = head->arg.page_base;

        /* rq_respages starts after the last arg page */

- rqstp->rq_respages = &rqstp->rq_arg.pages[page_no];
+ rqstp->rq_respages = &rqstp->rq_pages[page_no];
.
.
.

The change works for me, but I am not sure it is safe to assume the rqstp->rq_pages[head->count] will always point to the last arg page.

Dave.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hi David:

That looks like a bug to me and it looks like what you propose is the correct fix. My only reservation is that if you are correct then how did this work at all without data corruption for large writes on x86_64?

I'm on the road right now, so I can't dig too deep until Wednesday, but at this point your analysis looks correct to me.

Tom

Quoted 46 lines · David J. Wilder

Tom

I have been chasing an rnfs related Oops in svc_process(). I have found the source of the Oops but I am not sure of my fix. I am seeing the problem on ppc64, kernel 2.6.32, I have not tried other arch yet.

The source of the problem is in rdma_read_complete(), I am finding that rqstp->rq_respages is set to point past the end of the rqstp->rq_pages page list. This results in a NULL reference in svc_process() when passing rq_respages[0] to page_address().

In rdma_read_complete() we are using rqstp->rq_arg.pages as the base of the page list then indexing by page_no, however rq_arg.pages is not pointing to the start of the list so rq_respages ends up pointing to:

rqstp->rq_pages[(head->count+1) + head->hdr_count]

In my case, it ends up pointing one past the end of the list by one.

Here is the change I made.

static int rdma_read_complete(struct svc_rqst *rqstp,
struct svc_rdma_op_ctxt *head)

{
        int page_no;
        int ret;

        BUG_ON(!head);

        /* Copy RPC pages */
        for (page_no = 0; page_no < head->count; page_no++) {
                put_page(rqstp->rq_pages[page_no]);
                rqstp->rq_pages[page_no] = head->pages[page_no];
        }
        /* Point rq_arg.pages past header */
        rqstp->rq_arg.pages = &rqstp->rq_pages[head->hdr_count];
        rqstp->rq_arg.page_len = head->arg.page_len;
        rqstp->rq_arg.page_base = head->arg.page_base;

        /* rq_respages starts after the last arg page */
(quoted diff) +1 -1
-       rqstp->rq_respages = &rqstp->rq_arg.pages[page_no];
+	rqstp->rq_respages = &rqstp->rq_pages[page_no];

.
.
.

Quoted 5 lines

The change works for me, but I am not sure it is safe to assume the rqstp->rq_pages[head->count] will always point to the last arg page.

Dave.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4B8C8764.9080409-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org

#4 lore raw
Quoted 5 lines · Tom Tucker

Hi David:

That looks like a bug to me and it looks like what you propose is the correct fix. My only reservation is that if you are correct then how did this work at all without data corruption for large writes on x86_64?

The size of the page array is determined by page size (and some other parameters). I am using 64k pages, that may be the key. I don't know what page size was used on X86-64 but we may have been lucky and not fallen off the end of the array thus avoided the problem.

Quoted 57 lines

I'm on the road right now, so I can't dig too deep until Wednesday, but at this point your analysis looks correct to me.

Tom

Quoted 49 lines · David J. Wilder

Tom

I have been chasing an rnfs related Oops in svc_process(). I have found the source of the Oops but I am not sure of my fix. I am seeing the problem on ppc64, kernel 2.6.32, I have not tried other arch yet.

The source of the problem is in rdma_read_complete(), I am finding that rqstp->rq_respages is set to point past the end of the rqstp->rq_pages page list. This results in a NULL reference in svc_process() when passing rq_respages[0] to page_address().

In rdma_read_complete() we are using rqstp->rq_arg.pages as the base of the page list then indexing by page_no, however rq_arg.pages is not pointing to the start of the list so rq_respages ends up pointing to:

rqstp->rq_pages[(head->count+1) + head->hdr_count]

In my case, it ends up pointing one past the end of the list by one.

Here is the change I made.

static int rdma_read_complete(struct svc_rqst *rqstp,
struct svc_rdma_op_ctxt *head)

{
        int page_no;
        int ret;

        BUG_ON(!head);

        /* Copy RPC pages */
        for (page_no = 0; page_no < head->count; page_no++) {
                put_page(rqstp->rq_pages[page_no]);
                rqstp->rq_pages[page_no] = head->pages[page_no];
        }
        /* Point rq_arg.pages past header */
        rqstp->rq_arg.pages = &rqstp->rq_pages[head->hdr_count];
        rqstp->rq_arg.page_len = head->arg.page_len;
        rqstp->rq_arg.page_base = head->arg.page_base;

        /* rq_respages starts after the last arg page */
(quoted diff) +1 -1
-       rqstp->rq_respages = &rqstp->rq_arg.pages[page_no];
+	rqstp->rq_respages = &rqstp->rq_pages[page_no];

.
.
.

The change works for me, but I am not sure it is safe to assume the rqstp->rq_pages[head->count] will always point to the last arg page.

Quoted 7 lines
Quoted 2 lines

Dave.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to a message not in the archive
Quoted 41 lines · David J. Wilder

Tom

I have been chasing an rnfs related Oops in svc_process(). I have found the source of the Oops but I am not sure of my fix. I am seeing the problem on ppc64, kernel 2.6.32, I have not tried other arch yet.

The source of the problem is in rdma_read_complete(), I am finding that rqstp->rq_respages is set to point past the end of the rqstp->rq_pages page list. This results in a NULL reference in svc_process() when passing rq_respages[0] to page_address().

In rdma_read_complete() we are using rqstp->rq_arg.pages as the base of the page list then indexing by page_no, however rq_arg.pages is not pointing to the start of the list so rq_respages ends up pointing to:

rqstp->rq_pages[(head->count+1) + head->hdr_count]

In my case, it ends up pointing one past the end of the list by one.

Here is the change I made.

static int rdma_read_complete(struct svc_rqst *rqstp,
struct svc_rdma_op_ctxt *head)

{
        int page_no;
        int ret;

        BUG_ON(!head);

        /* Copy RPC pages */
        for (page_no = 0; page_no < head->count; page_no++) {
                put_page(rqstp->rq_pages[page_no]);
                rqstp->rq_pages[page_no] = head->pages[page_no];
        }
        /* Point rq_arg.pages past header */
        rqstp->rq_arg.pages = &rqstp->rq_pages[head->hdr_count];
        rqstp->rq_arg.page_len = head->arg.page_len;
        rqstp->rq_arg.page_base = head->arg.page_base;

        /* rq_respages starts after the last arg page */

Review

Quoted 2 lines
(quoted diff) +1 -1
-       rqstp->rq_respages = &rqstp->rq_arg.pages[page_no];
+	rqstp->rq_respages = &rqstp->rq_pages[page_no];

This might be clearer as:

       rqstp->rq_respages = &rqstp->rq_pages[head->count];
Quoted 7 lines

.
.
.

The change works for me, but I am not sure it is safe to assume the rqstp->rq_pages[head->count] will always point to the last arg page.

Quoted 7 lines

Dave.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to a message not in the archive

Someone please make sure that a final patch with a full description gets sent to the NFS guys for merging. Tom, are you going to handle this?

Signature · 7 lines
Roland Dreier  <[email protected]>
For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): adar5nqczov.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org

#8 lore raw
Quoted 3 lines · Roland Dreier

Someone please make sure that a final patch with a full description gets sent to the NFS guys for merging. Tom, are you going to handle this?

Yes, and I have several more in queue.

Tom

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw
In reply to a message not in the archive
Quoted 4 lines

The source of the problem is in rdma_read_complete(), I am finding that rqstp->rq_respages is set to point past the end of the rqstp->rq_pages page list. This results in a NULL reference in svc_process() when passing rq_respages[0] to page_address().

did this ever end up getting fixed upstream?

Signature · 6 lines
Roland Dreier <[email protected]> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): ada6332arcw.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org

#11 lore raw
Quoted 7 lines · Roland Dreier
Quoted 4 lines

The source of the problem is in rdma_read_complete(), I am finding that rqstp->rq_respages is set to point past the end of the rqstp->rq_pages page list. This results in a NULL reference in svc_process() when passing rq_respages[0] to page_address().

did this ever end up getting fixed upstream?

I believe it did, but I'll check to be sure. It may be in Bruce's queue too. --
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html