cifs: cope with negative dentries in cifs_get_root
Subsystems (3)
PATCH 1/1 cifs: cope with negative dentries in cifs_get_root
The loop around lookup_one_len doesn't handle the case where it might return a negative dentry, which can cause an oops on the next pass through the loop. Check for that and break out of the loop with an error of -ENOENT if there is one.
Fixes the panic reported here:
https://bugzilla.redhat.com/show_bug.cgi?id=727927
--- fs/cifs/cifsfs.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
fs/cifs/cifsfs.c +4 -0
@@ -563,6 +563,10 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)mutex_unlock (&dir->i_mutex);dput (dentry); dentry = child; +if (!dentry->d_inode) { +dput (dentry); + dentry =ERR_PTR (-ENOENT ); + } }while (!IS_ERR (dentry));_FreeXid (xid);kfree (full_path);
Signature · 1 line
1.7.6
A message that is not in the archive (sent off-list or not yet received): 1312549360-4317-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Quoted 4 lines · Jeff Layton
The loop around
lookup_one_lendoesn't handle the case where it might return a negative dentry, which can cause an oops on the next pass through the loop. Check for that and break out of the loop with an error of-ENOENTif there is one.
Ouch. Nice catch and that one is my damn fault. Do you want that one to go through cifs or vfs tree? ACK, in any case...
A message that is not in the archive (sent off-list or not yet received): 20110805145428.GS2203-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org
Quoted 8 lines · Al Viro
Quoted 4 lines · Jeff Layton
The loop around
lookup_one_lendoesn't handle the case where it might return a negative dentry, which can cause an oops on the next pass through the loop. Check for that and break out of the loop with an error of-ENOENTif there is one.Ouch. Nice catch and that one is my damn fault. Do you want that one to go through cifs or vfs tree? ACK, in any case...
Probably safer to go through my tree, reduce chance of merge conflict Was planning on sending a merge request up soon in any case.
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): CAH2r5mvB8jyZnnSaGCs1Z=NWMCh6LQBpwTR3hY1Fv9pxw54+Kw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Al Viro
Acked-byQuoted 7 lines · Steve French
Quoted 6 lines · Al Viro
Quoted 4 lines · Jeff Layton
The loop around
lookup_one_lendoesn't handle the case where it might return a negative dentry, which can cause an oops on the next pass through the loop. Check for that and break out of the loop with an error of-ENOENTif there is one.
Quoted 5 lines
Quoted 2 lines
Ouch. ?Nice catch and that one is my damn fault. ?Do you want that one to go through cifs or vfs tree? ?ACK, in any case...
Probably safer to go through my tree, reduce chance of merge conflict Was planning on sending a merge request up soon in any case.
OK
2011/8/5 Jeff Layton <[email protected]>:
Quoted 23 lines
The loop around
lookup_one_lendoesn't handle the case where it might return a negative dentry, which can cause an oops on the next pass through the loop. Check for that and break out of the loop with an error of-ENOENTif there is one.Fixes the panic reported here:
https://bugzilla.redhat.com/show_bug.cgi?id=727927
Reported-by TR Bentley <[email protected]>Reported-by Iain Arnell <[email protected]>Cc Al Viro <[email protected]>Signed-off-by Jeff Layton <[email protected]>---
fs/cifs/cifsfs.c | 4 ++++1 files changed, 4 insertions(+), 0 deletions(-)fs/cifs/cifsfs.c +0
-0
fs/cifs/cifsfs.c cifs_get_root(struct smb_vol *vol, struct super_block *sb) · line 566
Quoted 4 lines
fs/cifs/cifsfs.c +1
-0@@ -563,6 +563,10 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) mutex_unlock(&dir->i_mutex); dput(dentry); dentry = child; + if (!dentry->d_inode) {
dentry can be NULL here (returned from lookup_one_len) and it can cause a null pointer dereference.
Quoted 14 lines
fs/cifs/cifsfs.c +3
-1+ dput(dentry); + dentry = ERR_PTR(-ENOENT); + } } while (!IS_ERR(dentry)); _FreeXid(xid); kfree(full_path); --1.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best regards, Pavel Shilovsky.
A message that is not in the archive (sent off-list or not yet received): CAKywueRT9cGPu5pCiiYONd7DruBaE2TDvHVVyyELYwM_Ft5e+Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 7 lines · Pavel Shilovsky
Quoted 4 lines
? ? ? ? ? ? ? ?mutex_unlock(&dir->i_mutex);
? ? ? ? ? ? ? ?dput(dentry);
? ? ? ? ? ? ? ?dentry = child;
+ ? ? ? ? ? ? ? if (!dentry->d_inode) {dentry can be NULL here (returned from
lookup_one_len) and it can cause a null pointer dereference.
Not NULL, ERR_PTR(...). IOW, we need to check IS_ERR(dentry) to protect that check of dentry->d_inode.
Steve French
AppliedQuoted 5 lines · Jeff Layton
The loop around
lookup_one_lendoesn't handle the case where it might return a negative dentry, which can cause an oops on the next pass through the loop. Check for that and break out of the loop with an error of-ENOENTif there is one.
merged into cifs-2.6.git
Signature · 3 lines
Thanks, Steve