ecryptfs: Fix explicit null dereference
PATCH 1/1 ecryptfs: Fix explicit null dereference
If the condition 'ecryptfs_file_to_private(file)' takes false branch lower_file is dereferenced when NULL.
Caught by Coverity: CIDs 1128834 and 1128833.
--- fs/ecryptfs/file.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/ecryptfs/file.c +8 -4
@@ -316,10 +316,12 @@ ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *lower_file =NULL ;long rc = -ENOTTY ; -if (ecryptfs_file_to_private (file)) - lower_file =ecryptfs_file_to_lower (file); +if (!ecryptfs_file_to_private (file)) + goto out; + lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op->unlocked_ioctl) rc = lower_file->f_op->unlocked_ioctl (lower_file, cmd, arg); +out:return rc; }
@@ -330,10 +332,12 @@ ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *lower_file =NULL ;long rc = -ENOIOCTLCMD ; -if (ecryptfs_file_to_private (file)) - lower_file =ecryptfs_file_to_lower (file); +if (!ecryptfs_file_to_private (file)) + goto out; + lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op && lower_file->f_op->compat_ioctl) rc = lower_file->f_op->compat_ioctl (lower_file, cmd, arg); +out: return rc; }#endif
Signature · 1 line
1.8.4.2
Quoted 6 lines · Geyslan G. Bem
If the condition '
ecryptfs_file_to_private(file)' takes false branchlower_fileis dereferenced when NULL.Caught by Coverity: CIDs 1128834 and 1128833.
Signed-off-by Geyslan G. Bem <[email protected]>
Quoted 7 lines · Geyslan G. Bem
If the condition '
ecryptfs_file_to_private(file)' takes false branchlower_fileis dereferenced when NULL.Caught by Coverity: CIDs 1128834 and 1128833.
Signed-off-by Geyslan G. Bem <[email protected]>---
Hello - Smatch picked up on this earlier in week and Dan analyzed the situation here:
http://article.gmane.org/gmane.comp.file-systems.ecryptfs.general/441
I agree with his assessment and proposed the following patch:
http://article.gmane.org/gmane.comp.file-systems.ecryptfs.general/442
It makes Smatch happy and it should also make Coverity happy.
Tyler
Quoted 44 lines
fs/ecryptfs/file.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)fs/ecryptfs/file.c +8
-4@@ -316,10 +316,12 @@ ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *lower_file =NULL ;long rc = -ENOTTY ; -if (ecryptfs_file_to_private (file)) - lower_file =ecryptfs_file_to_lower (file); +if (!ecryptfs_file_to_private (file)) + goto out; + lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op->unlocked_ioctl) rc = lower_file->f_op->unlocked_ioctl (lower_file, cmd, arg); +out:return rc; }@@ -330,10 +332,12 @@ ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *lower_file =NULL ;long rc = -ENOIOCTLCMD ; -if (ecryptfs_file_to_private (file)) - lower_file =ecryptfs_file_to_lower (file); +if (!ecryptfs_file_to_private (file)) + goto out; + lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op && lower_file->f_op->compat_ioctl) rc = lower_file->f_op->compat_ioctl (lower_file, cmd, arg); +out: return rc; }#endif Signature · 6 lines
1.8.4.2 -- To unsubscribe from this list: send the line "unsubscribe ecryptfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
2013/11/14 Tyler Hicks <[email protected]>:
Quoted 14 lines · Geyslan G. Bem
Quoted 7 lines
If the condition '
ecryptfs_file_to_private(file)' takes false branchlower_fileis dereferenced when NULL.Caught by Coverity: CIDs 1128834 and 1128833.
Signed-off-by Geyslan G. Bem <[email protected]>---
Hello - Smatch picked up on this earlier in week and Dan analyzed the situation here:
http://article.gmane.org/gmane.comp.file-systems.ecryptfs.general/441
Quoted 7 lines
I agree with his assessment and proposed the following patch:
http://article.gmane.org/gmane.comp.file-systems.ecryptfs.general/442
It makes Smatch happy and it should also make Coverity happy.
Tyler
True. Disregard mine.
Thanks Tyler.
Quoted 45 lines
Quoted 45 lines
fs/ecryptfs/file.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)fs/ecryptfs/file.c +8
-5@@ -316,10 +316,12 @@ ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *lower_file =NULL ;long rc = -ENOTTY ; -if (ecryptfs_file_to_private (file)) - lower_file =ecryptfs_file_to_lower (file); +if (!ecryptfs_file_to_private (file)) + goto out; + lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op->unlocked_ioctl) rc = lower_file->f_op->unlocked_ioctl (lower_file, cmd, arg); +out:return rc; }@@ -330,10 +332,12 @@ ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *lower_file =NULL ;long rc = -ENOIOCTLCMD ; -if (ecryptfs_file_to_private (file)) - lower_file =ecryptfs_file_to_lower (file); +if (!ecryptfs_file_to_private (file)) + goto out; + lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op && lower_file->f_op->compat_ioctl) rc = lower_file->f_op->compat_ioctl (lower_file, cmd, arg); +out: return rc; }#endif --1.8.4.2
--
To unsubscribe from this list: send the line "unsubscribe ecryptfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
Regards, Geyslan G. Bem hackingbits.com
Quoted 19 lines · Geyslan Gregório Bem
2013/11/14 Tyler Hicks <[email protected]>:
Quoted 18 lines · Geyslan G. Bem
Quoted 7 lines
If the condition '
ecryptfs_file_to_private(file)' takes false branchlower_fileis dereferenced when NULL.Caught by Coverity: CIDs 1128834 and 1128833.
Signed-off-by Geyslan G. Bem <[email protected]>---
Hello - Smatch picked up on this earlier in week and Dan analyzed the situation here:
http://article.gmane.org/gmane.comp.file-systems.ecryptfs.general/441
I agree with his assessment and proposed the following patch:
http://article.gmane.org/gmane.comp.file-systems.ecryptfs.general/442
Quoted 7 lines
Quoted 3 lines
It makes Smatch happy and it should also make Coverity happy.
Tyler
True. Disregard mine.
Thanks Tyler.
Thank you! Can I add your Reviewed-by: tag to that patch prior to pushing it to my next branch?
Tyler
Quoted 58 lines
Quoted 46 lines
Quoted 46 lines
fs/ecryptfs/file.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)fs/ecryptfs/file.c +8
-5@@ -316,10 +316,12 @@ ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *lower_file =NULL ;long rc = -ENOTTY ; -if (ecryptfs_file_to_private (file)) - lower_file =ecryptfs_file_to_lower (file); +if (!ecryptfs_file_to_private (file)) + goto out; + lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op->unlocked_ioctl) rc = lower_file->f_op->unlocked_ioctl (lower_file, cmd, arg); +out:return rc; }@@ -330,10 +332,12 @@ ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *lower_file =NULL ;long rc = -ENOIOCTLCMD ; -if (ecryptfs_file_to_private (file)) - lower_file =ecryptfs_file_to_lower (file); +if (!ecryptfs_file_to_private (file)) + goto out; + lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op && lower_file->f_op->compat_ioctl) rc = lower_file->f_op->compat_ioctl (lower_file, cmd, arg); +out: return rc; }#endif --1.8.4.2
--
To unsubscribe from this list: send the line "unsubscribe ecryptfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 8 lines
Regards, Geyslan G. Bem hackingbits.com -- To unsubscribe from this list: send the line "unsubscribe ecryptfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
2013/11/14 Tyler Hicks <[email protected]>:
Quoted 24 lines · Geyslan Gregório Bem
Quoted 23 lines
2013/11/14 Tyler Hicks <[email protected]>:
Quoted 21 lines · Geyslan G. Bem
Quoted 7 lines
If the condition '
ecryptfs_file_to_private(file)' takes false branchlower_fileis dereferenced when NULL.Caught by Coverity: CIDs 1128834 and 1128833.
Signed-off-by Geyslan G. Bem <[email protected]>---
Hello - Smatch picked up on this earlier in week and Dan analyzed the situation here:
http://article.gmane.org/gmane.comp.file-systems.ecryptfs.general/441
I agree with his assessment and proposed the following patch:
http://article.gmane.org/gmane.comp.file-systems.ecryptfs.general/442
It makes Smatch happy and it should also make Coverity happy.
Tyler
Quoted 9 lines
Quoted 3 lines
True. Disregard mine.
Thanks Tyler.
Thank you! Can I add your Reviewed-by: tag to that patch prior to pushing it to my next branch?
Tyler
Sure, Tyler. You can! :)
Thanks again.
Quoted 58 lines
Quoted 58 lines
Quoted 42 lines
Quoted 42 lines
fs/ecryptfs/file.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)fs/ecryptfs/file.c +8
-5@@ -316,10 +316,12 @@ ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *lower_file =NULL ;long rc = -ENOTTY ; -if (ecryptfs_file_to_private (file)) - lower_file =ecryptfs_file_to_lower (file); +if (!ecryptfs_file_to_private (file)) + goto out; + lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op->unlocked_ioctl) rc = lower_file->f_op->unlocked_ioctl (lower_file, cmd, arg); +out:return rc; }@@ -330,10 +332,12 @@ ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *lower_file =NULL ;long rc = -ENOIOCTLCMD ; -if (ecryptfs_file_to_private (file)) - lower_file =ecryptfs_file_to_lower (file); +if (!ecryptfs_file_to_private (file)) + goto out; + lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op && lower_file->f_op->compat_ioctl) rc = lower_file->f_op->compat_ioctl (lower_file, cmd, arg); +out: return rc; }#endif --1.8.4.2
Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe ecryptfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
Regards,Geyslan G. Bem
hackingbits.com
--
To unsubscribe from this list: send the line "unsubscribe ecryptfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
Regards, Geyslan G. Bem hackingbits.com