From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796104216; b=1u2NYH6JcT5ISmjNqDlJJ1tJ2lImw1k+79+r54VfHaod2ssNQ0YzY+XyIloqRwerSO/U S+9sFZiarU22UtHw0qvjeL+wjk1lmEwYz3LLpXqfvAg9mQ6AhG91SewDf1VLZR9AzlEk0 Np5O9Xit96acVThPFEIGu+tZo2O4DKYwEbG+WRMzDaoowmofYMI6lpuhNkTPEkEZKH08k /tZNKrH4fYQaLQHfb/fr9AWexPUIUE5Xf7xHOX4+WqW/9ispcyT++aZUYbH1Xtycvhs4d ugwwJ+Pv1hTP1CgdUsziWw1IHyuufbOgkoZpxul/dUyKf0xkGFMWNDjEMdhyNPff+Zg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796104216; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=zmONzvIG92pUc/+dsef7wKvSD+FUENTmYJdokNn6iug=; b=2kWfINwI+o7zXUfcMw3Tp3qlAzQcyy2/y15CxweEHlNNmUMfyzFaObpclQ/LxUjclqgT REkoACNzrHgtkvHsI2NrL8PayVTm1I6z5bxkSXZh9bveuKlRd61Ug3iZcm4lzDxzTVPWb RMs/OumrZF8gnzswjB88meDRuy1GfCs5ozw1m7KNTqtuG62RS12AeqzRUgWP1M3qL1Xef VkSlT9kudFOjj5v+mqQMD6zcTV58M2PeCV0M0ai4hj2ADzLYh8NqTtZv2kxA6MG69XXQe 3M2rqilVQxeJtryrz5DlK0+k7JcN+YFcz5Fw1Vw33J/CBIkgLmxobxJaaBfPE1suNzw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chenxiaosong.com; spf=pass smtp.mailfrom=chenxiaosong.com; dkim=pass header.d=chenxiaosong.com header.i=@chenxiaosong.com header.a=rsa-sha256 header.s=key1 header.b=QQ+FdLs3; arc=none smtp.remote-ip=95.215.58.175 Received: from mta1.migadu.com (out-175.mta1.migadu.com [95.215.58.175]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2B20606A320 for ; Tue, 1 Dec 2026 05:50:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C2B20606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chenxiaosong.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chenxiaosong.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=chenxiaosong.com header.i=@chenxiaosong.com header.a=rsa-sha256 header.s=key1 header.b=QQ+FdLs3 X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=kCpLvBIyGTnrAEQct2KFEBBwGU5SXFFSyRqEVht3d6I=; c=simple/simple; d=chenxiaosong.com; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796104212; v=1; x=1796709012; b=QQ+FdLs3F+nUHXk5OtiFc599KsnhtLeAMektvOD+O+M3S1OXBiESaR/zp353NgvYKG/C4n4A aCZE+zehMEec1LXHKsAvaxWIQEUcPZvR36tkY0AmNzV2wVcMLoDSdmcV2h1tCVrgad7GB/Vvx0c F2tozs36TCYKLg8YGXAl3mT3XNO2Zr+xA9VSQf/beL5p6TWBEa+JewdQug9M+rJa+ONFI8vMTvh V7XUX5tzGuxO7RDNghm8ro4lEZBkbThmBGx+U9keTBQ/DWFEiriKinsvOQXd0ilFYWI5tH6QZGQ +zIJE/Oz2lJBhWFPatSfXfSg09wxdQETxEEwByiNzbrlQ== X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 1c75b79193851dac; Tue, 01 Dec 2026 05:50:11 +0000 X-Mizu-Trace-ID: 1c75b79193851dac X-Migadu-Flow: FLOW_OUT Message-ID: <1b25ec93-28e1-498a-884a-fbdbcfd34083@chenxiaosong.com> Date: Tue, 1 Dec 2026 13:50:04 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] ksmbd: fail FILE_CREATE of a named stream that exists To: Ian Bridges , linkinjeon@kernel.org Cc: senozhatsky@chromium.org, tom@talpey.com, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261201034720.2178803-1-icb@fastmail.org> Content-Language: en-US From: ChenXiaoSong In-Reply-To: <20261201034720.2178803-1-icb@fastmail.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Reviewed-by: ChenXiaoSong On 12/1/26 11:47, Ian Bridges wrote: > An open with FILE_CREATE of a named stream that already exists > succeeds, and the client gets a handle to the existing stream. The > stream lookup ignores case, so a name that differs only in case also > opens the existing stream. A client that uses FILE_CREATE to make a new > stream cannot tell that the stream existed, and its writes change the > existing data. > > Fail an open with FILE_CREATE of an existing named stream with > STATUS_OBJECT_NAME_COLLISION, as an open with FILE_CREATE of an > existing file already fails. > > The handle gets its stream name before the stream is looked up, so a > failed open of a stream is closed as a stream handle. When another > handle of the file has delete-on-close on a stream, that close can > remove the stream that the failed open named. The new failure would > then delete the existing stream. Make the handle a stream handle only > after the stream is opened. > > Suggested-by: ChenXiaoSong > Signed-off-by: Ian Bridges > --- > v2: Make the handle a stream handle only after the stream is opened, > as ChenXiaoSong suggested. Sashiko found that the failed FILE_CREATE > could remove the existing stream when another handle of the file has > delete-on-close on a stream. > > Tested on ksmbd-for-next 87ff512becd4, on x86_64 with KASAN. A script > sent FILE_CREATE of an existing named stream in several forms, and the > other dispositions, to the base and to the patched server. Each > FILE_CREATE of an existing stream got STATUS_OBJECT_NAME_COLLISION and > left the stream as it was. The others gave the same results as on the > base. A second script held delete-on-close on one stream of a file and > then sent a FILE_CREATE of another existing stream of the file. With > v1 the existing stream was removed. With v2 the existing stream was > kept. smbtorture gives the same results as on the base, and KASAN > reported nothing. > > This patch was developed with LLM assistance. > > fs/smb/server/smb2pdu.c | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) -- ChenXiaoSong Chinese Homepage: https://chenxiaosong.com English Homepage: https://chenxiaosong.com/en