Thread (27 messages) 27 messages, 7 authors, 2018-09-28

Re: [PATCH 6/6] xfs: don't crash the vfs on a garbage inline symlink

From: Allison Henderson <hidden>
Date: 2018-08-12 10:31:22


On 08/11/2018 08:35 AM, Darrick J. Wong wrote:
quoted hunk ↗ jump to hunk
From: Darrick J. Wong <redacted>

The VFS routine that calls ->get_link blindly copies whatever's returned
into the user's buffer.  If we return a NULL pointer, the vfs will
crash on the null pointer.  Therefore, return -EFSCORRUPTED instead of
blowing up the kernel.

Reported-by: wen.xu@gatech.edu
Signed-off-by: Darrick J. Wong <redacted>
---
  fs/xfs/xfs_iops.c |   10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 0ef5ad7fb851..26007a9db49d 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -471,8 +471,16 @@ xfs_vn_get_link_inline(
  	struct inode		*inode,
  	struct delayed_call	*done)
  {
+	char			*ptr;
+
  	ASSERT(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE);
-	return XFS_I(inode)->i_df.if_u1.if_data;
+
+	/*
+	 * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED if
+	 * if_data is junk.
+	 */
+	ptr = XFS_I(inode)->i_df.if_u1.if_data;
+	return ptr ? ptr : ERR_PTR(-EFSCORRUPTED);
  }
  
  STATIC int
Ok, looks fine.
Reviewed-by: Allison Henderson <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help