From patchwork Mon Dec 4 13:45:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 1871561 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-cifs+bounces-257-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SkQ1X1NfVz23nJ for ; Tue, 5 Dec 2023 00:46:24 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5137228103E for ; Mon, 4 Dec 2023 13:46:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A40D425116; Mon, 4 Dec 2023 13:46:19 +0000 (UTC) X-Original-To: linux-cifs@vger.kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90AB8DF for ; Mon, 4 Dec 2023 05:46:17 -0800 (PST) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d06fffdb65so8642955ad.2 for ; Mon, 04 Dec 2023 05:46:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701697576; x=1702302376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wfmb8XynJiqsiHBGukWRvxQFEjGuoaxPT1r9zoy4zUs=; b=hQJ6isBAAHJLCBkuR+64UmZtNEEo1tVvWNNQqIxH3/zqRK/twbvrdCGaSW2Nq6oz5D X5nL/3Jmb51V7ZCFixF79NzMm+H4Wmxr/N+B36iuXjGI8W2cUMqANA15mKnH0xPj0eCd qe29gZC1PlN80tAzvNYXrpkZAIyxREr8Q24RrK1DIUg83uzCaZSq8taSV5EtTityDcFY W5PneSyrEJKlRh9OGakzUCg0JD+lGs+LWkxApgbXK1GZkXZ9X+VTMg+chKk+WCzey3lr Gc50wYLzEKSDGN8eJzHWYM4+Ds41MNUsAbCdFuHNFLKaCwWC0QFH9APeFILuQv7/35LF SzSA== X-Gm-Message-State: AOJu0YxLn6RDb32FqCELFVHk6HdNAyXkQvvkqznWHuk/hizPwYabd8C5 oaR0TEXFMs85Ib0k9RyExBXjtO8bnEg= X-Google-Smtp-Source: AGHT+IHxI790+iUO7ngLKax5QskFyQ2jPpV32FuwLh+EK+cX9huR+R64G7YzAMwDooy5SzQcVVsNBg== X-Received: by 2002:a17:902:7281:b0:1d0:bba7:4f95 with SMTP id d1-20020a170902728100b001d0bba74f95mr282683pll.51.1701697576619; Mon, 04 Dec 2023 05:46:16 -0800 (PST) Received: from localhost.localdomain ([110.14.71.32]) by smtp.gmail.com with ESMTPSA id m9-20020a170902db0900b001cfcbf4b0cbsm8428475plx.128.2023.12.04.05.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 05:46:16 -0800 (PST) From: Namjae Jeon To: linux-cifs@vger.kernel.org Cc: smfrench@gmail.com, senozhatsky@chromium.org, tom@talpey.com, atteh.mailbox@gmail.com, Namjae Jeon Subject: [PATCH 6/7] ksmbd: avoid duplicate opinfo_put() call on error of smb21_lease_break_ack() Date: Mon, 4 Dec 2023 22:45:08 +0900 Message-Id: <20231204134509.11413-6-linkinjeon@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231204134509.11413-1-linkinjeon@kernel.org> References: <20231204134509.11413-1-linkinjeon@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 opinfo_put() could be called twice on error of smb21_lease_break_ack(). It will cause UAF issue if opinfo is referenced on other places. Signed-off-by: Namjae Jeon --- fs/smb/server/smb2pdu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index 45fc4bc3ac19..f3af83dc49c4 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -8219,6 +8219,11 @@ static void smb21_lease_break_ack(struct ksmbd_work *work) le32_to_cpu(req->LeaseState)); } + if (ret < 0) { + rsp->hdr.Status = err; + goto err_out; + } + lease_state = lease->state; opinfo->op_state = OPLOCK_STATE_NONE; wake_up_interruptible_all(&opinfo->oplock_q); @@ -8226,11 +8231,6 @@ static void smb21_lease_break_ack(struct ksmbd_work *work) wake_up_interruptible_all(&opinfo->oplock_brk); opinfo_put(opinfo); - if (ret < 0) { - rsp->hdr.Status = err; - goto err_out; - } - rsp->StructureSize = cpu_to_le16(36); rsp->Reserved = 0; rsp->Flags = 0;