Article View: linux.kernel.netdev
Article #11314[PATCH RESEND v2 26/30] alloc_tag: let procfs copy the ioctl arguments of /proc/allocinfo
From: Christian Brauner
Date: Wed, 04 Nov 2026 19:56
Date: Wed, 04 Nov 2026 19:56
141 lines
15024 bytes
15024 bytes
Implement ->proc_ioctl_buf() so procfs copies the arguments in before
it pins the entry and back out after unpinning it. The commands encode
their arguments. procfs converts the pointers of 32-bit tasks, so
allocinfo_compat_ioctl() goes away.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
mm/alloc_tag.c | 47 +++++++++++++++++------------------------------
1 file changed, 17 insertions(+), 30 deletions(-)
diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
index 697e44468ebc..b17457c8fb02 100644
--- a/mm/alloc_tag.c
+++ b/mm/alloc_tag.c
@@ -6,7 +6,6 @@
#include <linux/kallsyms.h>
#include <linux/module.h>
#include <linux/mutex.h>
-#include <linux/compat.h>
#include <linux/page_ext.h>
#include <linux/pgalloc_tag.h>
#include <linux/proc_fs.h>
@@ -236,16 +235,14 @@ static void allocinfo_to_params(struct codetag *ct,
* Retrieves the unique content ID representing the current allocation tag module
* layout, allowing userspace to detect if modules were loaded / unloaded.
*/
-static int allocinfo_ioctl_get_content_id(struct seq_file *m, void __user *arg)
+static int allocinfo_ioctl_get_content_id(struct seq_file *m, void *arg)
{
struct allocinfo_content_id params;
codetag_lock_module_list(alloc_tag_cttype);
params.id = codetag_get_content_id(alloc_tag_cttype);
codetag_unlock_module_list(alloc_tag_cttype);
- if (copy_to_user(arg, ¶ms, sizeof(params)))
- return -EFAULT;
-
+ memcpy(arg, ¶ms, sizeof(params));
return 0;
}
@@ -310,7 +307,7 @@ static bool matches_filter(struct codetag *ct, struct allocinfo_filter *filter,
* Seeks the ioctl iterator to the specified 0-indexed tag position, reads its
* profiling data and returns it to userspace.
*/
-static int allocinfo_ioctl_get_at(struct seq_file *m, void __user *arg)
+static int allocinfo_ioctl_get_at(struct seq_file *m, void *arg)
{
struct allocinfo_private *priv;
struct codetag *ct;
@@ -319,8 +316,7 @@ static int allocinfo_ioctl_get_at(struct seq_file *m, void __user *arg)
struct alloc_tag_counters counters;
bool fetched_counters;
- if (copy_from_user(¶ms, arg, sizeof(params)))
- return -EFAULT;
+ memcpy(¶ms, arg, sizeof(params));
if (params.filter.mask & ~ALLOCINFO_FILTER_MASKS)
return -EINVAL;
@@ -375,9 +371,7 @@ static int allocinfo_ioctl_get_at(struct seq_file *m, void __user *arg)
if (!ct)
return -ENOENT;
- if (copy_to_user(arg, ¶ms, sizeof(params)))
- return -EFAULT;
-
+ memcpy(arg, ¶ms, sizeof(params));
return 0;
}
@@ -385,7 +379,7 @@ static int allocinfo_ioctl_get_at(struct seq_file *m, void __user *arg)
* Advances the ioctl iterator to the next allocation tag in the sequence and
* returns its profiling data to userspace.
*/
-static int allocinfo_ioctl_get_next(struct seq_file *m, void __user *arg)
+static int allocinfo_ioctl_get_next(struct seq_file *m, void *arg)
{
struct allocinfo_private *priv;
struct codetag *ct;
@@ -425,10 +419,8 @@ static int allocinfo_ioctl_get_next(struct seq_file *m, void __user *arg)
codetag_unlock_module_list(alloc_tag_cttype);
mutex_unlock(&priv->ioctl_lock);
- if (ret == 0) {
- if (copy_to_user(arg, ¶ms, sizeof(params)))
- return -EFAULT;
- }
+ if (ret == 0)
+ memcpy(arg, ¶ms, sizeof(params));
return ret;
}
@@ -436,10 +428,8 @@ static int allocinfo_ioctl_get_next(struct seq_file *m, void __user *arg)
* Entry point ioctl function for /proc/allocinfo routing requests to fetch the
* layout content ID, seek to a specific tag, or read sequential tags.
*/
-static long allocinfo_ioctl(struct file *file, unsigned int cmd,
- unsigned long __arg)
+static long allocinfo_ioctl(struct file *file, unsigned int cmd, void *arg)
{
- void __user *arg = (void __user *)__arg;
int ret;
switch (cmd) {
@@ -460,23 +450,20 @@ static long allocinfo_ioctl(struct file *file, unsigned int cmd,
return ret;
}
-#ifdef CONFIG_COMPAT
-static long allocinfo_compat_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- return allocinfo_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
-}
-#endif
+static const struct proc_ioctl_arg allocinfo_ioctl_args[] = {
+ PROC_IOCTL_IOC(ALLOCINFO_IOC_CONTENT_ID),
+ PROC_IOCTL_IOC(ALLOCINFO_IOC_GET_AT),
+ PROC_IOCTL_IOC(ALLOCINFO_IOC_GET_NEXT),
+};
static const struct proc_ops allocinfo_proc_ops = {
.proc_seq_ops = &allocinfo_seq_op,
.proc_state_size = sizeof(struct allocinfo_private),
.proc_open = allocinfo_open,
.proc_release = allocinfo_release,
- .proc_ioctl = allocinfo_ioctl,
-#ifdef CONFIG_COMPAT
- .proc_compat_ioctl = allocinfo_compat_ioctl,
-#endif
+ .proc_ioctl_buf = allocinfo_ioctl,
+ .proc_ioctl_args = allocinfo_ioctl_args,
+ .proc_nr_ioctl_args = ARRAY_SIZE(allocinfo_ioctl_args),
};
size_t alloc_tag_top_users(struct codetag_bytes *tags, size_t count, bool can_sleep)
--
2.53.0
Technical Details
Message-ID:
<20261104-work-procfs-fs-v2-26-319e0f9a8aae@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356884-linux-kernel-netdev=dewy.ruReferences:
<20261104-work-procfs-fs-v2-0-319e0f9a8aae@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356884-linux-kernel-netdev=dewy.ru From: brauner@kernel.org (Christian Brauner) Newsgroups: linux.kernel.netdev Subject: [PATCH RESEND v2 26/30] alloc_tag: let procfs copy the ioctl arguments of /proc/allocinfo Date: Wed, 4 Nov 2026 20:56:03 +0100 Organization: Usenet Network Message-ID: <20261104-work-procfs-fs-v2-26-319e0f9a8aae@kernel.org> References: <20261104-work-procfs-fs-v2-0-319e0f9a8aae@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3498719"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:tr0w0ysrVGZVzfsH8+RQijkcHII= sha256:h/NKUXKJ/S2NbbHr3XoQ6XjoMSSb7dH3EtUrDZRF9I0= sha1:ZwIOLBN0kg9B+vYm8jNHygfrR/U= sha256:0BKmN0UXbTI3CFtaqRtrY3BqFYF9yZe7FNQ59B3X6sI= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id EB854112DB1; Thu, 5 Nov 2026 01:06:24 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.301 X-Spam-Status: No, score=-2.301 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vrS-t4iRJJzK; Thu, 5 Nov 2026 01:06:21 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-356884-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 8B175112D7E; Thu, 5 Nov 2026 01:06:13 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 520BB82E68; Wed, 4 Nov 2026 20:56:07 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793822179; b=HZP2Z/b1qfwoSI00F88S/NT/FuT2a/nZdGg6/XOweC9Nh43JkJwVy6FuCZNfp/9HgKBm pi2DruUp4ix1lYNxblU5Kr8Cq43yhIcbhL9jHVPPl4JJhWE7O2osYCFMSdUcxDryD/JOT OiO9oAW5BXm1o7E8RlBRoxiHCk/z3pJ1Fm0VifgA25g+CJO4OyjwjeESK9o/XTtjnM0UV 6eawCuPwxudmK6F3VbP0DZvnV+2Ig6kI0Y9JgJB+1QT9ReOsWCGs0mG4XJty9xsv76t36 NyBySfp9c9Hgy9kOIC2ryaksRLBJw1wkUXDFSZCKAGaHJVyLhg7wFez/LgPMxIjlcOQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793822179; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:In-Reply-To:References:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:X-Mailer:X-Developer-Signature: X-Developer-Key:Content-Transfer-Encoding; bh=dVjHuUMxxd8FqQa8K43Wpa6+M00cK9gADu+rBdGhG5Q=; b=N8MLTfB6xq6l8r+b2zlMaQjmT4U1IxWigGaUfayIhLtSmb1e973SvYzastf/w0e8u4uK P919DtiqXN8Jp8hbCGW4COua85rKZIf+inLZq+Fg9/iK2KqORHGA2Q/DynTExMSiJaVmT IceUQafgAa6qDCIHhMqLP6EQrasrL2+6uPKdW1tc90nqomm2z9pC7Z4DVE8Z/QwPOzYh0 BSbmHyb6Ml2yPKByignzVHFC0ZfpFKRYDHItt/7EVOYKNfF7ToZcoC/axaNu3NEzcFCt/ 2iFfq0HTA7TKQ8KvA/SEG5xcHHyfaG2CGvs7MU7kMq1UcHiYeZsgtdPNiZGSS5zTKTQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WciFxQke; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0A52609C5A8; Wed, 4 Nov 2026 19:56:19 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WciFxQke X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793822178; b=vSHNld2cfNd7P300Y/A0CexWz3yJB5qyBvJDSmND3+RCQSxx/thgx9r8ouuVdrPtcklU WURN7ekhNr5kzims67jvCP/vM4NDzttNFwcfjcRI0Zc1p/I/a2EBSizmxUXDX0MKM71/6 BHL2zRp6WupaCtAo7b3MKUTCOo/ua3jT0Oc/ku3H3zzcIriNfXlXEN8Wr0za3e0iVpC1B I9jWlJjlkHPX6n8q530XGF8D+XkuiD6IQVgKxltIF4Om2Jlr/QDPJunXdaKic0wSl1wPB Y/XMCfgjAqcrHKe/FQfOVROffUcmZ7MBCh5mj5rWCfClAze/LFP5cqq74wX3l+6EnkQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793822178; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: In-Reply-To:References:MIME-Version:Content-Type:X-Mailer: X-Developer-Signature:X-Developer-Key:Content-Transfer-Encoding; bh=dVjHuUMxxd8FqQa8K43Wpa6+M00cK9gADu+rBdGhG5Q=; b=XIOdViPkFGM/xakoa1rdT0vBd4tmkrNvKmPRh1kGLNCwkd3pLOPUKW0Dq/iF/28+zymm rfjr0rOnvKAQqFHTmsQsp429bSIqXrVV9wrwdeH6vpXyLd+b2U/+5CDyZdZ8af2kxgsSG qwTgK/SpvmZXrHSgeIZJe1c/5WcUSsmXZJM+TkCkaPcNrnNLOSk0Z2a6u/kmlyTOnif6W fPJWLAlsaZKT6TVh57HKrMsTbKgnALv4CXo4oy/Pern4nM/09nxx8TWGNEAxDpzeizUNT jSCgpIOdNMAbV+EETsurGZdIZrMzor1BAzWO9nFbcAp3qiILzQZZocGWycrbY7guKPA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WciFxQke; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 315866078941; Wed, 4 Nov 2026 19:56:17 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 842BD1F000C1; Wed, 4 Nov 2026 19:56:05 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793822177; bh=dVjHuUMxxd8FqQa8K43Wpa6+M00cK9gADu+rBdGhG5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WciFxQke7WU+TqGOiLHJFFvz51sxAv/rXDuJ65d7uc/uzhqt05C4NlVN6GEsTUCUu 31fkRA/xip2bhOq8TqDrQhDe5z0BPJYsvkSt1ZtjXi0UWf4TITY4A9UV1Jj74iUycG lDsCZ5Dv6DN9dQs5WHRrbLlWLWWmKs07ZIwnLQxTmPhOa7InPJfbe0D8IVp3OjClGc ZmGH+yeDVq+4v+cg8g4xIPmzrh+E3sC00xuiXzIgXt8btDsGhRR0CoJ8fDZPxoEm+E OBg77f3DkM4ZaSWy1R28T5gZm41vTK6+WYOPbNiJOEt0Tph54u6+2Ht87F0UbPAKoU ENh1KteE9DOew== X-Cc: Linus Torvalds <torvalds@linux-foundation.org>, Jann Horn <jannh@google.com>, Josef Bacik <josef@toxicpanda.com>, Chris Mason <mason@kernel.org>, Jeff Layton <jlayton@kernel.org>, NeilBrown <neil@brown.name>, Eric Dumazet <edumazet@kernel.org>, Thomas Gleixner <tglx@kernel.org>, Al Viro <viro@zeniv.linux.org.uk>, Jonathan Corbet <corbet@lwn.net>, Christoph Hellwig <hch@lst.de>, Greg Kroah-Hartman <gregkh@suse.de>, Joel Granados <joel.granados@kernel.org>, Kees Cook <kees@kernel.org>, Jan Kara <jack@suse.cz>, Jan Kara <jack@suse.com>, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-um@lists.infradead.org, linux-wireless@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, ntfs3@lists.linux.dev, platform-driver-x86@vger.kernel.org, coreteam@netfilter.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org, linux-sound@vger.kernel.org, netfilter-devel@vger.kernel.org, dri-devel@lists.freedesktop.org, ibm-acpi-devel@lists.sourceforge.net, jfs-discussion@lists.sourceforge.net, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cifs@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-mm@kvack.org, linux-sh@vger.kernel.org, linux-usb@vger.kernel.org, samba-technical@lists.samba.org, sparclinux@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-doc@vger.kernel.org, linux-serial@vger.kernel.org, linux-atm-general@lists.sourceforge.net, Takashi Iwai <tiwai@suse.de>, linux-input@vger.kernel.org, linux-raid@vger.kernel.org, linux-ext4@vger.kernel.org, linux-modules@vger.kernel.org, linux-debuggers@vger.kernel.org, "Christian Brauner (Amutable)" <brauner@kernel.org>, Chuck Lever <cel@kernel.org> X-In-Reply-To: <20261104-work-procfs-fs-v2-0-319e0f9a8aae@kernel.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5002; i=brauner@kernel.org; h=from:subject:message-id; bh=qvFStIPYOo+XQCz7NGrfedfPC5AiqcBr63oE+4d+7KE=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWS97vE65vl9w02l+nm/3k8td487Mlf95K8LO9Yw6x35z bF1Qqund0cpC4MYF4OsmCKLQ7tJuNxynorNRpkaMHNYmUCGMHBxCsBE6roZ/sfzLc1cc19g8UpG p9ScMA2ZG2mxxusMN/5mfHVJ4JFJ0UmGvxIPbppe0fTgXiEh//pB3cedQhve/fx4peeqfYB+jj/ rQzYA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624