Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3319866rwa; Tue, 23 Aug 2022 02:45:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR6S0z3iGTCYDELe4YnEbe+Yx8IcNjKI73xMhMRwAHxJY6PioZShrchG8Ld1cBGD1xyyKsjJ X-Received: by 2002:a05:6402:5413:b0:446:817d:5d46 with SMTP id ev19-20020a056402541300b00446817d5d46mr2985202edb.293.1661247939403; Tue, 23 Aug 2022 02:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661247939; cv=none; d=google.com; s=arc-20160816; b=uXbT5PTdn2j/YC5LSRo2S/z81U1tSFKgROJi0vu1Ue2pbfrCKOgOF1Ak3nWbjumLrg ZJj1gS3RXhwwg2JW15MG7zpbKkKiEcFWdieEdEhWgKIOelbPA67Q8X2PjLcNlmPZnJM4 ailHCi2QhMtO9oqcbKgc8haKmPO1Sjwq+VxWrJ0r3vBLVSv/ZlGVcm+80sVNWZEUzQ1s cRvG5hRKnfMbiq9jHTYktPlGHaVnQeFI61nc7fD3+07qZ0SlnU/6nMOSjJjtORWzfBLA pjufsd4vV4cTPmBu1X6xi3ZrZUC1UKdIYrsh+KijuxSJKDJyijHhdUydqhUegUIQpnfl yZuQ== 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=NRK3OQ18bz8FFXvRJ8BJg4wafyK4M0v29JUW81RzJN4=; b=kUuD53DoYAXlW/BsGdjFgMfiymYlyFMaHgSuIVGAh/937kyeHVMiD6nLseIotrF28B K0W+tmVeiYTpH9YRdIn8npHzBKolb5eEv1hfj/Xv4Biheyp6QzjUbmyv940ns5NAmASj DPluaF9M0cFCeY1A0wQEEArlJ2QCc35wqj60Xp8ZWJr1nFolizcssvwp6RgJpI8JU4o6 bzIsmn1legZDNUC2waVnpml7sRxJCE32Kzw6BddyieutAI2ZapOaZY3mQZko7EV42w2B zNLCctzsDCzeR0WOBKb2II4qdBbzpRmNAjCqy8evWPfRJj63mUzNhOS0mPGaTNivY1au DY2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0fWsxUXg; 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 hu8-20020a170907a08800b0073832e13344si11341638ejc.86.2022.08.23.02.45.13; Tue, 23 Aug 2022 02:45:39 -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=0fWsxUXg; 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 S1349736AbiHWJYS (ORCPT + 99 others); Tue, 23 Aug 2022 05:24:18 -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-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 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; 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) @@ -1159,6 +1157,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