mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Bridges <icb@fastmail.org>
To: linkinjeon@kernel.org
Cc: senozhatsky@chromium.org, tom@talpey.com,
	chenxiaosong@chenxiaosong.com, linux-cifs@vger.kernel.org,
	linux-kernel@vger.kernel.org, Ian Bridges <icb@fastmail.org>
Subject: [PATCH] ksmbd: don't create a missing stream for FILE_OVERWRITE
Date: Fri, 27 Nov 2026 18:39:13 -0600	[thread overview]
Message-ID: <20261128003913.1684555-1-icb@fastmail.org> (raw)

An open of a named stream that does not exist fails with
STATUS_OBJECT_NAME_NOT_FOUND only for FILE_OPEN. With FILE_OVERWRITE
the stream is created and the open succeeds. MS-FSA 2.1.5.1.2 fails
both dispositions when the stream is not found. Fail FILE_OVERWRITE the
same way. FILE_OVERWRITE_IF still creates the stream.

Signed-off-by: Ian Bridges <icb@fastmail.org>
---
Tested on ksmbd-for-next b9eab18ab72e with KASAN. A FILE_OVERWRITE open
of a missing named stream now fails with STATUS_OBJECT_NAME_NOT_FOUND,
and no stream is created. FILE_OVERWRITE of an existing stream and
FILE_OVERWRITE_IF of a missing one still succeed. smbtorture gives the
same results as on the base.

This patch was developed with LLM assistance.

 fs/smb/server/smb2pdu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index f286f9818643..e073b96d92a6 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3747,6 +3747,10 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
 		return -EBADF;
 	}
 
+	/* FILE_OVERWRITE does not create a missing stream (MS-FSA 2.1.5.1.2) */
+	if (fp->cdoption == FILE_OVERWRITE_LE)
+		return -EBADF;
+
 	if (!test_tree_conn_flag(fp->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE))
 		return -EACCES;
 

base-commit: b9eab18ab72ec25abf431cba58e5239f695632f7
-- 
2.47.3


                 reply	other threads:[~2026-11-28  0:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261128003913.1684555-1-icb@fastmail.org \
    --to=icb@fastmail.org \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®