[patch 57/87] coda: avoid NULL pointer dereference from a bad inode

From
Andrew Morton <akpm@linux-foundation.org>
Date
2021-11-09 02:34:33
Also in
mm-commits
Reply to
Andrew Morton, 2021-11-09
From: Jan Harkes <jaharkes@cs.cmu.edu>
Subject: coda: avoid NULL pointer dereference from a bad inode

Patch series "Coda updates for -next".

The following patch series contains some fixes for the Coda kernel module
I've had sitting around and were tested extensively in a development
version of the Coda kernel module that lives outside of the main kernel.


This patch (of 9):

Avoid accessing coda_inode_info from a dentry with a bad inode.

Link: https://lkml.kernel.org/r/20210908140308.18491-1-jaharkes@cs.cmu.edu (local)
Link: https://lkml.kernel.org/r/20210908140308.18491-2-jaharkes@cs.cmu.edu (local)
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
Cc: Alex Shi <redacted>
Cc: Jing Yangyang <redacted>
Cc: Xin Tan <redacted>
Cc: Xiyu Yang <redacted>
Cc: Zeal Robot <redacted>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/coda/dir.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
--- a/fs/coda/dir.c~coda-avoid-null-pointer-dereference-from-a-bad-inode
+++ a/fs/coda/dir.c
@@ -499,15 +499,20 @@ out:
  */
 static int coda_dentry_delete(const struct dentry * dentry)
 {
-	int flags;
+	struct inode *inode;
+	struct coda_inode_info *cii;
 
 	if (d_really_is_negative(dentry)) 
 		return 0;
 
-	flags = (ITOC(d_inode(dentry))->c_flags) & C_PURGE;
-	if (is_bad_inode(d_inode(dentry)) || flags) {
+	inode = d_inode(dentry);
+	if (!inode || is_bad_inode(inode))
 		return 1;
-	}
+
+	cii = ITOC(inode);
+	if (cii->c_flags & C_PURGE)
+		return 1;
+
 	return 0;
 }
 
_
Thread (98 messages) 98 messages, 4 authors, last reply 2021-11-10
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help