From patchwork Thu Jul 28 13:49:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 12931313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABDBDC19F29 for ; Thu, 28 Jul 2022 13:50:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229613AbiG1NuD (ORCPT ); Thu, 28 Jul 2022 09:50:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbiG1NuC (ORCPT ); Thu, 28 Jul 2022 09:50:02 -0400 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86AE762A46; Thu, 28 Jul 2022 06:50:01 -0700 (PDT) Received: by mail-pl1-f181.google.com with SMTP id iw1so1855991plb.6; Thu, 28 Jul 2022 06:50:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fJlProHpWW9lA3WyeUazKlvpeQSoWqdtf8mgGAQ1wPw=; b=wWPvvE3yI/Pof8ahiH9nqN8JO24ANfKJjPD8mQDckMwahfgdDL1OSkGUtbmZXuxYx6 0tBNn6NU12oxxu/HKx0DuQuExSXJMTiKd/FZstzjr6mRzpB9NfHxV5lLKSebRXMRBKvT dFOgPYcbgoYbX5RAoF0QkpCiG8BrYRIZ84Nl8tb0wZZJykTxT74PONPdMdsscFr9CiVs yPiKQasQyMdBFbX6PCBIuVuRBFX7uCb8P1VM+RqloEZjnIzQt7e2wwaihCOjPnijiqyV XZnq+gNGI9rHdN0laohqyFPdSJrIEJZBK+h1zYUBzQTIebWc2dM5mR6Qy+6XMhLFBC2b XcZA== X-Gm-Message-State: AJIora/mkEIVbPF/SBVM2yn4aeyeqfemqGWu44TJkMRLuKvvALU6aJv8 xUeSrJ7862NQnnuWXlb1mpa70VYkhMs= X-Google-Smtp-Source: AGRyM1v6aYSYrvI41+mRmrHxLskgNMXm7Cidh4rif86mbxC+aINcd9A2013vF9kyrreNjgHmd9XXJw== X-Received: by 2002:a17:90b:78d:b0:1ef:c46f:19a7 with SMTP id l13-20020a17090b078d00b001efc46f19a7mr10341009pjz.216.1659016200777; Thu, 28 Jul 2022 06:50:00 -0700 (PDT) Received: from localhost.localdomain ([211.49.23.9]) by smtp.gmail.com with ESMTPSA id q8-20020a170902eb8800b0016cf985c0fcsm491712plg.124.2022.07.28.06.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 06:50:00 -0700 (PDT) From: Namjae Jeon To: linux-cifs@vger.kernel.org Cc: smfrench@gmail.com, hyc.lee@gmail.com, senozhatsky@chromium.org, gregkh@linuxfoundation.org, Namjae Jeon , stable@vger.kernel.org, zdi-disclosures@trendmicro.com Subject: [PATCH v2 1/5] ksmbd: fix memory leak in smb2_handle_negotiate Date: Thu, 28 Jul 2022 22:49:42 +0900 Message-Id: <20220728134946.7603-1-linkinjeon@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org The allocated memory didn't free under an error path in smb2_handle_negotiate(). Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3") Cc: stable@vger.kernel.org Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-17815 Signed-off-by: Namjae Jeon Reviewed-by: Hyunchul Lee --- v2: - add missing fixes and stable tags. fs/ksmbd/smb2pdu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index 1f4f2d5217a6..41ef076af072 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -1142,12 +1142,16 @@ int smb2_handle_negotiate(struct ksmbd_work *work) status); rsp->hdr.Status = status; rc = -EINVAL; + kfree(conn->preauth_info); + conn->preauth_info = NULL; goto err_out; } rc = init_smb3_11_server(conn); if (rc < 0) { rsp->hdr.Status = STATUS_INVALID_PARAMETER; + kfree(conn->preauth_info); + conn->preauth_info = NULL; goto err_out; }