public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
From: Vasily Gorbik <gor@linux•ibm.com>
To: Stephen Rothwell <sfr@canb•auug.org.au>,
	Matthew Garrett <matthewgarrett@google•com>,
	James Morris <jmorris@namei•org>,
	Steven Rostedt <rostedt@goodmis•org>
Cc: Linux Next Mailing List <linux-next@vger•kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger•kernel.org>
Subject: [PATCH] tracefs: avoid crash when open callback is not set
Date: Tue, 13 Aug 2019 16:58:48 +0200	[thread overview]
Message-ID: <patch.git-ff7e3ec62cff.your-ad-here.call-01565708219-ext-8038@work.hours> (raw)
In-Reply-To: <your-ad-here.call-01565708256-ext-1951@work.hours>

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,
-- 
⣿⣿⣿⣿⢋⡀⣀⠹⣿⣿⣿⣿
⣿⣿⣿⣿⠠⣶⡦⠀⣿⣿⣿⣿
⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿
⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿
⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿
⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿


      reply	other threads:[~2019-08-13 14:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13  9:19 linux-next: Tree for Aug 13 Stephen Rothwell
2019-08-13 12:41 ` Vasily Gorbik
2019-08-13 14:56   ` Steven Rostedt
2019-08-13 15:10     ` Vasily Gorbik
2019-08-14  6:14     ` Marek Szyprowski
2019-08-14  7:35       ` Stephen Rothwell
2019-08-13 14:57   ` Vasily Gorbik
2019-08-13 14:58     ` Vasily Gorbik [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=patch.git-ff7e3ec62cff.your-ad-here.call-01565708219-ext-8038@work.hours \
    --to=gor@linux$(echo .)ibm.com \
    --cc=jmorris@namei$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-next@vger$(echo .)kernel.org \
    --cc=matthewgarrett@google$(echo .)com \
    --cc=rostedt@goodmis$(echo .)org \
    --cc=sfr@canb$(echo .)auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox