Skip to content

Commit 9e895cd

Browse files
chuckleverTrond Myklebust
authored andcommitted
xprtrdma: Fix a NULL dereference in frwr_unmap_sync()
The normal mechanism that invalidates and unmaps MRs is frwr_unmap_async(). frwr_unmap_sync() is used only when an RPC Reply bearing Write or Reply chunks has been lost (ie, almost never). Coverity found that after commit 9a301ca ("xprtrdma: Move fr_linv_done field to struct rpcrdma_mr"), the while() loop in frwr_unmap_sync() exits only once @mr is NULL, unconditionally causing subsequent dereferences of @mr to Oops. I've tested this fix by creating a client that skips invoking frwr_unmap_async() when RPC Replies complete. That forces all invalidation tasks to fall upon frwr_unmap_sync(). Simple workloads with this fix applied to the adulterated client work as designed. Reported-by: coverity-bot <[email protected]> Addresses-Coverity-ID: 1504556 ("Null pointer dereferences") Fixes: 9a301ca ("xprtrdma: Move fr_linv_done field to struct rpcrdma_mr") Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent f8f7e0f commit 9e895cd

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/sunrpc/xprtrdma/frwr_ops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
530530
*prev = last;
531531
prev = &last->next;
532532
}
533+
mr = container_of(last, struct rpcrdma_mr, mr_invwr);
533534

534535
/* Strong send queue ordering guarantees that when the
535536
* last WR in the chain completes, all WRs in the chain

0 commit comments

Comments
 (0)