From: Deepanshu Kartikey <kartikey406@gmail.com>
To: code@tyhicks.com
Cc: blum@kernel.org, chenyichong@uniontech.com,
a.velichayshiy@ispras.ru, kees@kernel.org, liubaolin@kylinos.cn,
eilaimemedsnaimel@gmail.com, ebiggers@kernel.org,
roberto.sassu@polito.it, ecryptfs@vger.kernel.org,
linux-kernel@vger.kernel.org,
Deepanshu Kartikey <kartikey406@gmail.com>,
syzbot+e4391e0d6e7c89b8c84e@syzkaller.appspotmail.com
Subject: [PATCH] ecryptfs: validate auth_tok key payload size before use
Date: Tue, 22 Sep 2026 10:14:00 +0530 [thread overview]
Message-ID: <20260922044400.14078-1-kartikey406@gmail.com> (raw)
ecryptfs_verify_auth_tok_from_key() casts a "user" type key's raw
payload directly to struct ecryptfs_auth_tok without checking that
the key actually holds enough data to back that struct. Since a
user-type key's payload length is fully attacker-controlled via
add_key(2), an undersized key whose description matches
global_default_fnek_sig lets later code (e.g.
ecryptfs_write_tag_70_packet()) read fields such as
session_key_encryption_key/session_key_encryption_key_bytes past the
end of the actual allocation, causing a slab-out-of-bounds read.
Reject the key up front if its datalen is smaller than
sizeof(struct ecryptfs_auth_tok).
Fixes: 0e1fc5ef470cc ("eCryptfs: verify authentication tokens before their use")
Reported-by: syzbot+e4391e0d6e7c89b8c84e@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e4391e0d6e7c89b8c84e
Tested-by: syzbot+e4391e0d6e7c89b8c84e@syzkaller.appspotmail.com
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
fs/ecryptfs/keystore.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 51651314b7a6..81768a0e43b1 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -462,6 +461,14 @@ ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key,
goto out;
}
+ if (auth_tok_key->datalen < sizeof(struct ecryptfs_auth_tok)) {
+ printk(KERN_ERR "Auth tok key payload too small (have %d bytes; need %zu)\n",
+ auth_tok_key->datalen, sizeof(struct ecryptfs_auth_tok));
+ rc = -EINVAL;
+ *auth_tok = NULL;
+ goto out;
+ }
+
if (ecryptfs_verify_version((*auth_tok)->version)) {
printk(KERN_ERR "Data structure version mismatch. Userspace "
"tools must match eCryptfs kernel module with major "
--
2.43.0
reply other threads:[~2026-09-22 4:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260922044400.14078-1-kartikey406@gmail.com \
--to=kartikey406@gmail.com \
--cc=a.velichayshiy@ispras.ru \
--cc=blum@kernel.org \
--cc=chenyichong@uniontech.com \
--cc=code@tyhicks.com \
--cc=ebiggers@kernel.org \
--cc=ecryptfs@vger.kernel.org \
--cc=eilaimemedsnaimel@gmail.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liubaolin@kylinos.cn \
--cc=roberto.sassu@polito.it \
--cc=syzbot+e4391e0d6e7c89b8c84e@syzkaller.appspotmail.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®