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]
Date:	Wed, 29 Sep 2010 21:52:53 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Dave Chinner <david@...morbit.com>
Cc:	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 07/17] fs: icache atomic inodes_stat

On Wed, 29 Sep 2010 22:18:39 +1000 Dave Chinner <david@...morbit.com> wrote:

> From: Nick Piggin <npiggin@...e.de>
> 
> The inode use statistics are currently protected by the inode_lock.
> Before we can remove the inode_lock, we need to protect these
> counters against races. Do this by converting them to atomic
> counters so they ar enot dependent on any lock at all.

typo

>
> ...
>
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -764,7 +764,8 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
>  	wb->last_old_flush = jiffies;
>  	nr_pages = global_page_state(NR_FILE_DIRTY) +
>  			global_page_state(NR_UNSTABLE_NFS) +
> -			(inodes_stat.nr_inodes - inodes_stat.nr_unused);
> +			(atomic_read(&inodes_stat.nr_inodes) -
> +			atomic_read(&inodes_stat.nr_unused));

race bug.

>  	if (nr_pages) {
>  		struct wb_writeback_work work = {
> @@ -1144,7 +1145,8 @@ void writeback_inodes_sb(struct super_block *sb)
>  	WARN_ON(!rwsem_is_locked(&sb->s_umount));
>  
>  	work.nr_pages = nr_dirty + nr_unstable +
> -			(inodes_stat.nr_inodes - inodes_stat.nr_unused);
> +			(atomic_read(&inodes_stat.nr_inodes) -
> +			atomic_read(&inodes_stat.nr_unused));

and another.

OK, they aren't serious ones.  But known regressions shouldn't be snuck
into the kernel unchangelogged and uncommented :(

>  	bdi_queue_work(sb->s_bdi, &work);
>  	wait_for_completion(&done);
>
> ...
>
> -struct inodes_stat_t {
> -	int nr_inodes;
> -	int nr_unused;
> -	int dummy[5];		/* padding for sysctl ABI compatibility */
> -};
> -
> -
>  #define NR_FILE  8192	/* this can well be larger on a larger system */
>  
>  #define MAY_EXEC 1
> @@ -416,6 +409,12 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
>  			ssize_t bytes, void *private, int ret,
>  			bool is_async);
>  
> +struct inodes_stat_t {
> +	atomic_t nr_inodes;
> +	atomic_t nr_unused;
> +	int dummy[5];		/* padding for sysctl ABI compatibility */
> +};

OK, that's a hack.  The first two "ints" are copied out to userspace. 
This change assumes that sizeof(atomic_t)=4 and that an atomic_t has
the same layout, alignment and padding as an int.

Probably that's true in current kernels and with current architectures
but it's a hack and it's presumptive.

It shouldn't be snuck into the tree unchangelogged and uncommented.

(time passes)

OK, I see that all of this gets reverted later on.  Please update the
changelog so the next reviewer doesn't get fooled.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ