* [PATCH] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get
@ 2015-07-23 4:59 Eric Sandeen
2015-07-23 5:20 ` Eric Sandeen
0 siblings, 1 reply; 2+ messages in thread
From: Eric Sandeen @ 2015-07-23 4:59 UTC (permalink / raw)
To: xfs-oss
It's entirely possible for userspace to ask for an xattr which
does not exist.
Normally, there is no problem whatsoever when we ask for such
a thing, but when we look at an obfuscated metadump image
on a debug kernel with selinux, we trip over this ASSERT in
xfs_da3_path_shift():
*result = -ENOENT; /* we're out of our tree */
ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
It (more or less) only shows up in the above scenario, because
xfs_metadump obfuscates attr names, but chooses names which
keep the same hash value - and xfs_da3_node_lookup_int does:
if (((retval == -ENOENT) || (retval == -ENOATTR)) &&
(blk->hashval == args->hashval)) {
error = xfs_da3_path_shift(state, &state->path, 1, 1,
&retval);
IOWS, we only get down to the xfs_da3_path_shift() ASSERT
if we are looking for an xattr which doesn't exist, but we
find xattrs on disk which have the same hash, and so might be
a hash collision, so we try the path shift. When *that*
fails to find what we're looking for, we hit the assert about
XFS_DA_OP_OKNOENT.
Simply setting XFS_DA_OP_OKNOENT in xfs_attr_get solves this
rather corner-case problem with no ill side effects. It's
fine for an attr name lookup to fail.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 3349c9a..ff06557 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -139,6 +139,8 @@ xfs_attr_get(
args.value = value;
args.valuelen = *valuelenp;
+ /* Entirely possible to look up a name which doesn't exist */
+ args.op_flags = XFS_DA_OP_OKNOENT;
lock_mode = xfs_ilock_attr_map_shared(ip);
if (!xfs_inode_hasattr(ip))
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get
2015-07-23 4:59 [PATCH] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get Eric Sandeen
@ 2015-07-23 5:20 ` Eric Sandeen
0 siblings, 0 replies; 2+ messages in thread
From: Eric Sandeen @ 2015-07-23 5:20 UTC (permalink / raw)
To: Eric Sandeen; +Cc: xfs-oss
On Jul 22, 2015, at 11:59 PM, Eric Sandeen <sandeen@redhat.com> wrote:
>
> It's entirely possible for userspace to ask for an xattr which
> does not exist.
>
> Normally, there is no problem whatsoever when we ask for such
> a thing, but when we look at an obfuscated metadump image
> on a debug kernel with selinux, we trip over this ASSERT in
> xfs_da3_path_shift():
>
> *result = -ENOENT; /* we're out of our tree */
> ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
>
> It (more or less) only shows up in the above scenario, because
> xfs_metadump obfuscates attr names, but chooses names which
> keep the same hash value - and xfs_da3_node_lookup_int does:
>
> if (((retval == -ENOENT) || (retval == -ENOATTR)) &&
> (blk->hashval == args->hashval)) {
> error = xfs_da3_path_shift(state, &state->path, 1, 1,
> &retval);
Oh, and add: thanks to dchinner for spotting the above conditional that got us there ;)
-Eric
> IOWS, we only get down to the xfs_da3_path_shift() ASSERT
> if we are looking for an xattr which doesn't exist, but we
> find xattrs on disk which have the same hash, and so might be
> a hash collision, so we try the path shift. When *that*
> fails to find what we're looking for, we hit the assert about
> XFS_DA_OP_OKNOENT.
>
> Simply setting XFS_DA_OP_OKNOENT in xfs_attr_get solves this
> rather corner-case problem with no ill side effects. It's
> fine for an attr name lookup to fail.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 3349c9a..ff06557 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -139,6 +139,8 @@ xfs_attr_get(
>
> args.value = value;
> args.valuelen = *valuelenp;
> + /* Entirely possible to look up a name which doesn't exist */
> + args.op_flags = XFS_DA_OP_OKNOENT;
>
> lock_mode = xfs_ilock_attr_map_shared(ip);
> if (!xfs_inode_hasattr(ip))
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
>
_______________________________________________
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:[~2015-07-23 5:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-23 4:59 [PATCH] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get Eric Sandeen
2015-07-23 5:20 ` Eric Sandeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox