{"id":2227061,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2227061/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260423055915.695024-1-youling.tang@linux.dev/","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/1.1/projects/12/?format=json","name":"Linux CIFS Client","link_name":"linux-cifs-client","list_id":"linux-cifs.vger.kernel.org","list_email":"linux-cifs@vger.kernel.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260423055915.695024-1-youling.tang@linux.dev>","date":"2026-04-23T05:59:15","name":"smb/client: fix unaligned reads in wsl_to_fattr()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6e1372014e3b1c5e9ca7709c429b0cc20d59ca03","submitter":{"id":88922,"url":"http://patchwork.ozlabs.org/api/1.1/people/88922/?format=json","name":"Youling Tang","email":"youling.tang@linux.dev"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260423055915.695024-1-youling.tang@linux.dev/mbox/","series":[{"id":501148,"url":"http://patchwork.ozlabs.org/api/1.1/series/501148/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=501148","date":"2026-04-23T05:59:15","name":"smb/client: fix unaligned reads in wsl_to_fattr()","version":1,"mbox":"http://patchwork.ozlabs.org/series/501148/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2227061/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2227061/checks/","tags":{},"headers":{"Return-Path":"\n <linux-cifs+bounces-11038-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-cifs@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256\n header.s=key1 header.b=YoFohIOE;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-cifs+bounces-11038-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev\n header.b=\"YoFohIOE\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=91.218.175.184","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.dev","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=linux.dev"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g1QVS3L3Lz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 16:02:40 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id ADCC63027134\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 06:00:37 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 3B6D338550C;\n\tThu, 23 Apr 2026 06:00:37 +0000 (UTC)","from out-184.mta0.migadu.com (out-184.mta0.migadu.com\n [91.218.175.184])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 729452D3ED2\n\tfor <linux-cifs@vger.kernel.org>; Thu, 23 Apr 2026 06:00:34 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776924037; cv=none;\n b=AffZcG9wbCVN0wokGvxd4VgQee8WQXGO5j+imWnD2KlM2XpV6IN/jV3MevPWVOrbrWvHAKRsfir4mXxYP41NGo2XJIeqoGTn/2Z/6Pr5gE0/W88hBesP9Ko8inol39Kl4uQI4SFaNblQFYHqNfuSLLseDjSWhhwejPTL22yhQUM=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776924037; c=relaxed/simple;\n\tbh=Y7S0I53Mg4DYEFQeNIyERr6A6rh3rgmI4+Ci2lA9AwU=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=TdZrGaMEAPmJyFRllua62h75WQEgl8c48rF+KlA9gdwOxbDPtu2nlfxOlCRm/hekxi07cz9uq+opKO7aoQWDJe19HlnSw/OnzJ8U8j2jEHj082GHRgGJ6m6Lgosd7WmQO+pgobE3E0nPSvBYqBHLEwi6oFgNvuyrDAbjtlUO2tA=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.dev;\n spf=pass smtp.mailfrom=linux.dev;\n dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev\n header.b=YoFohIOE; arc=none smtp.client-ip=91.218.175.184","X-Report-Abuse":"Please report any abuse attempt to abuse@migadu.com and\n include these headers.","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1;\n\tt=1776924032;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\t to:to:cc:cc:mime-version:mime-version:\n\t content-transfer-encoding:content-transfer-encoding;\n\tbh=E4OPrLawMRVjhlxBvyuqSTW8+MhzcHg8GcecN28dJmE=;\n\tb=YoFohIOEB4NFHLZkkPRc9cgVrsKK0/Z7GLcLFTiDXZ+Pu3Ty5D4RVvG+Zvt3zasWsn0F+g\n\tfmCu2MKtAGGSl+c5ntpuXQpo08t+ud//diJ1Dxx8Uq6uGm8jsCwj/0wsjLIqyKGz/SFTJW\n\tmcFkl+MjHvQtXJLtAwFVe0mneXZsO/M=","From":"Youling Tang <youling.tang@linux.dev>","To":"smfrench@gmail.com,\n\tlinkinjeon@kernel.org,\n\tpc@manguebit.org,\n\tronniesahlberg@gmail.com,\n\tsprasad@microsoft.com,\n\ttom@talpey.com,\n\tbharathsm@microsoft.com,\n\tsenozhatsky@chromium.org,\n\tdhowells@redhat.com,\n\tchenxiaosong@chenxiaosong.com,\n\tgregkh@linuxfoundation.org","Cc":"linux-cifs@vger.kernel.org,\n\tyouling.tang@linux.dev,\n\tYouling Tang <tangyouling@kylinos.cn>,\n\tChenXiaoSong <chenxiaosong@kylinos.cn>","Subject":"[PATCH] smb/client: fix unaligned reads in wsl_to_fattr()","Date":"Thu, 23 Apr 2026 13:59:15 +0800","Message-ID":"<20260423055915.695024-1-youling.tang@linux.dev>","Precedence":"bulk","X-Mailing-List":"linux-cifs@vger.kernel.org","List-Id":"<linux-cifs.vger.kernel.org>","List-Subscribe":"<mailto:linux-cifs+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-cifs+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Migadu-Flow":"FLOW_OUT"},"content":"From: Youling Tang <tangyouling@kylinos.cn>\n\nSee MS-FSCC 2.4.16. When multiple FILE_FULL_EA_INFORMATION data elements\nare present in the buffer, each MUST be aligned on a 4-byte boundary.\n\nWhen parsing WSL extended attributes, the code derives the value pointer\nat an offset of 7 (SMB2_WSL_XATTR_NAME_LEN + 1) from ea_data, the value\nsits at an unaligned offset.\n\nWe should use get_unaligned_le32() or get_unaligned_le64() to get\nunaligned values.\n\nLink: https://lore.kernel.org/linux-cifs/77013349-ff89-4593-985d-520d967d2638@chenxiaosong.com/\nSigned-off-by: Youling Tang <tangyouling@kylinos.cn>\nReviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>\n---\n fs/smb/client/reparse.c | 6 +++---\n fs/smb/client/reparse.h | 6 +++---\n fs/smb/client/smb2pdu.h | 1 +\n 3 files changed, 7 insertions(+), 6 deletions(-)","diff":"diff --git a/fs/smb/client/reparse.c b/fs/smb/client/reparse.c\nindex cd1e1eaee67a..eebce954c5ce 100644\n--- a/fs/smb/client/reparse.c\n+++ b/fs/smb/client/reparse.c\n@@ -1160,7 +1160,7 @@ static bool wsl_to_fattr(struct cifs_open_info_data *data,\n \n \t\tname = ea->ea_data;\n \t\tnlen = ea->ea_name_length;\n-\t\tv = (void *)((u8 *)ea->ea_data + ea->ea_name_length + 1);\n+\t\tv = (void *)((u8 *)name + nlen + 1);\n \n \t\tif (!strncmp(name, SMB2_WSL_XATTR_UID, nlen))\n \t\t\tfattr->cf_uid = wsl_make_kuid(cifs_sb, v);\n@@ -1168,9 +1168,9 @@ static bool wsl_to_fattr(struct cifs_open_info_data *data,\n \t\t\tfattr->cf_gid = wsl_make_kgid(cifs_sb, v);\n \t\telse if (!strncmp(name, SMB2_WSL_XATTR_MODE, nlen)) {\n \t\t\t/* File type in reparse point tag and in xattr mode must match. */\n-\t\t\tif (S_DT(fattr->cf_mode) != S_DT(le32_to_cpu(*(__le32 *)v)))\n+\t\t\tif (S_DT(fattr->cf_mode) != S_DT(get_unaligned_le32(v)))\n \t\t\t\treturn false;\n-\t\t\tfattr->cf_mode = (umode_t)le32_to_cpu(*(__le32 *)v);\n+\t\t\tfattr->cf_mode = (umode_t)get_unaligned_le32(v);\n \t\t} else if (!strncmp(name, SMB2_WSL_XATTR_DEV, nlen)) {\n \t\t\tfattr->cf_rdev = reparse_mkdev(v);\n \t\t\thave_xattr_dev = true;\ndiff --git a/fs/smb/client/reparse.h b/fs/smb/client/reparse.h\nindex 0164dc47bdfd..653213a6b7e8 100644\n--- a/fs/smb/client/reparse.h\n+++ b/fs/smb/client/reparse.h\n@@ -23,7 +23,7 @@\n \n static inline dev_t reparse_mkdev(void *ptr)\n {\n-\tu64 v = le64_to_cpu(*(__le64 *)ptr);\n+\tu64 v = get_unaligned_le64(ptr);\n \n \treturn MKDEV(v & 0xffffffff, v >> 32);\n }\n@@ -31,7 +31,7 @@ static inline dev_t reparse_mkdev(void *ptr)\n static inline kuid_t wsl_make_kuid(struct cifs_sb_info *cifs_sb,\n \t\t\t\t   void *ptr)\n {\n-\tu32 uid = le32_to_cpu(*(__le32 *)ptr);\n+\tu32 uid = get_unaligned_le32(ptr);\n \n \tif (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_OVERR_UID)\n \t\treturn cifs_sb->ctx->linux_uid;\n@@ -41,7 +41,7 @@ static inline kuid_t wsl_make_kuid(struct cifs_sb_info *cifs_sb,\n static inline kgid_t wsl_make_kgid(struct cifs_sb_info *cifs_sb,\n \t\t\t\t   void *ptr)\n {\n-\tu32 gid = le32_to_cpu(*(__le32 *)ptr);\n+\tu32 gid = get_unaligned_le32(ptr);\n \n \tif (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_OVERR_GID)\n \t\treturn cifs_sb->ctx->linux_gid;\ndiff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h\nindex 30d70097fe2f..6744606dab6c 100644\n--- a/fs/smb/client/smb2pdu.h\n+++ b/fs/smb/client/smb2pdu.h\n@@ -211,6 +211,7 @@ struct compress_ioctl {\n  *\tBB consider moving to a different header\n  */\n \n+/* See MS-FSCC 2.4.16 */\n struct smb2_file_full_ea_info { /* encoding of response for level 15 */\n \t__le32 next_entry_offset;\n \t__u8   flags;\n","prefixes":[]}