From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795034231; b=Smjj+ljQfa3TWGYSk9TvUk8bAJwHpXXLKUatDK45Lap6S0Wu9tEAmaHAhSDuNgrr9WmM sSVjwIal8Wa7nfxfryHEoMUkuISt5sm3u8zNgqSKlItq0HhW7Cj0J4LWJAc2stbGquwSv Ob7sCbgqrOXFKn+cTN72eykWcNX7KkrXEPtJJ3VgVGm7Il6wEzHyF8InKY73GOohxBQst pBvkZQtT1CZHBk/E6kMR9Z5cve56KeGzlNYhTdccjFwF4HAM8u4iClmxvMhcmxZLyS6bb WEYQT9SscJ88TBCGiIsC3ADmGPA+fYeaFR+yK87WYemx5h+ppt00ticjjBhFYfvWoKg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795034231; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=jPtZ0VYAfBujnaD1ywlCnkZW6CPFFm7y4RGMyLyKS+E=; b=k/mnvh3O69mkC1ltijGNeACd16JgaiyG/D5EFlY84cGUDGI0Zn9Wd1+k2ltbLGZLnIN8 QyQDrrjrv+TxMBJnhKV+GdDFaimqyJMZSjrP1WeC/HrMP8wWzBkEQjxy5/AhB2BYboVu5 1q2VECfSQ6yrKYR+/bISFMD98OQ7U51gkKCebgKSObHgy2sC43Wcywxf5906gRARKu8r0 Tg+aGNW0o+PTfc2MkRoLnQGxboGeZcyZhGzksZyfkhHKTfE/1zwNCMgFmO3SVVNSBttsH vn7ctHPKSI8xRfFgaRxH/+bdhIvvXCmI+DwW5ZebGGDnrW4xRuDIEnjxWVwCWnPIBlw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=GBLZi2vX; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11B63606A33F; Wed, 18 Nov 2026 20:37:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=GBLZi2vX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 610BA1F000C4; Wed, 18 Nov 2026 20:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795034230; bh=jPtZ0VYAfBujnaD1ywlCnkZW6CPFFm7y4RGMyLyKS+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GBLZi2vXm+7VaKWA05JVwYrff/vuKuP9IPESnSR7MoxrIXp34szCHtPu4y1WDm2Fb EwMMbaP/7ChvvOuKs2wJpe67hv88hnvf8fepgMJ8yJv/iIbwhXguI3l15saUPye8T2 JXb1nRJjKVn/axLbiIhcUZ30oicxTArU1+pRDnyM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gael Blivet , Namjae Jeon , Sasha Levin Subject: [PATCH 6.6 0297/3318] ksmbd: fix AsyncId zeroed before use in smb2_lock() cancel response Date: Wed, 18 Nov 2026 15:15:19 +0100 Message-ID: <20261118150324.578903025@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gael Blivet [ Upstream commit 7b461610882c8baa64d56dade57cdbfb686739fa ] release_async_work() zeroes work->async_id before the CANCELLED path calls smb2_send_interim_resp(work, STATUS_CANCELLED), which reads work->async_id to build the response's AsyncId field. The cancellation response for a cancelled blocked-lock request is sent with AsyncId=0 instead of the id the client received in the original STATUS_PENDING response for this request. Checked against every other release_async_work() call site in this file: smb2_read()/smb2_write() don't send a further async response afterward (their status goes out on the synchronous path instead), and smb2_notify()'s two async paths already transfer the id to a separate struct before releasing, so this reordering is scoped to smb2_lock() only. Send the STATUS_CANCELLED response while work->async_id is still valid, then release the async work afterward. Signed-off-by: Gael Blivet Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Namjae Jeon Signed-off-by: Sasha Levin --- fs/smb/server/smb2pdu.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index 4ed7fae342be5..2d18b5de63f68 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -7846,22 +7846,25 @@ int smb2_lock(struct ksmbd_work *work) spin_unlock(&fp->f_lock); list_del(&smb_lock->llist); - release_async_work(work); - - if (work->state == KSMBD_WORK_ACTIVE) - goto retry; - - locks_free_lock(flock); if (work->state == KSMBD_WORK_CANCELLED) { rsp->hdr.Status = STATUS_CANCELLED; kfree(smb_lock); smb2_send_interim_resp(work, STATUS_CANCELLED); + release_async_work(work); + locks_free_lock(flock); work->send_no_response = 1; goto out; } + release_async_work(work); + + if (work->state == KSMBD_WORK_ACTIVE) + goto retry; + + locks_free_lock(flock); + rsp->hdr.Status = STATUS_RANGE_NOT_LOCKED; kfree(smb_lock); -- 2.53.0