From: Dan Carpenter <dan.carpenter@oracle.com>
To: chuck.lever@oracle.com
Cc: linux-nfs@vger.kernel.org
Subject: re: xprtrdma: Move credit update to RPC reply handler
Date: Tue, 10 Feb 2015 12:45:43 +0300 [thread overview]
Message-ID: <20150210094543.GA16665@mwanda> (raw)
Hello Chuck Lever,
The patch eba8ff660b2d: "xprtrdma: Move credit update to RPC reply
handler" from Jan 21, 2015, leads to the following static checker
warning:
net/sunrpc/xprtrdma/rpc_rdma.c:879 rpcrdma_reply_handler()
warn: can 'credits' be negative?
net/sunrpc/xprtrdma/rpc_rdma.c
875
876 credits = be32_to_cpu(headerp->rm_credit);
877 if (credits == 0)
878 credits = 1; /* don't deadlock */
879 else if (credits > r_xprt->rx_buf.rb_max_requests)
880 credits = r_xprt->rx_buf.rb_max_requests;
"credits" and "r_xprt->rx_buf.rb_max_requests" are both type int so this
test can underflow. If "credits" is less than zero then "xprt->cwnd"
could be zero, leading to a deadlock (based on the comment), or
something else out of bounds.
881
882 cwnd = xprt->cwnd;
883 xprt->cwnd = credits << RPC_CWNDSHIFT;
884 if (xprt->cwnd > cwnd)
885 xprt_release_rqst_cong(rqst->rq_task);
886
887 dprintk("RPC: %s: xprt_complete_rqst(0x%p, 0x%p, %d)\n",
888 __func__, xprt, rqst, status);
889 xprt_complete_rqst(rqst->rq_task, status);
890 spin_unlock(&xprt->transport_lock);
891 }
regards,
dan carpenter
next reply other threads:[~2015-02-10 9:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 9:45 Dan Carpenter [this message]
2015-02-10 16:50 ` xprtrdma: Move credit update to RPC reply handler Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150210094543.GA16665@mwanda \
--to=dan.carpenter@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.