From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8ACC8BE0 for ; Tue, 28 Mar 2023 14:58:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A9F8C433EF; Tue, 28 Mar 2023 14:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1680015522; bh=sdA+LRo5P9DR52yRBJmX+u4ccoZbuBN/kOIybFthmGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTq2FfyiIuz1vBkOjV3xxVlFxzgIf//ZqcpMSQIOwjUuk6Tn4swejiBbqf++yg1ro t2FfPXVUOcGYbI6bSYJuZPlBBV2TPmMt5v0Rbs7/hehLZP0ICoICuZEk0qh6rX+qO6 F2n5btQwT8eExnRsjXFoh9jDjCZ3yTwNF+tUGp4M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Namjae Jeon , Sergey Senozhatsky , Steve French , Sasha Levin Subject: [PATCH 6.1 078/224] ksmbd: add low bound validation to FSCTL_QUERY_ALLOCATED_RANGES Date: Tue, 28 Mar 2023 16:41:14 +0200 Message-Id: <20230328142620.567851010@linuxfoundation.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230328142617.205414124@linuxfoundation.org> References: <20230328142617.205414124@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Namjae Jeon [ Upstream commit 342edb60dcda7a409430359b0cac2864bb9dfe44 ] Smatch static checker warning: fs/ksmbd/vfs.c:1040 ksmbd_vfs_fqar_lseek() warn: no lower bound on 'length' fs/ksmbd/vfs.c:1041 ksmbd_vfs_fqar_lseek() warn: no lower bound on 'start' Fix unexpected result that could caused from negative start and length. Fixes: f44158485826 ("cifsd: add file operations") Reported-by: Dan Carpenter Signed-off-by: Namjae Jeon Reviewed-by: Sergey Senozhatsky Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/ksmbd/smb2pdu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index 3bb971831e7ce..61d12eab0be15 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -7457,13 +7457,16 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id, if (in_count == 0) return -EINVAL; + start = le64_to_cpu(qar_req->file_offset); + length = le64_to_cpu(qar_req->length); + + if (start < 0 || length < 0) + return -EINVAL; + fp = ksmbd_lookup_fd_fast(work, id); if (!fp) return -ENOENT; - start = le64_to_cpu(qar_req->file_offset); - length = le64_to_cpu(qar_req->length); - ret = ksmbd_vfs_fqar_lseek(fp, start, length, qar_rsp, in_count, out_count); if (ret && ret != -E2BIG) -- 2.39.2