linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
Cc: linux-security-module@vger.kernel.org
Subject: Re: [PATCH] ima: reject duplicate fsname= in a policy rule
Date: Thu, 12 Nov 2026 07:05:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-210568@kernel.org> (raw)
In-Reply-To: <20261112-c3-n204-v1-1-dd9400b9ece8@illinois.edu>

> From: Weidong Wang <weidongw@illinois.edu>
> 
> ima_parse_rule() stores the fsname= value with kstrdup() but, unlike
> fsmagic=, fs_subtype= and the other options, does not check whether the
> rule already has one. A rule that names fsname= twice overwrites
> entry->fsname and leaks the first string.
> 
> Reject the duplicate with -EINVAL, as fs_subtype= does. Such a rule used
> to be accepted with the last fsname= taking effect; giving the option
> twice was never meaningful, and the other options already reject it.
> 
> Writing the policy requires CAP_SYS_ADMIN, so the leak is limited to a
> few bytes per malformed rule loaded by a privileged user.
> 
> The leak was found by an AI code review agent (an LLM-based bug-finding
> tool developed by Zijie Zhao and the submitter) and confirmed on an
> unmodified kernel, without error injection, on x86_64 under QEMU with
> kmemleak: loading 64 rules with a duplicated fsname= left 64
> unreferenced objects allocated by kstrdup() in ima_parse_rule() (inlined
> into ima_parse_add_rule()); the same rules with a single fsname= left
> none. With this patch the duplicate rules are rejected and kmemleak
> reports nothing; rules with a single fsname= are still accepted.
> 
> The reproducer, fix and changelog were drafted with AI assistance
> (Claude), then reviewed and tested by the submitter.
> 
> Fixes: f1b08bbcbdaf ("ima: define a new policy condition based on the filesystem name")
> Cc: Zijie Zhao <zijie4@illinois.edu>
> Signed-off-by: Weidong Wang <weidongw@illinois.edu>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112-c3-n204-v1-1-dd9400b9ece8@illinois.edu?part=1


      reply	other threads:[~2026-11-12  7:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  6:56 [PATCH] ima: reject duplicate fsname= in a policy rule Weidong Wang via B4 Relay
2026-11-12  7:05 ` sashiko-bot [this message]

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=sashiko-outbox-210568@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).