lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 30 Dec 2022 22:27:37 -0500
From:   "Theodore Ts'o" <tytso@....edu>
To:     Eric Biggers <ebiggers@...nel.org>
Cc:     Jun Nie <jun.nie@...aro.org>, adilger.kernel@...ger.ca,
        linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org,
        tudor.ambarus@...aro.org
Subject: Re: [PATCH 2/2] ext4: refuse to create ea block when umounted

On Fri, Dec 30, 2022 at 12:13:25PM -0800, Eric Biggers wrote:
> > diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> > index 235a517d9c17..ac58494e49b6 100644
> > --- a/fs/ext4/xattr.c
> > +++ b/fs/ext4/xattr.c
> > @@ -1422,6 +1422,12 @@ static struct inode *ext4_xattr_inode_create(handle_t *handle,
> >  	uid_t owner[2] = { i_uid_read(inode), i_gid_read(inode) };
> >  	int err;
> >  
> > +	if (inode->i_sb->s_root == NULL) {
> > +		ext4_error(inode->i_sb,
> > +			   "refuse to create EA inode when umounting");
> > +		return ERR_PTR(-EINVAL);
> > +	}

This should not be an ext4_error() since this is not a file system
corruption issue, but rather a kernel bug.  (With the one known
example being corrected by the first patch in this patch series.
Thanks Jun for working on a patch to things!)

This should be replaced by an ext4_warning() followed by a WARN_ON(1),
so we can get the stack trace.

> Why is an xattr being set during unmount?

The scenario was discovered by syzbot; the reproducer did the moral
equivalent of this (attached) shell script.  It required the
combination of lazytime and the debug_want_extra_isize mount options,
with a file system with (non-default) ea_inode feature enabled; so it
was highly unlikely to happen in real life.

For the detailed analysis, see [1]

[1] https://lore.kernel.org/all/Y5wGZG05uicAPscI@mit.edu

					- Ted

P.S.  Converting this into an xfstests test script to test for a
regression of this bug (or a failure to backport this into various
stable kernels) is also left as an exercise to the reader.  :-)

#!/bin/bash -vx
#
# This reproduces an ext4 bug caused by an unfortunate interaction
# between lazytime updates happening when a file system is being
# unmounted and expand_extra_isize
#
# Initially discovered via syzkaller:
# https://syzkaller.appspot.com/bug?id=3613786cb88c93aa1c6a279b1df6a7b201347d08
#

img=/tmp/foo.img
dir=/mnt
file=$dir/file0

rm -f $img
mke2fs -Fq -t ext4 -I 256 -O ea_inode -b 1024 $img 200k
mount $img $dir
v=$(dd if=/dev/zero bs=2000 count=1 2>/dev/null | tr '\0' =)
touch $file
attr -q -s test -V $v $file
umount $dir
mount -o debug_want_extra_isize=128,lazytime /tmp/foo.img $dir
cat $file
umount $dir

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ