Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ntfs: Use ERR_CAST() to avoid cross-structure cast

When trying to propagate an error result, the error return path attempts
to retain the error, but does this with an open cast across very different
types, which the upcoming structure layout randomization plugin flags as
being potentially dangerous in the face of randomization. This is a false
positive, but what this code actually wants to do is use ERR_CAST() to
retain the error value.

Cc: Anton Altaparmakov <anton@tuxera.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Kees Cook <keescook@chromium.org>

+1 -1
+1 -1
fs/ntfs/namei.c
··· 159 159 PTR_ERR(dent_inode)); 160 160 kfree(name); 161 161 /* Return the error code. */ 162 - return (struct dentry *)dent_inode; 162 + return ERR_CAST(dent_inode); 163 163 } 164 164 /* It is guaranteed that @name is no longer allocated at this point. */ 165 165 if (MREF_ERR(mref) == -ENOENT) {