public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* dm_get_dirattrs can write past end of user buffer
@ 2009-02-01  0:12 Kevin Jamieson
  2009-02-01  5:09 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Jamieson @ 2009-02-01  0:12 UTC (permalink / raw)
  To: xfs

I have observed segfaults with an application that calls dm_get_dirattrs
with the latest DMAPI kernel built from SGI CVS.

The problem appears to be in dm_filldir:

	needed = dm_stat_size(namelen + 1);
	...
	error = -xfs_dm_bulkattr_iget_one(cb->mp, ino, 0,
		statp, needed);
	...
	/*
	 * On return from bulkstat_one(), stap->_link points
	 * at the end of the handle in the stat structure.
	 */
	statp->dt_compname.vd_offset = statp->_link;
	statp->dt_compname.vd_length = namelen + 1;

xfs_dm_bulkattr_iget_one() sets statp->_link to needed, so the name ends
up getting written past the space reserved for the name, which can
exceed cb->spaceleft.

The below patch appears to fix the problem.


Index: fs/xfs/dmapi/xfs_dm.c
===================================================================
RCS file: /cvs/linux-2.6-xfs/fs/xfs/dmapi/xfs_dm.c,v
retrieving revision 1.81
diff -u -r1.81 xfs_dm.c
--- fs/xfs/dmapi/xfs_dm.c	28 Oct 2008 05:39:09 -0000	1.81
+++ fs/xfs/dmapi/xfs_dm.c	31 Jan 2009 23:08:07 -0000
@@ -1793,7 +1793,7 @@
 
 	memset(statp, 0, dm_stat_size(MAXNAMLEN));
 	error = -xfs_dm_bulkattr_iget_one(cb->mp, ino, 0,
-			statp, needed);
+			statp, DM_STAT_SIZE(*statp, 0));
 	if (error)
 		goto out_err;
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: dm_get_dirattrs can write past end of user buffer
  2009-02-01  0:12 dm_get_dirattrs can write past end of user buffer Kevin Jamieson
@ 2009-02-01  5:09 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2009-02-01  5:09 UTC (permalink / raw)
  To: Kevin Jamieson; +Cc: xfs

On Sat, Jan 31, 2009 at 04:12:52PM -0800, Kevin Jamieson wrote:
> The below patch appears to fix the problem.

The patch looks okay, but I don't think there's any uptodate tree
that includes dmapi support.

Btw, we'd also need to have a

	Signed-off-by: Kevin Jamieson <kevin@kevinjamieson.com>

please read Documentation/SubmittingPatches in the kernel tree and make
sure you agree with the conditions for the Signed-off-by:.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-01  5:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-01  0:12 dm_get_dirattrs can write past end of user buffer Kevin Jamieson
2009-02-01  5:09 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox