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  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:   Mon, 29 Jun 2020 13:38:47 -0600
From:   Andreas Dilger <adilger@...ger.ca>
To:     zhengliang <zhengliang6@...wei.com>
Cc:     "Theodore Y. Ts'o" <tytso@....edu>,
        Ext4 Developers List <linux-ext4@...r.kernel.org>
Subject: Re: [PATCH] ext4: lost matching-pair of trace in ext4_truncate

On Jun 28, 2020, at 8:13 PM, zhengliang <zhengliang6@...wei.com> wrote:
> 
> If truncate inline data successfully, it shoule call trace exit.
> 
> Signed-off-by: zhengliang <zhengliang6@...wei.com>
> ---
> fs/ext4/inode.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index e416096fc081..6d24ed658e30 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4171,8 +4171,10 @@ int ext4_truncate(struct inode *inode)
> 		err = ext4_inline_data_truncate(inode, &has_inline);
> 		if (err)
> 			return err;
> -		if (has_inline)
> +		if (has_inline) {
> +			trace_ext4_truncate_exit(inode);
> 			return 0;
> +		}
> 	}

This only handles one of many similar cases in this function.  That is why
the preferred code style is to have a single exit path with labels that
handle the cleanup in reverse order from the setup.  This avoids the need
to have multiple copies of the cleanup code in each error case, and avoids
bugs where some of the cleanup steps are missed.  Something like:

	trace_ext4_truncate_enter(inode);

        if (!ext4_can_truncate(inode))
                goto out_trace;

        ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS);

        if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
                ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);

        if (ext4_has_inline_data(inode)) {
                int has_inline = 1;

                err = ext4_inline_data_truncate(inode, &has_inline);
                if (err || has_inline)
			goto out_trace;
        }

        /* If we zero-out tail of the page, we have to create jinode for jbd2 */
        if (inode->i_size & (inode->i_sb->s_blocksize - 1)) {
                if (ext4_inode_attach_jinode(inode) < 0)
                        goto out_trace;
        }

        handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits);
        if (IS_ERR(handle)) {
                err = PTR_ERR(handle);
		goto out_trace;
	}
	:
	:

out_trace:
	trace_ext4_truncate_exit(inode);
	return err;

Cheers, Andreas






Download attachment "signature.asc" of type "application/pgp-signature" (874 bytes)

Powered by blists - more mailing lists