Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp394805rdb; Mon, 22 Jan 2024 07:30:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IEY4Sz16tssWukz02QMXyQaxaUteM9hwVjOTBqdPl0zekqVPKPXD/lwCANKudf8KWYZL1O9 X-Received: by 2002:a17:906:bfc8:b0:a2d:5d73:8fb5 with SMTP id us8-20020a170906bfc800b00a2d5d738fb5mr2254601ejb.59.1705937430286; Mon, 22 Jan 2024 07:30:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705937430; cv=pass; d=google.com; s=arc-20160816; b=NzsvsJdyjKeB2pRYlSAPQWOXmSrCUMFcT9HS3gILGgh0FL6ILJB59baCFX/Cd/lHdR eFoNIIPFYgFBw/jh2OoBRF3R4gZVe482BBGq+dwM99HL7XZy5X28MxBiq2zSLf5jQl+/ DqnNauc5g4bdiWOT4qigliWIPL+4ThWIgSWWPfuN0/3lQzqeMb1iAxu/gW6Ly/m6c18/ trDHbRLZWOcuCnDlCopuFx0QtaSDGCe1LlpiTFU5zNaIGPooFUMyES3JskMP20N3ElgZ CfdiJ1vmaoALRnaoch+2M4gAkimGfllA0EKACl79vBzM+nSHERrfVl+tw+DOlr5eIRf3 9X9A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=DcZF9aqZ3zc/z2jP/pB/pnq6uiGTPbOkvVixIBejDEY=; fh=YCpWGDe4dlD/Msuo/KjbMNPS2Hvd2LSPoVlNK8Y+dew=; b=GMvCmuQS9m49qWEu0p7ukc3e2GjXUpV7LJOq8MpPUN0OZJHvRl9oJJ9irZhSteAnCY iNxSGPTdL13oMUGxtBn4QWBZtDgrGcioH4u8FTJAt9zq/6nCXI5RLcAuqu76Zy4B+1eW R1cOx2rs5o7LwLNWiUfLOhnVlIm8bsq/Q0gUax6fNNq9yb1pyJMDKHHIvb/7WPvr9L4h TTEcTTHiagQH4jaPOhFK6g0/2d10UW6ytuk+TljKriiG9OMD56OXnN2YDgqqMzEZhZBi Ei+I/BuYc9Rr/4sEdKHu1Rh4QHZY8RCbA4LuEfdVALjuIcpYJseMN28qimr8IPkH8m/2 9wAQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WrPBoaLd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33309-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q9-20020a170906678900b00a2de3fac739si7672943ejp.699.2024.01.22.07.30.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 07:30:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WrPBoaLd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33309-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0E03A1F2109C for ; Mon, 22 Jan 2024 15:30:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 868E65FDD7; Mon, 22 Jan 2024 15:02:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WrPBoaLd" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A83315FDBE; Mon, 22 Jan 2024 15:02:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705935744; cv=none; b=GYxAvkMKgIK4dsZJeEwlpjWWOvrFU+UTr3n9dp0YkIbmks/2U1tYLsZh+f2W8Avx2MW1HOBFKUDVmtg0sg/xatnbuIag06diyTqHXyTwNOPYRxp2XSTrSg+4v5e3q1eJW/vxKfnR1UcEakVmXNI3JYGfA/wYjVTbsfnRu3ew9BQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705935744; c=relaxed/simple; bh=1v7yhRkCsHnbDmrDhYU7jxmxAs6MM8X4JDMXcOlc/Ik=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=diCzbLWr6rYV41lp2WHqrFQWdFFZLMgnzniOcdMljPxDYpk2LsqqLemC0tikmkUPNT3x8Uoy5Gwt/IXlYd83xc+zPy8K0sVY6NF7EuCONfFZUTbMpoc/yytHKHtddYEjg2nu4VI7NV46oKsoR+wBpemkSI+ZJLL5tx50Ylj1xzQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WrPBoaLd; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CEE9C43609; Mon, 22 Jan 2024 15:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705935744; bh=1v7yhRkCsHnbDmrDhYU7jxmxAs6MM8X4JDMXcOlc/Ik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WrPBoaLdKpc/ydnrl4Nd/dQgAaWaKE6KytsSOY6i/NIvyR8xKKMeNmbvGiuz+ldWi oZ1wrJYprWofvIlM9FTIcAMg/fgZZqIh3zcJVgSmmhy2vGTopbSMAn3TDfGZSlVO2Z bk9T9rhXu45kBmj9OhqquuRK+MB7WdwZNeOJZGzrReh8iWhHwH1cZNYm9wIsDfXhtV PmsMzIGUxhFTNVHaS8nmT9vcJoi4L7NMyAdxDY+ThzN20o5fZClVL2WQO8Xp9NZf46 vecV1mBxxfAig2AzGEpvNmq1zXRkQyVsyn07IV+eTOVUUuuuwiznVVixsvG1i4oVFW IkjLhSfBIufiQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Namjae Jeon , Steve French , Sasha Levin , sfrench@samba.org, linux-cifs@vger.kernel.org Subject: [PATCH AUTOSEL 6.7 87/88] ksmbd: fix potential circular locking issue in smb2_set_ea() Date: Mon, 22 Jan 2024 09:52:00 -0500 Message-ID: <20240122145608.990137-87-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122145608.990137-1-sashal@kernel.org> References: <20240122145608.990137-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.7.1 Content-Transfer-Encoding: 8bit From: Namjae Jeon [ Upstream commit 6fc0a265e1b932e5e97a038f99e29400a93baad0 ] smb2_set_ea() can be called in parent inode lock range. So add get_write argument to smb2_set_ea() not to call nested mnt_want_write(). Signed-off-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/smb/server/smb2pdu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index 652ab429bf2e..a2f729675183 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -2311,11 +2311,12 @@ static noinline int create_smb2_pipe(struct ksmbd_work *work) * @eabuf: set info command buffer * @buf_len: set info command buffer length * @path: dentry path for get ea + * @get_write: get write access to a mount * * Return: 0 on success, otherwise error */ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, - const struct path *path) + const struct path *path, bool get_write) { struct mnt_idmap *idmap = mnt_idmap(path->mnt); char *attr_name = NULL, *value; @@ -3003,7 +3004,7 @@ int smb2_open(struct ksmbd_work *work) rc = smb2_set_ea(&ea_buf->ea, le32_to_cpu(ea_buf->ccontext.DataLength), - &path); + &path, false); if (rc == -EOPNOTSUPP) rc = 0; else if (rc) @@ -5992,7 +5993,7 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp, return -EINVAL; return smb2_set_ea((struct smb2_ea_info *)req->Buffer, - buf_len, &fp->filp->f_path); + buf_len, &fp->filp->f_path, true); } case FILE_POSITION_INFORMATION: { -- 2.43.0