From nobody Fri Sep 5 20:15:08 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5A35C54F4B for ; Tue, 23 Aug 2022 12:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359399AbiHWMDt (ORCPT ); Tue, 23 Aug 2022 08:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359148AbiHWL7v (ORCPT ); Tue, 23 Aug 2022 07:59:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 173C4D8B32; Tue, 23 Aug 2022 02:35:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 71D25B81C9F; Tue, 23 Aug 2022 09:35:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A59B7C433C1; Tue, 23 Aug 2022 09:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661247301; bh=9SfeYFIkUxV4kzA0oTEj7SB4EtELhFUNxGS1fzUs1Ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fitIZHJHhYttORLLpZMyJeMDOuIbsYaU+FudAKG4UAVKbXi5UbLjX0ipyjKpLMYbo sEqqK35cNeM6u7K6N6B4bNlYZCeIAy4QOtdJKMLe8W7Ru57a0DjCusD3n4SWuXgFDX 6T16vOIvlVOXsjX01Y9TB2g8z/likcbeK4whyZe8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronnie Sahlberg , Steve French , Sasha Levin Subject: [PATCH 5.4 381/389] smb3: check xattr value length earlier Date: Tue, 23 Aug 2022 10:27:39 +0200 Message-Id: <20220823080131.481900520@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Steve French [ Upstream commit 5fa2cffba0b82336a2244d941322eb1627ff787b ] Coverity complains about assigning a pointer based on value length before checking that value length goes beyond the end of the SMB. Although this is even more unlikely as value length is a single byte, and the pointer is not dereferenced until laterm, it is clearer to check the lengths first. Addresses-Coverity: 1467704 ("Speculative execution data leak") Reviewed-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/smb2ops.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 57164563eec6..6ae281cff0d5 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -960,9 +960,7 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size, size_t name_len, value_len, user_name_len; =20 while (src_size > 0) { - name =3D &src->ea_data[0]; name_len =3D (size_t)src->ea_name_length; - value =3D &src->ea_data[src->ea_name_length + 1]; value_len =3D (size_t)le16_to_cpu(src->ea_value_length); =20 if (name_len =3D=3D 0) @@ -974,6 +972,9 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size, goto out; } =20 + name =3D &src->ea_data[0]; + value =3D &src->ea_data[src->ea_name_length + 1]; + if (ea_name) { if (ea_name_len =3D=3D name_len && memcmp(ea_name, name, name_len) =3D=3D 0) { --=20 2.35.1