Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2198607iof; Tue, 7 Jun 2022 22:59:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmyl+UxYIpPKKs00Mf8D2jgmNw++Js1d94I9mHYZCe+qVAsktEartxKQXlmw+VFasR2Ezr X-Received: by 2002:a17:90a:6390:b0:1e0:a47b:a57a with SMTP id f16-20020a17090a639000b001e0a47ba57amr69765927pjj.115.1654667942575; Tue, 07 Jun 2022 22:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667942; cv=none; d=google.com; s=arc-20160816; b=Shysr6Zk1Pvs2KZvCsDCoaapfrlSjOOYTH2JcuvQx1QyViimzXMoWyWgA8xAvb87hE 765OL+1qtnbzlY6pzLpvp+jaYOfs34ImnHHtYtZDZbvdtPkN6yabwyMVGxhK2KkFYMN+ gn4z5NFyAtMJ8pLc98Zj7UcXQvrjGsHyUFWRa5KJinhMhV7nwEfneHdfGapPyxzzAGLx 9fSLSh5aYlhxRTtqEmnghpUclUk84ZyjgSHCYTu1EZhzds/dRBfrsBBKa3SP2VFZKSnU ZQSHKKiCsqqodDF0MJ+oR6YNEv45+p4waRUW2eXcoCLdk2dJa5VaKDXovxOq2vrqNgWa T6rw== 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=V5OZRI8M8K9lYf4WYTEK30L6Cob657+hcr+o8U94jzU=; b=wDKkdrEhpPcrferz5b8k+TQrZCsLIYDSJJot/XJf6kOanksZfhyiD4H6tCxDV1K89k XyH2MmIcdpcGwInT8v6hknyA8Xb6aR1HhhHDZd+G6/ZQ+sV+tmF6nHeM+x8UolhmOSu3 JoEEg+Cj4vreqk4Ek750gDRG1ZmXneEyQOrdlB2gfIAVO8+IuCr9BuxSLalDrToJ/myX 6O9a1npYVbQ4US/5F7WyHFvEZdBPKyxTUSZlAOp2WTwQRPxK6xXnEUtICTyOt9f2ZXJk iVRp+bkgljebiykkZDTjrxk0qmWmI+RAYHZbtX65yllIv0cySUet6gH72T9zypFhiXSL E+cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vf2zvPlW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d15-20020a170903230f00b00163c985bb45si14270808plh.101.2022.06.07.22.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:59:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vf2zvPlW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0C2E2527F3; Tue, 7 Jun 2022 22:26:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444939AbiFHBIc (ORCPT + 99 others); Tue, 7 Jun 2022 21:08:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380777AbiFGW15 (ORCPT ); Tue, 7 Jun 2022 18:27:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A97A4272341; Tue, 7 Jun 2022 12:23:29 -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 E9FB460B09; Tue, 7 Jun 2022 19:23:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C56F6C385A2; Tue, 7 Jun 2022 19:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629808; bh=gdjgGA3jTeWt39F5XYCk+VKfrnsbIggp1l16MZwXDVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vf2zvPlWej4IcNIOzyS3tYhEcNaqJtIbLVy1w5v8REoAhXEcUMGnLWB43uDWioorV U3TKJ8PxpNjGb8S5AZS5iJ3YeGMD5m29VqcKHJCwe9OS+GUfRlxjwUW385rzWpVYTJ 7x/ttEPc2DE2gIYT8v0U/2Xyg0+PcdX7U4VwUlgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hyunchul Lee , Yufan Chen , Namjae Jeon , Steve French Subject: [PATCH 5.18 824/879] ksmbd: fix outstanding credits related bugs Date: Tue, 7 Jun 2022 19:05:42 +0200 Message-Id: <20220607165026.772893494@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Hyunchul Lee commit 376b9133826865568167b4091ef92a68c4622b87 upstream. outstanding credits must be initialized to 0, because it means the sum of credits consumed by in-flight requests. And outstanding credits must be compared with total credits in smb2_validate_credit_charge(), because total credits are the sum of credits granted by ksmbd. This patch fix the following error, while frametest with Windows clients: Limits exceeding the maximum allowable outstanding requests, given : 128, pending : 8065 Fixes: b589f5db6d4a ("ksmbd: limits exceeding the maximum allowable outstanding requests") Cc: stable@vger.kernel.org Signed-off-by: Hyunchul Lee Reported-by: Yufan Chen Tested-by: Yufan Chen Acked-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/ksmbd/connection.c | 2 +- fs/ksmbd/smb2misc.c | 2 +- fs/ksmbd/smb_common.c | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) --- a/fs/ksmbd/connection.c +++ b/fs/ksmbd/connection.c @@ -62,7 +62,7 @@ struct ksmbd_conn *ksmbd_conn_alloc(void atomic_set(&conn->req_running, 0); atomic_set(&conn->r_count, 0); conn->total_credits = 1; - conn->outstanding_credits = 1; + conn->outstanding_credits = 0; init_waitqueue_head(&conn->req_running_q); INIT_LIST_HEAD(&conn->conns_list); --- a/fs/ksmbd/smb2misc.c +++ b/fs/ksmbd/smb2misc.c @@ -338,7 +338,7 @@ static int smb2_validate_credit_charge(s ret = 1; } - if ((u64)conn->outstanding_credits + credit_charge > conn->vals->max_credits) { + if ((u64)conn->outstanding_credits + credit_charge > conn->total_credits) { ksmbd_debug(SMB, "Limits exceeding the maximum allowable outstanding requests, given : %u, pending : %u\n", credit_charge, conn->outstanding_credits); ret = 1; --- a/fs/ksmbd/smb_common.c +++ b/fs/ksmbd/smb_common.c @@ -140,8 +140,10 @@ int ksmbd_verify_smb_message(struct ksmb hdr = work->request_buf; if (*(__le32 *)hdr->Protocol == SMB1_PROTO_NUMBER && - hdr->Command == SMB_COM_NEGOTIATE) + hdr->Command == SMB_COM_NEGOTIATE) { + work->conn->outstanding_credits++; return 0; + } return -EINVAL; }