[Top] [All Lists]

Re: [PATCH] xfsprogs: Fix possible unallocated memory access in fiemap

To: Lukas Czerner <lczerner@xxxxxxxxxx>
Subject: Re: [PATCH] xfsprogs: Fix possible unallocated memory access in fiemap
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Thu, 13 Dec 2012 10:12:45 +1100
Cc: xfs@xxxxxxxxxxx, hch@xxxxxxxxxxxxx
In-reply-to: <1355319059-12111-1-git-send-email-lczerner@xxxxxxxxxx>
References: <1355319059-12111-1-git-send-email-lczerner@xxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Wed, Dec 12, 2012 at 02:30:59PM +0100, Lukas Czerner wrote:
> Currently we could access unallocated memory in fiemap because we're
> using uninitialized variable 'fiemap' in fiemap_f(). In fact this has
> been spotted on x390s machine where xfs_io would segfault.
> The problem happens in the for cycle which seems to be intended to
> compute the header item spacing. However at that point the fiemap
> structure has just been allocated and does not contain any extents
> yet, so it is entirely useless and it never actually worked.
> This patch removes this dead code mentioned above which also fixes
> the possible unallocated memory access.

I think the correct fix is to move the formatting calculation to
after the first fiemap call. The formatting is actually useful
because it calculates column widths that make sure output is fairly
nicely aligned, and that is definitely of value when you are looking
at output thousands of extents long...


Dave Chinner

<Prev in Thread] Current Thread [Next in Thread>