From: Matthias Kaehlcke <mka@chromium.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
Josh Poimboeuf <jpoimboe@redhat.com>,
Manoj Gupta <manojgupta@chromium.org>,
Matthias Kaehlcke <mka@chromium.org>
Subject: [PATCH] debugfs: Check return value of debugfs_real_fops() for NULL
Date: Tue, 27 Mar 2018 16:55:53 -0700 [thread overview]
Message-ID: <20180327235553.210165-1-mka@chromium.org> (raw)
debugfs_real_fops() returns a NULL pointer when it is invoked without a
prior call to debugfs_file_get(). In code paths including this call it
is not strictly necessary to check the return value of
debugfs_real_fops(). However clang inlines debugfs_real_fops(), detects
the invalid dereferencing of the NULL pointer and drops the code path.
This leads to a bunch of objtool warnings when building with clang and
CONFIG_UNWINDER_ORC=y:
fs/debugfs/file.o: warning: objtool: full_proxy_llseek() falls through to next function full_proxy_read()
fs/debugfs/file.o: warning: objtool: full_proxy_read() falls through to next function full_proxy_write()
fs/debugfs/file.o: warning: objtool: full_proxy_write() falls through to next function full_proxy_poll()
fs/debugfs/file.o: warning: objtool: full_proxy_poll() falls through to next function full_proxy_unlocked_ioctl()
fs/debugfs/file.o: warning: objtool: full_proxy_unlocked_ioctl() falls through to next function fops_u8_open()
Check the pointer returned by debugfs_real_fops() in all code paths to
make clang and objtool happy.
Debugged-by: Josh Poimboeuf <jpoimboe@redhat.com>
Debugged-by: Manoj Gupta <manojgupta@chromium.org>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
fs/debugfs/file.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index cd12e6576b48..427e185ecc8f 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -183,7 +183,8 @@ static ret_type full_proxy_ ## name(proto) \
if (unlikely(r)) \
return r; \
real_fops = debugfs_real_fops(filp); \
- r = real_fops->name(args); \
+ if (real_fops) \
+ r = real_fops->name(args); \
debugfs_file_put(dentry); \
return r; \
}
@@ -217,7 +218,14 @@ static unsigned int full_proxy_poll(struct file *filp,
return POLLHUP;
real_fops = debugfs_real_fops(filp);
+ if (!real_fops) {
+ r = -ENXIO;
+ goto out;
+ }
+
r = real_fops->poll(filp, wait);
+
+out:
debugfs_file_put(dentry);
return r;
}
--
2.17.0.rc1.321.gba9d0f2565-goog
next reply other threads:[~2018-03-27 23:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-27 23:55 Matthias Kaehlcke [this message]
2018-03-28 6:16 ` Greg Kroah-Hartman
2018-03-28 14:47 ` Manoj Gupta
2018-03-28 15:30 ` Josh Poimboeuf
2018-03-28 15:34 ` Josh Poimboeuf
2018-03-28 18:05 ` Greg Kroah-Hartman
2018-03-28 18:14 ` Matthias Kaehlcke
2018-03-28 18:19 ` Greg Kroah-Hartman
2018-03-28 18:50 ` Matthias Kaehlcke
2018-03-28 19:22 ` Greg Kroah-Hartman
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=20180327235553.210165-1-mka@chromium.org \
--to=mka@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=manojgupta@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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
all inboxes | Powered by JetHome®