From bfc1d9724c78aa7570dbeb17207a21089f2d1b1a Mon Sep 17 00:00:00 2001 From: Hengyu Liang Date: Fri, 23 Oct 2026 14:13:00 -0400 Subject: [PATCH] fs/proc/task_mmu: return -ENOTTY for unknown pagemap ioctls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 52526ca7fdb9 ("fs/proc/task_mmu: implement IOCTL to get and optionally clear info about PTEs") made do_pagemap_cmd() the ioctl handler of /proc//pagemap. However, do_pagemap_cmd() returns -EINVAL for every command other than PAGEMAP_SCAN. Before that commit, pagemap had no ioctl handler, and the VFS returned -ENOTTY for these commands. As of now, they fail with EINVAL, so tcgetattr() and isatty() on pagemap report EINVAL instead of ENOTTY. The issue can be reproduced with a simple C program: #include #include #include int main(void) { struct termios t; int fd = open("/proc/self/pagemap", O_RDONLY); if (tcgetattr(fd, &t) < 0) perror("tcgetattr"); return 0; } Before that commit, the result is: tcgetattr: Inappropriate ioctl for device After that commit, the result is: tcgetattr: Invalid argument This patch will return -ENOIOCTLCMD for unknown commands, as procfs_procmap_ioctl() in the same file does, so that the VFS turns it into -ENOTTY. Link: https://lore.kernel.org/20261023181300.3366487-1-hengyul@cs.unc.edu Fixes: 52526ca7fdb9 ("fs/proc/task_mmu: implement IOCTL to get and optionally clear info about PTEs") Signed-off-by: Hengyu Liang Signed-off-by: Andrew Morton Acked-by: David Hildenbrand (Arm) Reviewed-by: Pedro Falcato Reviewed-by: Lorenzo Stoakes (ARM) Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Jann Horn Cc: Muhammad Usama Anjum Cc: Andrei Vagin Cc: Michał Mirosław Cc: Arnd Bergmann Cc: --- fs/proc/task_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 7452b695fdae..f68673a91756 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -3201,7 +3201,7 @@ static long do_pagemap_cmd(struct file *file, unsigned int cmd, return do_pagemap_scan(mm, arg); default: - return -EINVAL; + return -ENOIOCTLCMD; } }