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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110819181054.GA2203@ZenIV.linux.org.uk>
Date:	Fri, 19 Aug 2011 19:10:54 +0100
From:	Al Viro <viro@...IV.linux.org.uk>
To:	Josh Boyer <jwboyer@...hat.com>
Cc:	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH v2] fs/minix: Verify bitmap block counts before mounting

On Fri, Aug 19, 2011 at 02:02:00PM -0400, Josh Boyer wrote:

> -unsigned long minix_count_free_blocks(struct minix_sb_info *sbi)
> +unsigned long minix_count_free_blocks(struct super_block *sb)
>  {
> -	return (count_free(sbi->s_zmap, sbi->s_zmap_blocks,
> -		sbi->s_nzones - sbi->s_firstdatazone + 1)
> +	struct minix_sb_info *sbi = minix_sb(sb);
> +	u32 bits = sbi->s_nzones - (sbi->s_firstdatazone + 1);
> +	unsigned blocks = minix_blocks_needed(bits, sb->s_blocksize);
> +
> +	return (count_free(sbi->s_zmap, blocks, bits)
>  		<< sbi->s_log_zone_size);
>  }

> +	unsigned blocks = minix_blocks_needed(bits, sb->s_blocksize);
> +
> +	return count_free(sbi->s_imap, blocks, bits);

I'd pass sb->s_blocksize to that sucker instead of blocks; less redundancy
and we have good uses for it there anyway.

> +static inline unsigned minix_blocks_needed(unsigned bits, unsigned blocksize)
> +{
> +	unsigned blocks = bits / (blocksize * 8);
> +
> +	if (bits % (blocksize * 8))
> +		blocks++;
> +	return blocks;
> +}

Yecchh...  The usual idiom for that is DIV_ROUND_UP(bits, blocksize * 8)
(see linux/kernel.h for details).
--
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