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-next>] [day] [month] [year] [list]
Date:	Wed, 23 Apr 2014 16:41:15 +0800
From:	Weijie Yang <weijie.yang@...sung.com>
To:	'Andrew Morton' <akpm@...ux-foundation.org>
Cc:	'Minchan Kim' <minchan@...nel.org>,
	'Nitin Gupta' <ngupta@...are.org>, iamjoonsoo.kim@....com,
	'Sergey Senozhatsky' <sergey.senozhatsky@...il.com>,
	'Bob Liu' <bob.liu@...cle.com>, weijie.yang.kh@...il.com,
	'linux-kernel' <linux-kernel@...r.kernel.org>
Subject: [PATCH RESEND] zram: correct offset usage in zram_bio_discard

We want to skip the physical block(PAGE_SIZE) which is partially
covered by the discard bio, so we check the remaining size and
subtract it if there is a need to goto the next physical block.

The current offset usage in zram_bio_discard is incorrect, it will
cause its upper filesystem breakdown.
Consider the following scenario:
on some architecture or config, PAGE_SIZE is 64K for example,
filesystem is set up on zram disk without PAGE_SIZE aligned,
a discard bio leads to a offset = 4K and size=72K,
normally, it should not really discard any physical block as it
partially cover two physical blocks.
However, with the current offset usage, it will discard the second
physical block and free its memory, which will cause filesystem breakdown.

This patch corrects the offset usage in zram_bio_discard.

Signed-off-by: Weijie Yang <weijie.yang@...sung.com>
Acked-by: Joonsoo Kim <iamjoonsoo.kim@....com>
---
 drivers/block/zram/zram_drv.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 9849b52..48eccb3 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -572,10 +572,10 @@ static void zram_bio_discard(struct zram *zram, u32 index,
 	 * skipping this logical block is appropriate here.
 	 */
 	if (offset) {
-		if (n < offset)
+		if (n <= (PAGE_SIZE - offset))
 			return;
 
-		n -= offset;
+		n -= (PAGE_SIZE - offset);
 		index++;
 	}
 
-- 
1.7.10.4


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