Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3415090rwa; Tue, 23 Aug 2022 04:31:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR4EY5IgeZ0doy9vlcZBcOgrvr0I80iCCRJeMhnHwHzVvpTgZAASdSweUCCqz7BIYXLMh0G9 X-Received: by 2002:a05:6402:50ca:b0:447:3355:76e3 with SMTP id h10-20020a05640250ca00b00447335576e3mr555132edb.72.1661254271953; Tue, 23 Aug 2022 04:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254271; cv=none; d=google.com; s=arc-20160816; b=Xt0w0Kywf7XnDFtO0/bp5MNi4aNbRSZR7sAd1NbgbFDNkdUDdCkjW6BHZUjvTznAM7 2nGOX8Qss1cbOjztUUeHKHRmBaLaRgy0E0Z/CJbGGS2kyvlK8AWPE2T9wRctw+pe48wI VMv5HwV2RRNjJQvcrG7AZXR2IJJTkUhtFp8TfYA1vdODL7b+ud5PcE9JHWzcZFyPgILe 0oZhYS4Mr4A4hZAG/tz7CHzCv5Bgfzdq14xejdxoxq4nQwvPUjYg16/4JspgMYudgWHp t1SAv+LyJR9N5HMCap2SpPDuBaVf1Lz29bXHuhtsx7YcVIAVggcpgIdMDULkdzWYkXEF Zn8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VEtmYuEkl0H8w5tGvvvtUtMOCCXNTPURNnOdcUp/zO8=; b=VWXHwRzRzJDOVxAH5iRQe4BJu5NXr3bbKXz+wrgOaNg5pfyGl1jt9EwXyw4S8DNPK3 WOz4oPh/YYEW7nAANF8aWspObfJLtTTiPAtsukPWrOLIdy1+KWUbmt+FcMHfT9j63Y5X 9OJ/EBdhVmSClOnAnn1i37dTJPD1Q5yNVXcsW9THX0+nt797hFfgsASLwk+yHyA6U4T+ 7jMVh+m+BMoOrBgpt8EiFaaFAZtu5cneHTASX37FIDPIZZLUpJ9mMDFjZ6G5/zuWjTRs WkW/2PuXDpD/pkROaSj7BiduZ0RwI0L3UJM9jjYjFOfP6KEvtRMWn6LO5OmBQOzABc5r AYTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MspJHyAm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c92-20020a509fe5000000b00446007388a9si1885529edf.224.2022.08.23.04.30.46; Tue, 23 Aug 2022 04:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MspJHyAm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242776AbiHWLG5 (ORCPT + 99 others); Tue, 23 Aug 2022 07:06:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356576AbiHWLEQ (ORCPT ); Tue, 23 Aug 2022 07:04:16 -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 752E0B2873; Tue, 23 Aug 2022 02:15:23 -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 AB08F60F50; Tue, 23 Aug 2022 09:15:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0F75C433C1; Tue, 23 Aug 2022 09:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246117; bh=Syn49+GFPMqD0AC+qtGcAiSRfizHIhpdfBenoWSbbRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MspJHyAmdQSUn3HWObtXeLyRGyHR+Zy5VQfDRmOGpk9AYGv7culqaIkzUkWJnmr3p U26vZOS6jg5LO2L+4zpbO+1twv7K3IWbyaf3UE33Te/FbndzVINnnzaImJyfNvNmk1 NYKoi7TWUb5of+N9LCDniC02aUdcYme7aEbAIZWs= 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 4.19 280/287] smb3: check xattr value length earlier Date: Tue, 23 Aug 2022 10:27:29 +0200 Message-Id: <20220823080110.890263139@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_FILL_THIS_FORM_SHORT,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 cc34a28aecbc..f906984eb25b 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -762,9 +762,7 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size, size_t name_len, value_len, user_name_len; while (src_size > 0) { - name = &src->ea_data[0]; name_len = (size_t)src->ea_name_length; - value = &src->ea_data[src->ea_name_length + 1]; value_len = (size_t)le16_to_cpu(src->ea_value_length); if (name_len == 0) { @@ -777,6 +775,9 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size, goto out; } + name = &src->ea_data[0]; + value = &src->ea_data[src->ea_name_length + 1]; + if (ea_name) { if (ea_name_len == name_len && memcmp(ea_name, name, name_len) == 0) { -- 2.35.1