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, 19 Aug 2011 14:17:13 -0400
From:	Josh Boyer <jwboyer@...hat.com>
To:	Al Viro <viro@...IV.linux.org.uk>
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 07:10:54PM +0100, Al Viro wrote:
> 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.

OK.  So just move the blocks calculating into count_free itself.  I'll
rework.

> > +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).

Will fix.

josh
--
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