Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp815321rwi; Wed, 19 Oct 2022 03:23:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Nkws6n59ywIiQ5LJ8/e5zsfMYCw/CIN7NOMtRK5dc6QlIIrgdwnFjyvDd/RIRdo9yySu/ X-Received: by 2002:a05:6402:5162:b0:457:6ef2:df3 with SMTP id d2-20020a056402516200b004576ef20df3mr6689825ede.128.1666174993762; Wed, 19 Oct 2022 03:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666174993; cv=none; d=google.com; s=arc-20160816; b=Kvh1BBtGSya41Ep2o2eToBdJADt+i4A9Fc90Hl8KyHL+LVCxDrvjVcDgeuksY+/W5v U1EA2LNkhFlhl0EKI+2Of5cvwByKPY4Ec4bU16tMa9PJ3t9sGaAVkdH/KjviDVa97S1M vN4JanfLoimR8k9qCTcmCuPHLsOP6qqAU1ZCJkOHuHOnZRsIYh630T9WANJk/KAQFbu7 afIDUNCH1TCMHBJPKf3AaSZ6+QWpKJj0AM2fTQcFmi19DR/43ITgQ+60lQq8CSNVZuis pNAWosBbBxJW0KOnMqE8AutEHSy1EZFVxHw0Ea9WiSNZJVRYo9C7LeugwkOEjfmpHnVJ aaCA== 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=2oNjCqn/eoTLT2FY1YTlQgdtXPjjAcVnXOuOqEr5nt8=; b=thq3gDhNqrhKgpQ870KiUnURla+Cji+HXdMjPKYzfULcuNQDQG1kf2AGAPJR0q5NjO JUAnaxjzDrPrA6JzAdqV8t2z/G2qtyJXfh00bbUpNmVWpIugztCzi27Lxjc8lGI+UQ2k YtrSqLd2pDro4p3N+aJFH2T24+SBU6qDw+gab782/LZ9OLnvJ+ZFPVROqtcm6EptG41E N/5kB08UAjEhEJhSCaw98GVnYUUduddZ2Mco29uAQMg4/ci3wdVY+obGieaFaOHVdu3C FRkKr4l14PxhvFDk1UTTC+mNZ+q5NUUU4+8pqrcJewoKuqaH2p+DXscYDx3xIl9udnME dDDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ow8nXXCF; 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 e3-20020a17090658c300b00730936657d1si14724006ejs.552.2022.10.19.03.22.48; Wed, 19 Oct 2022 03:23:13 -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=ow8nXXCF; 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 S232825AbiJSJZB (ORCPT + 99 others); Wed, 19 Oct 2022 05:25:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233349AbiJSJXJ (ORCPT ); Wed, 19 Oct 2022 05:23:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 100F432ECA; Wed, 19 Oct 2022 02:10:17 -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 ADC2D6187E; Wed, 19 Oct 2022 09:08:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDC12C433D6; Wed, 19 Oct 2022 09:08:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170486; bh=MKoBh82UrCikpRPp+3I9KxQVcYkaIfYhH8SFNWI3dfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ow8nXXCFdEwNB4Zu29z7v/szyNj7MZi6YzdrBU8yRNS/h1Xv6HDX6vo7Ea02S5D2y wQxp9bmkLXJH/YI5INT4q5DaEYfNiJBzegSfCuFqF9GIZK5JXT/GXZmBT0lIMaYyEj 5GnpgxRnqZkTexN9soqmPxfGV9EoS+S1TGm0cUXE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronnie Sahlberg , Enzo Matsumiya , Steve French , Sasha Levin Subject: [PATCH 6.0 641/862] cifs: return correct error in ->calc_signature() Date: Wed, 19 Oct 2022 10:32:08 +0200 Message-Id: <20221019083318.246791597@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@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.4 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 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: Enzo Matsumiya [ Upstream commit 09a1f9a168ae1f69f701689429871793174417d2 ] If an error happens while getting the key or session in the ->calc_signature implementations, 0 (success) is returned. Fix it by returning a proper error code. Since it seems to be highly unlikely to happen wrap the rc check in unlikely() too. Reviewed-by: Ronnie Sahlberg Fixes: 32811d242ff6 ("cifs: Start using per session key for smb2/3 for signature generation") Signed-off-by: Enzo Matsumiya Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/smb2transport.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c index 1a5fc3314dbf..4640fc4a8b13 100644 --- a/fs/cifs/smb2transport.c +++ b/fs/cifs/smb2transport.c @@ -225,9 +225,9 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server, struct smb_rqst drqst; ses = smb2_find_smb_ses(server, le64_to_cpu(shdr->SessionId)); - if (!ses) { + if (unlikely(!ses)) { cifs_server_dbg(VFS, "%s: Could not find session\n", __func__); - return 0; + return -ENOENT; } memset(smb2_signature, 0x0, SMB2_HMACSHA256_SIZE); @@ -557,8 +557,10 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server, u8 key[SMB3_SIGN_KEY_SIZE]; rc = smb2_get_sign_key(le64_to_cpu(shdr->SessionId), server, key); - if (rc) - return 0; + if (unlikely(rc)) { + cifs_server_dbg(VFS, "%s: Could not get signing key\n", __func__); + return rc; + } if (allocate_crypto) { rc = cifs_alloc_hash("cmac(aes)", &hash, &sdesc); -- 2.35.1