Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1372355 > unrolled thread
| Started by | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| First post | 2016-04-06 12:10 +0200 |
| Last post | 2016-04-06 18:20 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] proc: fix dereference of ERR_PTR Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2016-04-06 12:10 +0200
Re: [PATCH] proc: fix dereference of ERR_PTR Al Viro <viro@ZenIV.linux.org.uk> - 2016-04-06 18:20 +0200
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Date | 2016-04-06 12:10 +0200 |
| Subject | [PATCH] proc: fix dereference of ERR_PTR |
| Message-ID | <rkSzo-2dL-15@gated-at.bofh.it> |
On the unlikely event of a bad name, d_hash_and_lookup() can return the
error value in ERR_PTR(). And we were only checking the return value of
d_hash_and_lookup() to be NULL. In case it is not NULL and has some
error then d_inode() will try to dereference it later.
Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
---
fs/proc/base.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index b1755b2..a71df53 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1818,7 +1818,7 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,
ino_t ino;
child = d_hash_and_lookup(dir, &qname);
- if (!child) {
+ if (IS_ERR_OR_NULL(child)) {
child = d_alloc(dir, &qname);
if (!child)
goto end_instantiate;
--
2.1.4
[toc] | [next] | [standalone]
| From | Al Viro <viro@ZenIV.linux.org.uk> |
|---|---|
| Date | 2016-04-06 18:20 +0200 |
| Message-ID | <rkYls-6yQ-29@gated-at.bofh.it> |
| In reply to | #1372355 |
On Wed, Apr 06, 2016 at 11:07:45AM +0100, Sudip Mukherjee wrote:
> On the unlikely event of a bad name, d_hash_and_lookup() can return the
> error value in ERR_PTR(). And we were only checking the return value of
> d_hash_and_lookup() to be NULL. In case it is not NULL and has some
> error then d_inode() will try to dereference it later.
s/unlikely/impossible/ - procfs doesn't _have_ ->d_hash. NAK; at most
add a
/* no ->d_hash() rejects on procfs */
comment as we have next to another call site in procfs.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web