From patchwork Wed Oct 19 08:32:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4831 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp223642wrs; Wed, 19 Oct 2022 02:38:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7A+PqzuIRIIKuR7SW9JfvQVrZk8SGBlmj052xd5hs8FF1Aqg86hXR8jv27OOStY+uhuk7Z X-Received: by 2002:a17:906:db07:b0:77b:82cf:54af with SMTP id xj7-20020a170906db0700b0077b82cf54afmr6141040ejb.666.1666172283332; Wed, 19 Oct 2022 02:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666172283; cv=none; d=google.com; s=arc-20160816; b=k59ljDTnaPtsc6C9JKcawg/jXsQn8xubEQF+bl1GGYqmAVDU0KYcJ2Zv3hK/DDhxmJ j24BOEleqMrnCRmTwQBCsZRdYI9G6zPCnTBP6W8pjQ4ArfkayqFoKR+v6Sc1sDy6bwsx BaCBGFZS8SiinBwikVFkiB1p6d30/y9DR5/tsHtCvZpJXil8irsLLNflEtzbQQE7cTfc 1EI3RMa5EZvIfzrFvLJ8l3n9fJgDxzm6CTZOzPucuu2OmaUk5sUgXHMhefFAGwt+cO7x B3tujYRkBK/mU43mz5gJmP/3K6iFcCTr4oCPOFVrZQSeYXsV0NcsIAvI26PKvXwueGWc uzVA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q6-20020a17090676c600b0078da414a7cesi11731704ejn.149.2022.10.19.02.37.35; Wed, 19 Oct 2022 02:38:03 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747108268033771364?= X-GMAIL-MSGID: =?utf-8?q?1747108268033771364?= 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);