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] [thread-next>] [day] [month] [year] [list]
Message-ID: <87fsl1cvl7.fsf@mail.parknet.co.jp>
Date:   Mon, 23 May 2022 02:42:44 +0900
From:   OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
To:     Javier Martinez Canillas <javierm@...hat.com>
Cc:     linux-kernel@...r.kernel.org, Colin Walters <walters@...bum.org>,
        Peter Jones <pjones@...hat.com>,
        Alexander Larsson <alexl@...hat.com>,
        Alberto Ruiz <aruiz@...hat.com>,
        Christian Kellner <ckellner@...hat.com>,
        Lennart Poettering <lennart@...ttering.net>,
        Chung-Chiang Cheng <cccheng@...ology.com>
Subject: Re: [RFC PATCH 2/3] fat: add renameat2 RENAME_EXCHANGE flag support

Javier Martinez Canillas <javierm@...hat.com> writes:

> The renameat2 RENAME_EXCHANGE flag allows to atomically exchange two paths
> but is currently not supported by the Linux vfat filesystem driver.
>
> Add a vfat_rename_exchange() helper function that implements this support.
>
> The super block lock is acquired during the operation to ensure atomicity,
> and in the error path actions made are reversed also with the mutex held,
> making the whole operation transactional.

I'm not fully reviewed yet though (write order and race), basically
looks like good.

> +	/* if directories are not the same, get ".." info to update */
> +	if (old_dir != new_dir) {
> +		if (S_ISDIR(old_inode->i_mode))
> +			if (fat_get_dotdot_entry(old_inode, &old_dotdot_bh, &old_dotdot_de)) {
> +				err = -EIO;
> +				goto out;
> +			}
> +		if (S_ISDIR(new_inode->i_mode))
> +			if (fat_get_dotdot_entry(new_inode, &new_dotdot_bh, &new_dotdot_de)) {
> +				err = -EIO;
> +				goto out;
> +			}
> +	}

It may not be linux coding style though, please add {}

	if () {
        	...
	}

for non one liner body.

> +	/* update ".." directory entry info */
> +	if (old_dotdot_de) {
> +		fat_set_start(old_dotdot_de, MSDOS_I(new_dir)->i_logstart);
> +		mark_buffer_dirty_inode(old_dotdot_bh, old_inode);
> +		if (IS_DIRSYNC(new_dir)) {
> +			err = sync_dirty_buffer(old_dotdot_bh);
> +			if (err)
> +				goto error_old_dotdot;
> +		}
> +		drop_nlink(old_dir);
> +		inc_nlink(new_dir);
> +	}
> +
> +	if (new_dotdot_de) {
> +		fat_set_start(new_dotdot_de, MSDOS_I(old_dir)->i_logstart);
> +		mark_buffer_dirty_inode(new_dotdot_bh, new_inode);
> +		if (IS_DIRSYNC(old_dir)) {
> +			err = sync_dirty_buffer(new_dotdot_bh);
> +			if (err)
> +				goto error_new_dotdot;
> +		}
> +		drop_nlink(new_dir);
> +		inc_nlink(old_dir);
> +	}

There are some copy&paste codes, for example above, it may be better to
use function and consolidate? If you had some intent, it is ok though.

Thanks.
-- 
OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ