[PATCH 03/15] ksmbd: match SMB2 EA names by exact length
Ze Tan <[email protected]> Fri, 24 Jul 2026 18:39:57 +0800
| Newsgroups | org.kernel.vger.linux-cifs |
|---|---|
| Message-ID | <44793550a615a2fe2494c562317b7d335a7c4646.1784888897.git.tanze@kylinos.cn> |
smb2_get_ea() uses the requested name length as the comparison bound. That also matches a longer EA whose name starts with the requested bytes. Compare equal-length names so a request for "foo" cannot return the value of "foobar". Signed-off-by: Ze Tan <[email protected]> --- fs/smb/server/smb2pdu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index baa6e8f0eba4..2131625dbc2d 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -5240,7 +5240,8 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp, name_len = visible_name_len; if (req->InputBufferLength && - strncmp(ea_name, ea_req->name, ea_req->EaNameLength)) + (name_len != ea_req->EaNameLength || + memcmp(ea_name, ea_req->name, name_len))) continue; ptr = eainfo->name + name_len + 1; -- 2.43.0