xfs: fix kernel memory exposure problems
PATCH v2 1/1 xfs: fix kernel memory exposure problems
Fix a memory exposure problems in inumbers where we allocate an array of structures with holes, fail to zero the holes, then blindly copy the kernel memory contents (junk and all) into userspace.
---
v2: split patches
--- fs/xfs/xfs_itable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_itable.c +1 -1
@@ -583,7 +583,7 @@ xfs_inumbers(return error; bcount =MIN (left, (int )(PAGE_SIZE /sizeof (*buffer))); - buffer =kmem_alloc (bcount *sizeof (*buffer),KM_SLEEP ); + buffer =kmem_zalloc (bcount *sizeof (*buffer),KM_SLEEP ); do { struct xfs_inobt_rec_incore r; int stat;
PATCH 1/1 xfs: fix over-copying of getbmap parameters from userspace
In xfs_ioc_getbmap, we should only copy the fields of struct getbmap from userspace, or else we end up copying random stack contents into the kernel. struct getbmap is a strict subset of getbmapx, so a partial structure copy should work fine.
--- fs/xfs/xfs_ioctl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/xfs/xfs_ioctl.c +6 -2
@@ -1543,10 +1543,14 @@ xfs_ioc_getbmap(unsigned int cmd, void __user *arg) { - struct getbmapx bmx; + struct getbmapx bmx = { 0 };int error; -if (copy_from_user (&bmx, arg,sizeof (struct getbmapx ))) +/* +* struct getbmap is a strict subset of struct getbmapx, +* so using a straight memory copy should work fine. +*/ +if (copy_from_user (&bmx, arg, offsetof(struct getbmapx , bmv_iflags)))return -EFAULT ;if (bmx.bmv_count <2 )
Re: [PATCH] xfs: fix over-copying of getbmap parameters from userspace
fs/xfs/xfs_ioctl.c xfs_ioc_getbmap( · line 1551
Quoted 1 line
fs/xfs/xfs_ioctl.c +1
-0+* so using a straight memory copy should work fine.
I'd skip this half of the comment.
Otherwise looks fine:
Re: [PATCH] xfs: fix over-copying of getbmap parameters from userspace
Quoted 3 lines · Christoph Hellwig
fs/xfs/xfs_ioctl.c xfs_ioc_getbmap( · line 1551
Quoted 1 line
fs/xfs/xfs_ioctl.c +1
-0+* so using a straight memory copy should work fine. I'd skip this half of the comment.
Will do.
Quoted 7 lines
Otherwise looks fine:
Reviewed-by Christoph Hellwig <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Darrick J. Wong
Fix a memory exposure problems in inumbers where we allocate an array of structures with holes, fail to zero the holes, then blindly copy the kernel memory contents (junk and all) into userspace.
Signed-off-by Darrick J. Wong <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>
BTW, I intend to send this patch (though not the getbmap patch) for 4.11 since kernel memory exposure is usually treated as a security problem.
--D
Quoted 23 lines
---
v2: split patches--- fs/xfs/xfs_itable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_itable.c +1
-2@@ -583,7 +583,7 @@ xfs_inumbers(return error; bcount =MIN (left, (int )(PAGE_SIZE /sizeof (*buffer))); - buffer =kmem_alloc (bcount *sizeof (*buffer),KM_SLEEP ); + buffer =kmem_zalloc (bcount *sizeof (*buffer),KM_SLEEP ); do { struct xfs_inobt_rec_incore r; int stat; --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Darrick J. Wong
Quoted 6 lines · Darrick J. Wong
Fix a memory exposure problems in inumbers where we allocate an array of structures with holes, fail to zero the holes, then blindly copy the kernel memory contents (junk and all) into userspace.
Signed-off-by Darrick J. Wong <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>BTW, I intend to send this patch (though not the getbmap patch) for 4.11 since kernel memory exposure is usually treated as a security problem.
I agree with that plan; if this change isn't safe I don't know what is ...
-Eric
Quoted 30 lines
--D
Quoted 20 lines
---
v2: split patches--- fs/xfs/xfs_itable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_itable.c +1
-2@@ -583,7 +583,7 @@ xfs_inumbers(return error; bcount =MIN (left, (int )(PAGE_SIZE /sizeof (*buffer))); - buffer =kmem_alloc (bcount *sizeof (*buffer),KM_SLEEP ); + buffer =kmem_zalloc (bcount *sizeof (*buffer),KM_SLEEP ); do { struct xfs_inobt_rec_incore r; int stat; --Quoted 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Eric Sandeen
Quoted 5 lines · Darrick J. Wong
Quoted 4 lines · Darrick J. Wong
Fix a memory exposure problems in inumbers where we allocate an array of structures with holes, fail to zero the holes, then blindly copy the kernel memory contents (junk and all) into userspace.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Darrick J. Wong <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>BTW, I intend to send this patch (though not the getbmap patch) for 4.11 since kernel memory exposure is usually treated as a security problem.
I agree with that plan; if this change isn't safe I don't know what is ...
Yes. Please send this for 4.11-rc.