public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: GUO Zihua <guozihua@huawei.com>,
	dmitry.kasatkin@gmail.com, jmorris@namei.org, serge@hallyn.com
Cc: linux-integrity@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] ima: fix deadlock when traversing "ima_default_rules".
Date: Tue, 07 May 2024 07:54:05 -0400	[thread overview]
Message-ID: <baff6527d8d1e1f7287e33d6a8570bd242d5cadf.camel@linux.ibm.com> (raw)
In-Reply-To: <20240507093714.1031820-1-guozihua@huawei.com>

On Tue, 2024-05-07 at 09:37 +0000, GUO Zihua wrote:
> From: liqiong <liqiong@nfschina.com>
> 
> [ Upstream commit eb0782bbdfd0d7c4786216659277c3fd585afc0e ]
> 
> The current IMA ruleset is identified by the variable "ima_rules"
> that default to "&ima_default_rules". When loading a custom policy
> for the first time, the variable is updated to "&ima_policy_rules"
> instead. That update isn't RCU-safe, and deadlocks are possible.
> Indeed, some functions like ima_match_policy() may loop indefinitely
> when traversing "ima_default_rules" with list_for_each_entry_rcu().
> 
> When iterating over the default ruleset back to head, if the list
> head is "ima_default_rules", and "ima_rules" have been updated to
> "&ima_policy_rules", the loop condition (&entry->list != ima_rules)
> stays always true, traversing won't terminate, causing a soft lockup
> and RCU stalls.
> 
> Introduce a temporary value for "ima_rules" when iterating over
> the ruleset to avoid the deadlocks.
> 
> Addition:
> 
> A rcu_read_lock pair is added within ima_update_policy_flag to avoid
> suspicious RCU usage warning. This pair of RCU lock was added with
> commit 4f2946aa0c45 ("IMA: introduce a new policy option
> func=SETXATTR_CHECK") on mainstream.
> 
> Signed-off-by: liqiong <liqiong@nfschina.com>
> Reviewed-by: THOBY Simon <Simon.THOBY@viveris.fr>
> Fixes: 38d859f991f3 ("IMA: policy can now be updated multiple times")
> Reported-by: kernel test robot <lkp@intel.com> (Fix sparse: incompatible types in comparison expression.)
> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
> Sig=ned-off-by: GUO Zihua <guozihua@huawei.com>

Hi Scott,

I'm confused by this patch.  Is it meant for upstream?

thanks,

Mimi


  reply	other threads:[~2024-05-07 11:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-07  9:37 [PATCH] ima: fix deadlock when traversing "ima_default_rules" GUO Zihua
2024-05-07 11:54 ` Mimi Zohar [this message]
2024-05-08  2:06   ` Guozihua (Scott)
2024-05-08  7:06     ` Guozihua (Scott)
2024-05-23 11:44       ` Greg KH

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=baff6527d8d1e1f7287e33d6a8570bd242d5cadf.camel@linux.ibm.com \
    --to=zohar@linux.ibm.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=guozihua@huawei.com \
    --cc=jmorris@namei.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=stable@vger.kernel.org \
    /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