Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Ian Bridges <icb@fastmail.org>
To: Namjae Jeon <linkinjeon@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	Tom Talpey <tom@talpey.com>,
	ChenXiaoSong <chenxiaosong@chenxiaosong.com>,
	Ian Bridges <icb@fastmail.org>,
	linux-cifs@vger.kernel.org
Subject: ksmbd: refactor security descriptor handling?
Date: Tue,  3 Nov 2026 19:07:25 -0600	[thread overview]
Message-ID: <20261104010725.50071-1-icb@fastmail.org> (raw)

Hi Namjae,

Would you be open to a refactor of the security descriptor (SD)
handling in fs/smb/server/smbacl.c?

Since February 2025 smbacl.c has taken 24 fixes for bounds checking,
sizing and SID validation, 20 of them this year. Several readers walk
the SD bytes independently, each with its own validation
(parse_sec_desc() and parse_dacl(), smb_inherit_dacl(),
smb_check_perm_dacl() and build_sec_desc()), and the QUERY_INFO reply
is sized by an estimate and then written ACE by ACE.

Roughly, the plan would be
 - One decoder, one encoder and one decoded type. The decoder checks
   the whole SD once and returns a structure that callers read and
   build from, without handling SD bytes themselves. The encoder
   computes the exact size first and bounds every write by it.
 - QUERY_INFO, SET_INFO and inheritance moved onto them one caller at
   a time. The access check stays as it is.
 - Current behaviour kept, apart from rejecting a malformed SD before
   it is stored or used. Everything stays inside fs/smb/server.

I would test it with KUnit tests next to the existing smbacl tests,
smbtorture's smb2.acls tests, and by comparing each converted path
against the unmodified module. I would also check the decoder and the
encoder with CBMC, a bounded model checker, for memory safety on every
SD up to a fixed size, and can share the harnesses.

If you are open to it, I would send a prototype as an RFC series. Is
anyone already working in this area, or is there anything you would
like done differently?

Thanks,
Ian

             reply	other threads:[~2026-11-04  1:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  1:07 Ian Bridges [this message]
2026-11-04  1:19 ` ksmbd: refactor security descriptor handling? Namjae Jeon
2026-11-04  1:32   ` ChenXiaoSong
2026-11-04  1:48     ` Namjae Jeon

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=20261104010725.50071-1-icb@fastmail.org \
    --to=icb@fastmail.org \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@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