From patchwork Sat Oct 22 07:26:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7688 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1109095wrr; Sat, 22 Oct 2022 01:47:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6QX4kF6W290MguURva2LmgHUsrLgLLohUBX3I//QV9+BAsJ7qjO+3QT5Gyn+vC7Aj78Lg+ X-Received: by 2002:a17:907:744:b0:741:36b9:d2cc with SMTP id xc4-20020a170907074400b0074136b9d2ccmr18410402ejb.613.1666428435017; Sat, 22 Oct 2022 01:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666428435; cv=none; d=google.com; s=arc-20160816; b=szR4GzSGte1NMYT4UTy7mOy69iiDStOIXYXX/9eHgFASw3ELBYdm2LneRh8cI8hkwe ZXXWy0B0livuoxvsjmG5Q09RoD8iaOljGnM+MU+POGajgPEZIEzb5S1GCVPRgi3riMFs wZ+Iwd5FLk1DLVtMSIQb9U/Hu1xflyLmeid220wjvk7l1wXpKsQtV4GyORg8vrDjWIbe CTmZ9P38xsaZWHWiwQ/I9nOV1S3WGjTEs3JvZ/kEJv1rlyRwsEp0iMrp6cLqOFju8tGG /oInlX5u9TH4h7CpsH+jJs5yob6ik2HH2eZEDrsUnxEioScwz4kSly4DKq3xXglJbLNy rPWw== 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=RKRmZw+87b4NrD80ymQgo5l+jv7v8C/yukwI9780aSA=; b=BNJgMOP6PYlxeAMoX1282k7vEnafxfvw2OHAdhpG01Brccxk3gOjQBJxE/OMKfdOn9 BygfAReIVDlblFozOihJdq3jxClkDS0ta8+6HpUetEE7kVPQjzH9JVsXiUIOcbg9ZxjV R00G14kGZiBynPrr038WSiNo+DLrZ58K9OF0Qcb5Py6DUP2QfLqzAdQt4NanaAoqzMNe TlnVl5pambYRdQz1lRMOtQh0cLGhEXj4JRwMGyJ9wVqUlyRdac+iJc0ZA7sdnTFfGulN +tNrzfSK6xY9F1CjWP89sG4cLGhpDLLgQONzyfCvcFG/D1At3xGkcQmUbyicA7NTX5N9 ohlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=slkWU2uc; 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 dm4-20020a170907948400b007894b9de062si9010701ejc.631.2022.10.22.01.46.50; Sat, 22 Oct 2022 01:47:15 -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=slkWU2uc; 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 S234783AbiJVIqU (ORCPT + 99 others); Sat, 22 Oct 2022 04:46:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234963AbiJVIoJ (ORCPT ); Sat, 22 Oct 2022 04:44:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A8D62D5E94; Sat, 22 Oct 2022 01:07:52 -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 ams.source.kernel.org (Postfix) with ESMTPS id 8D23EB82E06; Sat, 22 Oct 2022 07:59:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E63E4C433D6; Sat, 22 Oct 2022 07:59:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425558; bh=9UrjUr8/IkPv6PWDRT8g70RM3dX0hvB24hPHyGPf0nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=slkWU2ucj/aDhflC2sfvKqSJDUJ4HHeIB5HZkOSzPrlGHOu98kZKL3SDm4WXAuwzP yudSmyFN34K0lt3hrCIHV2mEqG9dHJwLUDHy45XdQOwoLDRxsXbGGm7T0goM6fczjX YM1lC+BtLAtMxA4T6W1kgtA0bj8BQetpurLcG2bs= 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 5.19 523/717] cifs: return correct error in ->calc_signature() Date: Sat, 22 Oct 2022 09:26:42 +0200 Message-Id: <20221022072521.442957149@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747376863123137073?= X-GMAIL-MSGID: =?utf-8?q?1747376863123137073?= 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 55e79f6ee78d..334d8471346f 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);