Article View: linux.kernel.netdev
Article #9757[PATCH RFC 24/27] alloc_tag: let procfs copy the ioctl arguments of /proc/allocinfo
From: Christian Brauner
Date: Mon, 02 Nov 2026 15:07
Date: Mon, 02 Nov 2026 15:07
141 lines
15005 bytes
15005 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 788c9d7f7151..1734705e2990 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>
@@ -235,16 +234,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;
}
@@ -309,7 +306,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;
@@ -318,8 +315,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;
@@ -374,9 +370,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;
}
@@ -384,7 +378,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;
@@ -424,10 +418,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;
}
@@ -435,10 +427,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) {
@@ -459,23 +449,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:
<20261102-work-procfs-fs-v1-24-d09a996317b3@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-354883-linux-kernel-netdev=dewy.ruReferences:
<20261102-work-procfs-fs-v1-0-d09a996317b3@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-354883-linux-kernel-netdev=dewy.ru From: brauner@kernel.org (Christian Brauner) Newsgroups: linux.kernel.netdev Subject: [PATCH RFC 24/27] alloc_tag: let procfs copy the ioctl arguments of /proc/allocinfo Date: Mon, 02 Nov 2026 16:07:34 +0100 Organization: Usenet Network Message-ID: <20261102-work-procfs-fs-v1-24-d09a996317b3@kernel.org> References: <20261102-work-procfs-fs-v1-0-d09a996317b3@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="2967832"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:TjqT8y0VXszz7js9OPcWmuYbMuI= sha256:4LfzgCbJ/7Gdq13VmSlPJVN5p1NbGKrAHrjvlzw2BgU= sha1:g6g9JhD8LUUTv6Pd7FlJaaW+sYA= sha256:ea+sNRcYhB2PUamYuBVi3Tf/PNHUVeCwooQxeSReTjQ= 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 4468A112592; Mon, 2 Nov 2026 19:27:49 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.4 X-Spam-Status: No, score=-2.4 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.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, URIBL_BLOCKED=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 oQeWs9qrRMRH; Mon, 2 Nov 2026 19:27:44 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-354883-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 8936B112591; Mon, 2 Nov 2026 19:27:35 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 1BAEF6021A5; Mon, 2 Nov 2026 16:22:27 +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=1793633338; b=pdtfUeU1Rqk4EGbp4dNl8QyR6uFcd6GW/aEhEJXi1XeJqlljuZSGY7H4KU9WG95bzsBr aqfN25yoZCy+zqMdgF5qhpZ07QFp0sJBfGw533YpjrUv0qvC5jBpQUZWB9EHKnKkDahU2 zCmtnjfFlP5KGDhAq0CXnANTV6HvaFeu8fsTgARFdRUxUs1KUIn7AbFHfVmNXYYYi/sd4 dfz9tHsoRX6HsWwuzHdDluzFqQ64dDs9No4ifh1iEcQJPWTpsNYRMwnuzsTNvNKHaHNLD 08oxhtoBO94Ev0QlRG9QenWLRHGrfRO2e6ixr+5QCt8m6/kTAMLxhhYiCtza0t/egYw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793633338; h=X-Original-To:Received:Received:DKIM-Signature:From:Date:Subject: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=toX2CmHD2NzUUtPxn+B9S++PSadbiUkEaQUUA5VZdL0=; b=ZiqOe1hd6qbZLMGcpE6pJu1wLYYKKt54qi5ovwUEzAmNcX1AaCGsQatbDjvyZ4QrfcTo KO7hu/JXE9zgkav6rDNzg1T0DG1p9obj8Abfv5qPHV1Kd7E0pR+zA0VMNdRAfuUxQynoS 95haP4MneWTAdz5I1zKEtAkNjLqLvIOM6ZiHa1cadC2Gmvvj/ZhtLbTLr5xeUtrBlrZgF stUNKh+qE6bTZHord3R5itnpKIBQ5hZKyj+jN1oFr86gO207nHOfDBwRnC1W4P1/OZRIk dSc5X9Vgl5dQTiMfSZqupAcO774XydFwqwDinprUPVohfhAZq/0b2xFFs4wpKIjtFwQ== 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=Qg2kQwEJ; 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 E9CA9609D12A; Mon, 2 Nov 2026 15:28:57 +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=Qg2kQwEJ 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=1793633322; b=NfWj1ExidirlGCiBSFf84E9aaGrYb6qoCFu23N68LQyUxJg8qvOgWj+/lUEsvV77Rswu 6WXjJiUkWQNwRqOnndhYWNvI9n8FTT6PiQYPmS2fCh6MURbJmRkeFGS/czzw1gvCZ2866 NKUEZO38kQFAuT6EdWDv63VE/8fo6M4XOqic/UAnSv6BxWFLPM6nl7SAPcMJH0hbDTDU9 KuK+czJkWZx99NLpE/ECX53s9O3bqNNBb3hr1Yt1gTTxRfKosdsbfjX33Gk786uFT3fAk hpeJEZK8isamJT90k967LJw1QmVEuMv0LcY3U+L5rU99daKNIB92xf4tpYOWlVLO26A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793633322; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=toX2CmHD2NzUUtPxn+B9S++PSadbiUkEaQUUA5VZdL0=; b=oGN31SWxr1Qb7S6cTZjJe8HdVLoBq4jKQwlRcBt+8Xw4FAGp+Gjoa9d2NSSXsK3Q72Ad fuTgYBNTrnz5eL+Rc92TxWe2kZhk/+9PeN3xQLr88QqkIezQ4O5RTZYdXk8u0j6t7ZTgM 6CicgxsMub1zK9cOWlEucrDtoV/r/C/yLEiEEb8rGzfAnv5zhH0+FHK+DILZ7eINYxlob lakpjN2TYsgJcehPl76HhwlXrmQ9zT7wUH9RmcNyEINkarhNdodYnKb8i3vgYsP4saJXq 71Hd0Rnmx97BE/buxQwDHDtSoSSMXycDf3STA/07+yzC8GDrl3oC795pPghq8cctt/A== 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=Qg2kQwEJ; 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 B5BA460850A9; Mon, 2 Nov 2026 15:28:41 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DD6D1F00A16; Mon, 2 Nov 2026 15:28:22 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793633321; bh=toX2CmHD2NzUUtPxn+B9S++PSadbiUkEaQUUA5VZdL0=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Qg2kQwEJzBBud2YUJ5gCy+8AwyrbfP0wjUoQmOVfGfnhhid1zR1YXGmw9lG63Cq5H PnFT4z0kjd/vnLavLzmjV+cc1mZrSe7esUryOwNy8DlGgP0iR20nKduRu/kIzHHsrQ gjv4+UrQipmVe0//KR6hmG2uBXfpQI7HpEbsZeXm0dGsbxjJywIm3X1O6YZKcRgI8R fyDrbQhVDukMWPxLMGTE6xRuHe8cYGAyiRM5fIGe9b1AtfTA3oMoQ+m+woQvg5dZTm aWP+sNADJwOPXcf78LIFpFrYKl//E/ARw2Rvrj2196gNLVEEXBWWB+0PsauKpZ5TfT cXvrUnM7DQOgA== 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-In-Reply-To: <20261102-work-procfs-fs-v1-0-d09a996317b3@kernel.org> 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-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=Df+mpuPO24WuA65Z3R+CqgWoIsjjCuc3kLgbPQbmkBc=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWS9WG7M+GnFOi/L79sZ/3nKHOl8OmlN0p/Mgq2y3fUHM zOWcK5f3VHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAnCT+RgZjmkkrJpwrImlTOP+ 7JSdp5pyDvu1zYz6ujT/tMhRJ7dTsYwMu1c1SXtoHp9uOvfWFiYRtj/J6WeC+vuWLjBUsk9nYHL iBgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624