* [PATCH] ecryptfs: remove unneeded buggy code in ecryptfs_do_create()
@ 2014-09-22 20:39 Alexey Khoroshilov
2014-10-09 22:26 ` Tyler Hicks
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2014-09-22 20:39 UTC (permalink / raw)
To: Tyler Hicks
Cc: Alexey Khoroshilov, Al Viro, ecryptfs, linux-kernel, ldv-project
There is a bug in error handling of lock_parent() in ecryptfs_do_create():
lock_parent() acquries mutex even if dget_parent() fails, so mutex should be unlocked anyway.
But dget_parent() does not fail, so the patch just removes unneeded buggy code.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
fs/ecryptfs/inode.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index d4a9431ec73c..97735c75085f 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -192,12 +192,6 @@ ecryptfs_do_create(struct inode *directory_inode,
lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry);
lower_dir_dentry = lock_parent(lower_dentry);
- if (IS_ERR(lower_dir_dentry)) {
- ecryptfs_printk(KERN_ERR, "Error locking directory of "
- "dentry\n");
- inode = ERR_CAST(lower_dir_dentry);
- goto out;
- }
rc = vfs_create(lower_dir_dentry->d_inode, lower_dentry, mode, true);
if (rc) {
printk(KERN_ERR "%s: Failure to create dentry in lower fs; "
@@ -215,7 +209,6 @@ ecryptfs_do_create(struct inode *directory_inode,
fsstack_copy_inode_size(directory_inode, lower_dir_dentry->d_inode);
out_lock:
unlock_dir(lower_dir_dentry);
-out:
return inode;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ecryptfs: remove unneeded buggy code in ecryptfs_do_create()
2014-09-22 20:39 [PATCH] ecryptfs: remove unneeded buggy code in ecryptfs_do_create() Alexey Khoroshilov
@ 2014-10-09 22:26 ` Tyler Hicks
0 siblings, 0 replies; 2+ messages in thread
From: Tyler Hicks @ 2014-10-09 22:26 UTC (permalink / raw)
To: Alexey Khoroshilov; +Cc: Al Viro, ecryptfs, linux-kernel, ldv-project
[-- Attachment #1: Type: text/plain, Size: 1629 bytes --]
Hi Alexey - thanks for the patch.
On 2014-09-23 00:39:31, Alexey Khoroshilov wrote:
> There is a bug in error handling of lock_parent() in ecryptfs_do_create():
> lock_parent() acquries mutex even if dget_parent() fails, so mutex should be unlocked anyway.
>
> But dget_parent() does not fail, so the patch just removes unneeded buggy code.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
This looks good to me and I've included it in the pull request that I
just sent to Linus. Thanks!
Tyler
> ---
> fs/ecryptfs/inode.c | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index d4a9431ec73c..97735c75085f 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -192,12 +192,6 @@ ecryptfs_do_create(struct inode *directory_inode,
>
> lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry);
> lower_dir_dentry = lock_parent(lower_dentry);
> - if (IS_ERR(lower_dir_dentry)) {
> - ecryptfs_printk(KERN_ERR, "Error locking directory of "
> - "dentry\n");
> - inode = ERR_CAST(lower_dir_dentry);
> - goto out;
> - }
> rc = vfs_create(lower_dir_dentry->d_inode, lower_dentry, mode, true);
> if (rc) {
> printk(KERN_ERR "%s: Failure to create dentry in lower fs; "
> @@ -215,7 +209,6 @@ ecryptfs_do_create(struct inode *directory_inode,
> fsstack_copy_inode_size(directory_inode, lower_dir_dentry->d_inode);
> out_lock:
> unlock_dir(lower_dir_dentry);
> -out:
> return inode;
> }
>
> --
> 1.9.1
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-09 22:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-22 20:39 [PATCH] ecryptfs: remove unneeded buggy code in ecryptfs_do_create() Alexey Khoroshilov
2014-10-09 22:26 ` Tyler Hicks
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.