From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 050FB606C909 for ; Wed, 4 Nov 2026 19:56:22 +0000 (UTC) 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 Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4jKbmN5L5qz3dWc; Thu, 05 Nov 2026 06:56:20 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2600:3c0a:e001:78e:0:1991:8:25" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1793822180; cv=none; b=FTjWAiiPLm5fUTOPUmy3x8yH5F+WBGP+NXAN6vRR0zNzLxzzUcuJ+OMW/0jUjbaOqF0UPYVZ+6en9WJh8OUIXqK7r7kTHxEd5ff2EwOVn/yrgjSpmgDwRWq59tn+1L1O645Gx9KlY3oevfBzqx+AwgsNTPan0YQK+VkUZVbc7fZ9h7Jd4SIA4reDtFlDphwXRdFn5vr4W1ELOchJT0x3DkMOMX/934JWZFYczuaY6cA16YTVWVPVG+jQgaKrwfqcSTHbUbgPV8DOWS34cADa1Rfu4AtCQkTDJqbbGdbYrEloCtFRpqLItVQ5oImOypSm323g20mYFDkEHvMlRa73bQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1793822180; c=relaxed/relaxed; bh=dVjHuUMxxd8FqQa8K43Wpa6+M00cK9gADu+rBdGhG5Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ieUDfvvro4ERDadtMKlJNOR1BUD/hF6vNpYpwz7BL0op71rDW0jK9Yw25CVjTl5kySkh+Dh+mMCR/DMqs09CfVuYFfNi0GHuoub/Y/fSJFAxdBn6IcHDH9L5JqySW6yc96HjTUxBWuE/cfeUFWdHhOMyaCIXxGQuSFkZ84IJVo7V4TAUj32/XNjjv1Wgs4vgUlQDdvZwJSi3TSFjZhWQukG9kZYg0FA38JsWKhkcZD0BI6KDhvjQiptXtVq8+7by1oRLyjIu72rhYymdkgPbPLSs8VR+TKSarbXCOIbHb/makPS/pGAmEq9kNp5Sg6PEZzOGZ5esd+frMT7AWoQzJQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=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; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=brauner@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.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; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=brauner@kernel.org; receiver=lists.ozlabs.org) Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4jKbmM6Kjwz3dWb for ; Thu, 05 Nov 2026 06:56:19 +1100 (AEDT) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id EB06643975; Wed, 4 Nov 2026 19:56:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 842BD1F000C1; Wed, 4 Nov 2026 19:56:05 +0000 (UTC) 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== From: Christian Brauner To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Jann Horn , Josef Bacik , Chris Mason , Jeff Layton , NeilBrown , Eric Dumazet , Thomas Gleixner , Al Viro , Jonathan Corbet , Christoph Hellwig , Greg Kroah-Hartman , Joel Granados , Kees Cook , Jan Kara , Jan Kara , 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 , 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)" , Chuck Lever 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 Message-ID: <20261104-work-procfs-fs-v2-26-319e0f9a8aae@kernel.org> In-Reply-To: <20261104-work-procfs-fs-v2-0-319e0f9a8aae@kernel.org> References: <20261104-work-procfs-fs-v2-0-319e0f9a8aae@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , Precedence: list X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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) --- 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 #include #include -#include #include #include #include @@ -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