From nobody Thu Dec 18 13:02:07 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 EB763C32772 for ; Tue, 23 Aug 2022 09:24:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349737AbiHWJYU (ORCPT ); Tue, 23 Aug 2022 05:24:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350647AbiHWJWD (ORCPT ); Tue, 23 Aug 2022 05:22:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 507188E0DA; Tue, 23 Aug 2022 01:34:53 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C3BF96151B; Tue, 23 Aug 2022 08:34:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC9DCC43470; Tue, 23 Aug 2022 08:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243691; bh=vtUXON8ZPY2JWNUwIGTSBD4cwQhMoCHe7RqNx/KHnSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0fWsxUXgqxFOtyW2KKTtIh6tkl05/3P0uetAe8FKZydVLR7ck8Lz06OY6h4126m3D unyhrBkLCCqAnFhQCRbz33tjBoH/BFbOLwK6VeF6Y8wg2H4cJjURabXZkksgfv/nvW hpcmvUzPg38vwzXnfEJ3Rv4hgddd1xQ27oxS5sg4= 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.19 357/365] smb3: check xattr value length earlier Date: Tue, 23 Aug 2022 10:04:18 +0200 Message-Id: <20220823080133.225187338@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@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 8802995b2d3d..aa4c1d403708 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1145,9 +1145,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) @@ -1159,6 +1157,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