]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
SUNRPC: Fix integer overflow in decode_rc_list()
authorDan Carpenter <dan.carpenter@linaro.org>
Thu, 19 Sep 2024 08:50:33 +0000 (11:50 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 13:11:53 +0000 (15:11 +0200)
[ Upstream commit 6dbf1f341b6b35bcc20ff95b6b315e509f6c5369 ]

The math in "rc_list->rcl_nrefcalls * 2 * sizeof(uint32_t)" could have an
integer overflow.  Add bounds checking on rc_list->rcl_nrefcalls to fix
that.

Fixes: 4aece6a19cf7 ("nfs41: cb_sequence xdr implementation")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/callback_xdr.c

index d0cccddb7d0885fe98f477324fdd50012faf3cb7..fa519ce5c841f6d0050b1ea3d3036a9c2693e6e0 100644 (file)
@@ -372,6 +372,8 @@ static __be32 decode_rc_list(struct xdr_stream *xdr,
 
        rc_list->rcl_nrefcalls = ntohl(*p++);
        if (rc_list->rcl_nrefcalls) {
+               if (unlikely(rc_list->rcl_nrefcalls > xdr->buf->len))
+                       goto out;
                p = xdr_inline_decode(xdr,
                             rc_list->rcl_nrefcalls * 2 * sizeof(uint32_t));
                if (unlikely(p == NULL))