[PATCH 0/4] ksmbd: fix the checks on an open of an existing file
From: Ian Bridges
Date: Mon Nov 30 2026 - 00:14:07 EST
These patches fix four bugs in an open of an existing file.
Patch 1 stops a delete-on-close open from deleting a read-only file on a
share that does not store DOS attributes. Patch 2 fails an overwrite or
supersede of a directory, which ksmbd lets succeed. Patch 3 fails an
overwrite of a hidden or system file that leaves the attribute out,
which ksmbd lets empty the file. Patch 4 refuses write access to a
read-only file.
Patch 1 adds the attribute read used by patches 3 and 4. Patch 2 adds
the disposition check used by patch 3. The patches apply in the order
shown.
Tests
=====
I tested the series on ksmbd-for-next b572ec503ef0, on x86_64 with
KASAN.
- Each patch builds with W=1 and sparse. The series adds no smatch
warning.
- A script sent one request for each changed rule to the base and to
the tree at each patch. Each request got the status that its patch
describes. The requests that are not meant to change, POSIX opens
among them, gave the same results as on the base.
- smbtorture gives the same results at each patch as on the base.
KASAN reported nothing.
This series was developed with LLM assistance.
Ian Bridges (4):
ksmbd: check the cached read-only attribute for delete-on-close
ksmbd: fail an overwrite or supersede of a directory
ksmbd: fail an overwrite that would clear the hidden or system
attribute
ksmbd: refuse write access to a read-only file at open
fs/smb/server/smb2pdu.c | 131 +++++++++++++++++++++++++++++++-------
fs/smb/server/vfs_cache.c | 23 +++++++
fs/smb/server/vfs_cache.h | 1 +
3 files changed, 133 insertions(+), 22 deletions(-)
base-commit: b572ec503ef0c9dc74507b4a624df7f218da6a64
--
2.47.3