mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jérémy Jean" <jeremy.jean@oss.cyber.gouv.fr>
To: Roberto Sassu <roberto.sassu@huaweicloud.com>
Cc: Mimi Zohar <zohar@linux.ibm.com>,
	Roberto Sassu <roberto.sassu@huawei.com>,
	Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
	Eric Snowberg <eric.snowberg@oracle.com>,
	linux-integrity@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] evm: fix TOCTOU heap OOB in protected xattr reads
Date: Mon, 09 Nov 2026 21:05:40 +0100	[thread overview]
Message-ID: <10660aa25fd9d868a391a1c092fe8b33@oss.cyber.gouv.fr> (raw)
In-Reply-To: <98d6c26c-3dc4-4659-8284-a7ab0629bb40@huaweicloud.com>

On 2026-11-09 10:07, Roberto Sassu wrote:
> On 11/8/2026 12:05 AM, Jérémy Jean wrote:
>> ima_eventinodexattrs_init_common() queries the total size of protected
>> xattrs, allocates that amount, and calls evm_read_protected_xattrs()
>> again to fill the buffer. This creates a TOCTOU window: if the
>> protected xattr changes between the two calls to
>> evm_read_protected_xattrs(), names and lengths are written without
>> checking whether the data still fits in the target buffer. This can
>> yield an OOB heap write that KASAN reports as:
>> 
>>    BUG: KASAN: slab-out-of-bounds in 
>> evm_read_protected_xattrs+0x15e/0x280
>>    Write of size 20 at addr ffff888002c59bcd by task init/62
>> 
>> Reject fields that no longer fit in the target buffer. For xattr
>> values, also check the length returned by the copy before accounting 
>> it.
>> This also handles the case where a size of 0 is treated as a length
>> query.
>> 
>> Fixes: 8314b6732ae4e ("ima: Define new template fields xattrnames, 
>> xattrlengths and xattrvalues")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
>> ---
>> Changes since v1 (after review from Sashiko):
>> - Handle the 0 case.
> 
> Hi Jeremy
> 
> I already sent a patch to the mailing list to fix the same problem (it 
> is similar to yours):
> 
> https://lore.kernel.org/linux-integrity/20261029142707.2602008-1-roberto.sassu@huaweicloud.com/
> 
> Thanks
> 
> Roberto

Hello Roberto,

Argh, I missed it when I prepared my fix, and even wasted time preparing 
a v2.
Thanks for the pointer though, good that this will get fixed.

Regards,
Jérémy

  reply	other threads:[~2026-11-09 20:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07 23:05 Jérémy Jean
2026-11-09  9:07 ` Roberto Sassu
2026-11-09 20:05   ` Jérémy Jean [this message]
2026-11-10  8:28     ` Roberto Sassu

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=10660aa25fd9d868a391a1c092fe8b33@oss.cyber.gouv.fr \
    --to=jeremy.jean@oss.cyber.gouv.fr \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=eric.snowberg@oracle.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=roberto.sassu@huawei.com \
    --cc=roberto.sassu@huaweicloud.com \
    --cc=stable@vger.kernel.org \
    --cc=zohar@linux.ibm.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®