* [PATCH] xfs: fix getfsmap userspace memory corruption while setting OF_LAST
@ 2017-04-23 17:46 Darrick J. Wong
2017-04-24 7:05 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2017-04-23 17:46 UTC (permalink / raw)
To: xfs; +Cc: Christoph Hellwig
At the end of a getfsmap call, we will set FMR_OF_LAST in the last
struct fsmap that was handed in by userspace if we've truly run out of
space mapping record (as opposed to simply running out of space in the
user array). Unfortunately, fmh_entries is the wrong check for whether
or not we've filled out anything in the user array because the ioctl
provides that fmh_count==0 sets fmh_entries without filling out the fsmap
array. Therefore we end up writing things into user memory areas that we
weren't given, and kaboom.
Since Christoph amended the getfsmap structure to track the number of
fsmap entries we've actually filled out, use that as part of deciding if
we have to set the OF_LAST flag.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/xfs_ioctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index eee8b0f..6190697 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1674,7 +1674,7 @@ xfs_ioc_getfsmap(
return error;
/* If we didn't abort, set the "last" flag in the last fmx */
- if (!aborted && xhead.fmh_entries) {
+ if (!aborted && info.idx) {
info.last_flags |= FMR_OF_LAST;
if (copy_to_user(&info.data->fmh_recs[info.idx - 1].fmr_flags,
&info.last_flags, sizeof(info.last_flags)))
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfs: fix getfsmap userspace memory corruption while setting OF_LAST
2017-04-23 17:46 [PATCH] xfs: fix getfsmap userspace memory corruption while setting OF_LAST Darrick J. Wong
@ 2017-04-24 7:05 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2017-04-24 7:05 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs, Christoph Hellwig
Looks fine,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-24 7:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-23 17:46 [PATCH] xfs: fix getfsmap userspace memory corruption while setting OF_LAST Darrick J. Wong
2017-04-24 7:05 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox