Skip to content

Commit afb37ef

Browse files
author
Mete Durlu
committed
s390/hypfs: Avoid unnecessary ioctl registration in debugfs
JIRA: https://issues.redhat.com/browse/RHEL-111204 Conflicts: no_llseek is removed on upstream but still present on RHEL, add it in to accomodate changes. commit fec7bdf Author: Peter Oberparleiter <oberpar@linux.ibm.com> Date: Thu Aug 21 14:35:40 2025 +0200 s390/hypfs: Avoid unnecessary ioctl registration in debugfs Currently, hypfs registers ioctl callbacks for all debugfs files, despite only one file requiring them. This leads to unintended exposure of unused interfaces to user space and can trigger side effects such as restricted access when kernel lockdown is enabled. Restrict ioctl registration to only those files that implement ioctl functionality to avoid interface clutter and unnecessary access restrictions. Tested-by: Mete Durlu <meted@linux.ibm.com> Reviewed-by: Vasily Gorbik <gor@linux.ibm.com> Fixes: 5496197 ("debugfs: Restrict debugfs when the kernel is locked down") Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Mete Durlu <mdurlu@redhat.com>
1 parent f537aee commit afb37ef

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

arch/s390/hypfs/hypfs_dbfs.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,29 @@ static long dbfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
6464
long rc;
6565

6666
mutex_lock(&df->lock);
67-
if (df->unlocked_ioctl)
68-
rc = df->unlocked_ioctl(file, cmd, arg);
69-
else
70-
rc = -ENOTTY;
67+
rc = df->unlocked_ioctl(file, cmd, arg);
7168
mutex_unlock(&df->lock);
7269
return rc;
7370
}
7471

75-
static const struct file_operations dbfs_ops = {
72+
static const struct file_operations dbfs_ops_ioctl = {
7673
.read = dbfs_read,
7774
.llseek = no_llseek,
7875
.unlocked_ioctl = dbfs_ioctl,
7976
};
8077

78+
static const struct file_operations dbfs_ops = {
79+
.read = dbfs_read,
80+
.llseek = no_llseek,
81+
};
82+
8183
void hypfs_dbfs_create_file(struct hypfs_dbfs_file *df)
8284
{
83-
df->dentry = debugfs_create_file(df->name, 0400, dbfs_dir, df,
84-
&dbfs_ops);
85+
const struct file_operations *fops = &dbfs_ops;
86+
87+
if (df->unlocked_ioctl)
88+
fops = &dbfs_ops_ioctl;
89+
df->dentry = debugfs_create_file(df->name, 0400, dbfs_dir, df, fops);
8590
mutex_init(&df->lock);
8691
}
8792

0 commit comments

Comments
 (0)