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: <20090819163426.fa90cf9f.akpm@linux-foundation.org>
Date:	Wed, 19 Aug 2009 16:34:26 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	dimitri.gorokhovik@...e.fr
Cc:	David Woodhouse <dwmw2@...radead.org>,
	David Woodhouse <David.Woodhouse@...el.com>,
	Tim Gardner <tim.gardner@...onical.com>,
	Scott James Remnant <scott@...onical.com>,
	Julia Lawall <julia@...u.dk>,
	David Brownell <dbrownell@...rs.sourceforge.net>,
	linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] nftl: fix offset alignments

On Wed, 19 Aug 2009 00:06:28 +0200 (CEST) dimitri.gorokhovik@...e.fr wrote:

> Arithmetic conversion in the mask computation makes the upper word 
> of the second argument passed down to mtd->read_oob(), be always 0
> (assuming 'offs' being a 64-bit signed long long type, and 
> 'mtd->writesize' being a 32-bit unsigned int type). 
> 
> This patch applies over the other one adding masking in nftl_write,
> "nftl: write support is broken".
> 
> Signed-off-by: <dimitri.gorokhovik@...e.fr>
> ---
>  
> diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
> index 665d3eb..d2fd066 100644
> --- a/drivers/mtd/nftlcore.c
> +++ b/drivers/mtd/nftlcore.c
> @@ -135,16 +135,17 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev)
>  int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
>  		  size_t *retlen, uint8_t *buf)
>  {
> +	typeof(offs) mask = mtd->writesize - 1;

I see no reason to use typeof here.  Plain old

	loff_t mask = mtd->writesize - 1;

would be more conventional.

>  	struct mtd_oob_ops ops;
>  	int res;
>  
>  	ops.mode = MTD_OOB_PLACE;
> -	ops.ooboffs = offs & (mtd->writesize - 1);
> +	ops.ooboffs = offs & mask;
>  	ops.ooblen = len;
>  	ops.oobbuf = buf;
>  	ops.datbuf = NULL;
>  
> -	res = mtd->read_oob(mtd, offs & ~(mtd->writesize - 1), &ops);
> +	res = mtd->read_oob(mtd, offs & ~mask, &ops);

yup.

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