net: sunrpc: xprt.c: fix shift-out-of-bounds in xprt_calc_majortimeo
Subsystems (4)
PATCH 1/1 net: sunrpc: xprt.c: fix shift-out-of-bounds in xprt_calc_majortimeo
Fix shift-out-of-bounds in xprt_calc_majortimeo().
UBSAN: shift-out-of-bounds in net/sunrpc/xprt.c:658:14
shift exponent 536871232 is too large for 64-bit type 'long u
--- net/sunrpc/xprt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/sunrpc/xprt.c +4 -1
@@ -655,7 +655,10 @@ static unsigned long xprt_calc_majortimeo(struct rpc_rqst *req)unsigned long majortimeo = req->rq_timeout;if (to->to_exponential) - majortimeo <<= to->to_retries; +if (to->to_retries >=sizeof (majortimeo) *8 ) + majortimeo = to->to_maxval; +else + majortimeo <<= to->to_retries;else majortimeo += to->to_increment * to->to_retries;if (majortimeo > to->to_maxval || majortimeo ==0 )
Signature · 1 line
2.30.2
Quoted 20 lines · Kurt Manucredo
Fix shift-out-of-bounds in
xprt_calc_majortimeo().UBSAN: shift-out-of-bounds in net/sunrpc/xprt.c:658:14shift exponent 536871232 is too large for 64-bit type 'long u
Reported-by [email protected]Signed-off-by Kurt Manucredo <[email protected]>---
net/sunrpc/xprt.c | 5 ++++-1 file changed, 4 insertions(+), 1 deletion(-)net/sunrpc/xprt.c +0
-0@@ -655,7 +655,10 @@ static unsigned long xprt_calc_majortimeo(struct rpc_rqst *req) unsigned long majortimeo = req->rq_timeout;
if (to->to_exponential)
Quoted 8 lines
- majortimeo <<=
to->to_retries;
+ if (to->to_retries>= sizeof(majortimeo) * 8) + majortimeo =to->to_maxval;
+ else
+ majortimeo <<=to->to_retries; else
majortimeo +=to->to_increment*to->to_retries; if (majortimeo >to->to_maxval|| majortimeo == 0)
I've already stated on the mailing list that I'm not accepting any changes to xprt_calc_majortimeo() for this problem. There is a fix to the NFS mount code that addresses this bounds issue, and that commit is already being tested in linux-next.
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]