Commit 7525ab47 authored by Eric Sandeen's avatar Eric Sandeen Committed by Stefan Bader

xfs: don't call xfs_da_shrink_inode with NULL bp

CVE-2018-13094

xfs_attr3_leaf_create may have errored out before instantiating a buffer,
for example if the blkno is out of range.  In that case there is no work
to do to remove it, and in fact xfs_da_shrink_inode will lead to an oops
if we try.

This also seems to fix a flaw where the original error from
xfs_attr3_leaf_create gets overwritten in the cleanup case, and it
removes a pointless assignment to bp which isn't used after this.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199969Reported-by: default avatarXu, Wen <wen.xu@gatech.edu>
Tested-by: default avatarXu, Wen <wen.xu@gatech.edu>
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
(cherry picked from commit bb3d48dc)
Signed-off-by: default avatarPo-Hsu Lin <po-hsu.lin@canonical.com>
Acked-by: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarAaron Ma <aaron.ma@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent d97ac6b8
...@@ -779,9 +779,8 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) ...@@ -779,9 +779,8 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
ASSERT(blkno == 0); ASSERT(blkno == 0);
error = xfs_attr3_leaf_create(args, blkno, &bp); error = xfs_attr3_leaf_create(args, blkno, &bp);
if (error) { if (error) {
error = xfs_da_shrink_inode(args, 0, bp); /* xfs_attr3_leaf_create may not have instantiated a block */
bp = NULL; if (bp && (xfs_da_shrink_inode(args, 0, bp) != 0))
if (error)
goto out; goto out;
xfs_idata_realloc(dp, size, XFS_ATTR_FORK); /* try to put */ xfs_idata_realloc(dp, size, XFS_ATTR_FORK); /* try to put */
memcpy(ifp->if_u1.if_data, tmpbuffer, size); /* it back */ memcpy(ifp->if_u1.if_data, tmpbuffer, size); /* it back */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment