lkml.org 
[lkml]   [2019]   [Aug]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] tracefs: avoid crash when open callback is not set
Some tracefs files, e.g. tracing/events/syscalls/*/id do not define
"open" file operation. Yet commit 757ff7244358 ("tracefs: Restrict
tracefs when the kernel is locked down") introduces "open" proxy which
unconditionally calls original open callback, which causes kernel crash
when the callback is 0.

Fix that by simply returning 0, if open callback is not set.

Fixes: 757ff7244358 ("tracefs: Restrict tracefs when the kernel is locked down")
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
---
fs/tracefs/inode.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 12a325fb4cbd..77407632c916 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -43,7 +43,9 @@ static int default_open_file(struct inode *inode, struct file *filp)
return ret;

real_fops = dentry->d_fsdata;
- return real_fops->open(inode, filp);
+ if (real_fops->open)
+ return real_fops->open(inode, filp);
+ return 0;
}

static ssize_t default_read_file(struct file *file, char __user *buf,
--
⣿⣿⣿⣿⢋⡀⣀⠹⣿⣿⣿⣿
⣿⣿⣿⣿⠠⣶⡦⠀⣿⣿⣿⣿
⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿
⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿
⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿
⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
\
 
 \ /
  Last update: 2019-08-13 16:59    [W:0.065 / U:3.884 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site