From nobody Sun May 24 21:41:12 2026 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25C673BCD2C for ; Thu, 21 May 2026 11:15:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779362124; cv=none; b=Dwh3Dapxd1ovsBT0s1Oi1eK/kIwjT1+dvseWlbj1DVh8cQnq50YKGWWTH3tU91ZiKVXKBWCUj7n3aLwCk6gZYz/RKByeSyj3oCWJKajbdR/rVniUxbMPyzfDQVI489LC/nl1eC4M399QifpbYJR1k0YuNXuEpQ1ymA8kER8FDa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779362124; c=relaxed/simple; bh=P6IUgd+ambj76QcrIw1CcLj6uqCg4f+3nNonL0CfapI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=i+IP/AnRP07gceOTMpkrdV+t54VcxNM9j3+FwjxWTJ9WsDRbuNqOoZruTis2gTwSP/rFqP7tNmaz8JhSLsooXWYN00aCWnGduiN48B+9I2UHQSZlOHcw/JhmtlXAjlcUYyttReiA3Uc0P3bTj8BHU3DB0zvMB7+KuosPQEupIkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Fdm7HJ1r; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Fdm7HJ1r" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5a4002b1183so472301e87.3 for ; Thu, 21 May 2026 04:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1779362119; x=1779966919; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tZ7P+5t3jLRBE3lOcArAKCuHzvSZ9KoaqAb+k1VS674=; b=Fdm7HJ1rqRl4apoQpSNuee+IfsIr5L65zuLi5ktLPiIVSkU+AwlAaAVUgQyIEOmvsg rzwnmTfUDsrVvONMetBWzLgy7bKhYI8QZ58hvAz91IMJU0dAxpgWdFAixl0z2N9itRDb OzLIxqPgoXWAY2zeJV/UOSGfWlh08LxpigriRdsuV2P94zwv3X2l41Ha0fUo6mKnqqYd wbnyHrqO+yqZSLZocig1/MxpiTZWnLLMV6WI/8eKfYRXdxMrzZo8RQ1SEjuwDUHpOl5h D3M39uokthoaQTigiaU95U+rq1ndpIqfy8CAGbXP4iVxPwA3c9qOkoTG2mVCqztqJoAH vBZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779362119; x=1779966919; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tZ7P+5t3jLRBE3lOcArAKCuHzvSZ9KoaqAb+k1VS674=; b=had+6hfjLkjzgSiXqCYOfIySJ/a3UYt+tE5CGX58iDYwZdUYNpVrXPP4sEkA2Zu2ko C06LqUo2cIWlhcNuIlayigaMHoubIGcyKsBYoyAh3p21k4OHiT8B1hWBU47EJ6ftpF9T 6iTZmvcJFaHmq2iuq4KjDHVNnlAzXT01YUOLhdd7rczzBXh9YtU2o6/emLLbR6RSksUx Z6pr//mUV9zG27UgvRedbg5ecKGSJokt8CQc4/zdmSAgGUZsOYXxVpHI1ieSMuEKJVBD UmkrL14h5L533XuaQDu/Ilmb7bdOYQ6ZzWW+aoCH61btnJLooaDCjIfiGoizYDUfIZGJ XzLg== X-Forwarded-Encrypted: i=1; AFNElJ/uAYI9LtTeUhjwacgz0n1TEDXj0uKsPfX5va1z0HyOMvjyGrp6XzVTJO6QLMF/HUKlT+5kwLxMJpg6pBA=@vger.kernel.org X-Gm-Message-State: AOJu0YxE9+v8zBMk/y97C5avD372Rgvb3RkHk2/kvFG1PLzr/gbTWcAI H1SXMTYS8shxyLOJCvMk4GUDZkJcTxqSdGDAo8wryefpcFxaUMa5HPlOZBgkyvH1nXU= X-Gm-Gg: Acq92OE95ZlWZOkTe5Oz8Gl47eYmT19s/luz/FGjJlKqlM8z4EzPytDkyuXeMDXMeWl waKagRIWa6fOd0J86dQYdKlIUZ2B5uwDeU3oI2cN4isZBJnUI04rwaNpS9DzR7tklmTZVP+C7xk XCUftMTqsJf7KIwe80bZ8a9fhT9KQjEmhq62W5DWOk7khck485QScAGXrluHp6zkV9P5Gt3al/O h2duv3EN7MlVSAf03pInUHBUOnAB3LpanmDDlunPSAoNzlfU7HQhkbQjtDXjaAhGng2FZ7lEtsT Eew7xlKk7RdtFxHerZ6aBCxaBLm6+HyKdlhSteyOZ9RwMRi+lWUx6sZnc/jNelXZnWf+NHqydvG Y/Tr4QI5SueGKnnkkw//90ZwRqOn53BHjUZ68JskgSoIFuaKhLq15VC3jxh6eqzHxFvMbjBoRQb UHUHExdv0QEwz0+WdPjzM7dOnK7aYMTH26wS4vn54+A5HGaOKwYWYcow6ZUFikzpH2Y5n5+J+T0 6+C X-Received: by 2002:a05:6512:39cf:b0:5a4:a4c:6595 with SMTP id 2adb3069b0e04-5aa2ba9076cmr513290e87.4.1779362118542; Thu, 21 May 2026 04:15:18 -0700 (PDT) Received: from thyme.. (91-159-24-186.elisa-laajakaista.fi. [91.159.24.186]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5aa2f14f34fsm163861e87.74.2026.05.21.04.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 04:15:18 -0700 (PDT) From: Vladimir Zapolskiy To: Vlastimil Babka , Harry Yoo , Andrew Morton , Christoph Lameter , Hao Li Cc: David Rientjes , Roman Gushchin , Hugh Dickins , Vladimir Zapolskiy , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] mm/slab: fix probable issue of dentries registration under /sys/kernel/slab Date: Thu, 21 May 2026 14:15:16 +0300 Message-ID: <20260521111516.1903707-1-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" L2TP/IP and L2TP/IPv6 protocol names contain a slash symbol, however these names are blindly used as symlinks to slab cache objects registered under /sys/kernel/slab. This kind of symlink creation is successful, but its dentry is obviously broken, as well it breaks the access to the list of /sys/kernel/slab dentries. Likely L2TP protocol renames cannot be done, since the defined protocol names are exposed over /proc/net/protocols for years, but the symlink names can be renamed, because they are yet to be properly created, and this should be eventually done by this change. The problem manifests itself, if CONFIG_L2TP_IP build symbol is selected. Fixes: 81819f0fc8285 ("SLUB core") Signed-off-by: Vladimir Zapolskiy --- Changes from v2 to v1: * added slash symbol replacement to __kmem_cache_create_args() as well, many thanks to Hao and Harry for review. Link to v1: * https://lore.kernel.org/linux-mm/8a80496b-1568-4a0b-a878-836c27d19ad5@ker= nel.org/ mm/slab_common.c | 23 +++++++++++++++++++---- mm/slub.c | 23 ++++++++++++++++++++++- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index d5a70a831a2a..b9930521496d 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -366,16 +366,31 @@ struct kmem_cache *__kmem_cache_create_args(const cha= r *name, object_size - args->usersize < args->useroffset)) args->usersize =3D args->useroffset =3D 0; =20 - s =3D __kmem_cache_alias(name, object_size, flags, args); - if (s) - goto out_unlock; - cache_name =3D kstrdup_const(name, GFP_KERNEL); if (!cache_name) { err =3D -ENOMEM; goto out_unlock; } =20 + if (strchr(cache_name, '/')) { + char *n; + + n =3D kstrdup(cache_name, GFP_KERNEL); + kfree_const(cache_name); + if (!n) { + err =3D -ENOMEM; + goto out_unlock; + } + + cache_name =3D strreplace(n, '/', '_'); + } + + s =3D __kmem_cache_alias(cache_name, object_size, flags, args); + if (s) { + kfree_const(cache_name); + goto out_unlock; + } + args->align =3D calculate_alignment(flags, args->align, object_size); s =3D create_cache(cache_name, object_size, args, flags); if (IS_ERR(s)) { diff --git a/mm/slub.c b/mm/slub.c index 0baa906f39ab..843bed864a7f 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -9634,6 +9634,7 @@ static struct saved_alias *alias_list; int sysfs_slab_alias(struct kmem_cache *s, const char *name) { struct saved_alias *al; + const char *al_name; =20 if (slab_state =3D=3D FULL) { /* @@ -9652,8 +9653,27 @@ int sysfs_slab_alias(struct kmem_cache *s, const cha= r *name) if (!al) return -ENOMEM; =20 + al_name =3D kstrdup_const(name, GFP_KERNEL); + if (!al_name) { + kfree(al); + return -ENOMEM; + } + + if (strchr(al_name, '/')) { + char *n; + + n =3D kstrdup(al_name, GFP_KERNEL); + kfree_const(al_name); + if (!n) { + kfree(al); + return -ENOMEM; + } + + al_name =3D strreplace(n, '/', '_'); + } + al->s =3D s; - al->name =3D name; + al->name =3D al_name; al->next =3D alias_list; alias_list =3D al; kmsan_unpoison_memory(al, sizeof(*al)); @@ -9691,6 +9711,7 @@ static int __init slab_sysfs_init(void) if (err) pr_err("SLUB: Unable to add boot slab alias %s to sysfs\n", al->name); + kfree_const(al->name); kfree(al); } =20 --=20 2.49.0