mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qing Zhang <diasyzhangqing@gmail.com>
To: Tyler Hicks <code@tyhicks.com>
Cc: ecryptfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+2e8c4ecc07730b29ae27@syzkaller.appspotmail.com,
	Roberto Sassu <roberto.sassu@polito.it>,
	diasyzhang@tencent.com
Subject: [PATCH] ecryptfs: validate auth token payload length before use
Date: Fri,  6 Nov 2026 02:04:02 +0800	[thread overview]
Message-ID: <20261105180403.675338-1-diasyzhangqing@gmail.com> (raw)
In-Reply-To: <6aec66fb.059f5055.2712e4.0000.GAE@google.com>

From: Qing Zhang <diasyzhang@tencent.com>

eCryptfs treats user and encrypted key payloads as struct
ecryptfs_auth_tok without checking their length. Short payloads with
valid version and token type fields can pass verification and cause
out-of-bounds reads during file or filename encryption.

Reject undersized payloads in both payload accessors with -EINVAL
before any authentication token fields are accessed.

Fixes: 237fead61998 ("[PATCH] ecryptfs: fs/Makefile and fs/Kconfig")
Fixes: 1252cc3b232e ("eCryptfs: added support for the encrypted key type")
Reported-by: syzbot+2e8c4ecc07730b29ae27@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=2e8c4ecc07730b29ae27
Signed-off-by: Qing Zhang <diasyzhang@tencent.com>
---

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
 fs/ecryptfs/ecryptfs_kernel.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 58165928ed1e..4315c18ba1cd 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -88,6 +88,9 @@ ecryptfs_get_encrypted_key_payload_data(struct key *key)
 	if (!payload)
 		return ERR_PTR(-EKEYREVOKED);
 
+	if (payload->payload_datalen < sizeof(struct ecryptfs_auth_tok))
+		return ERR_PTR(-EINVAL);
+
 	return (struct ecryptfs_auth_tok *)payload->payload_data;
 }
 
@@ -124,6 +127,9 @@ ecryptfs_get_key_payload_data(struct key *key)
 	if (!ukp)
 		return ERR_PTR(-EKEYREVOKED);
 
+	if (ukp->datalen < sizeof(struct ecryptfs_auth_tok))
+		return ERR_PTR(-EINVAL);
+
 	return (struct ecryptfs_auth_tok *)ukp->data;
 }
 
-- 
2.43.7


  reply	other threads:[~2026-11-05 18:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 11:22 [syzbot] [ecryptfs?] KASAN: slab-out-of-bounds Read in write_tag_3_packet syzbot
2026-11-05 18:04 ` Qing Zhang [this message]
2026-11-05 18:24   ` syzbot

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=20261105180403.675338-1-diasyzhangqing@gmail.com \
    --to=diasyzhangqing@gmail.com \
    --cc=code@tyhicks.com \
    --cc=diasyzhang@tencent.com \
    --cc=ecryptfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roberto.sassu@polito.it \
    --cc=syzbot+2e8c4ecc07730b29ae27@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®