zram: pass down the bvec we need to read into in the work struct
Subsystems (3)
PATCH 1/1 zram: pass down the bvec we need to read into in the work struct
From: Jérôme Glisse <[email protected]>
When scheduling work item to read page we need to pass down the proper bvec struct which point to the page to read into. Before this patch it uses randomly initialized bvec (only if PAGE_SIZE != 4096) which is wrong.
--- drivers/block/zram/zram_drv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/block/zram/zram_drv.c +3 -2
@@ -774,18 +774,18 @@ struct zram_work {struct zram *zram;unsigned long entry;struct bio *bio; +struct bio_vec bvec; };#if PAGE_SIZE !=4096 static void zram_sync_read (struct work_struct *work) { -struct bio_vec bvec; struct zram_work *zw = container_of(work, struct zram_work, work);struct zram *zram = zw->zram;unsigned long entry = zw->entry;struct bio *bio = zw->bio; -read_from_bdev_async (zram, &bvec, entry, bio); +read_from_bdev_async (zram, &zw->bvec, entry, bio); }/*
@@ -798,6 +798,7 @@ static int read_from_bdev_sync(struct zram *zram, struct bio_vec *bvec, {struct zram_work work; + work.bvec = *bvec; work.zram = zram; work.entry = entry; work.bio = bio;
Signature · 1 line
2.20.1
Adding more Cc and stable (i thought this was 5.1 addition). Note that without this patch on arch/kernel where PAGE_SIZE != 4096 userspace could read random memory through a zram block device (thought userspace probably would have no control on the address being read).
Quoted 52 lines · On Mon, Apr 08, 2019 at 02:32:19PM -0400, [email protected] wrote:
From: Jérôme Glisse <[email protected]>
When scheduling work item to read page we need to pass down the proper bvec struct which point to the page to read into. Before this patch it uses randomly initialized bvec (only if
PAGE_SIZE!= 4096) which is wrong.Signed-off-by Jérôme Glisse <[email protected]>Cc Minchan Kim <[email protected]>Cc Nitin Gupta <[email protected]>Cc Sergey Senozhatsky <[email protected]>--- drivers/block/zram/zram_drv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/block/zram/zram_drv.c +3
-2@@ -774,18 +774,18 @@ struct zram_work {struct zram *zram;unsigned long entry;struct bio *bio; +struct bio_vec bvec; };#if PAGE_SIZE !=4096 static void zram_sync_read (struct work_struct *work) { -struct bio_vec bvec; struct zram_work *zw = container_of(work, struct zram_work, work);struct zram *zram = zw->zram;unsigned long entry = zw->entry;struct bio *bio = zw->bio; -read_from_bdev_async (zram, &bvec, entry, bio); +read_from_bdev_async (zram, &zw->bvec, entry, bio); }/* @@ -798,6 +798,7 @@ static int read_from_bdev_sync(struct zram *zram, struct bio_vec *bvec, {struct zram_work work; + work.bvec = *bvec; work.zram = zram; work.entry = entry; work.bio = bio;Signature · 1 line
2.20.1
Andrew Morton
Reviewed-byQuoted 4 lines · On Wed, 10 Apr 2019 15:43:50 -0400 Jerome Glisse <[email protected]> wrote:
Adding more Cc and stable (i thought this was 5.1 addition). Note that without this patch on
arch/kernelwherePAGE_SIZE!= 4096 userspace could read random memory through a zram block device (thought userspace probably would have no control on the address being read).
Looks good to me.
Minchan & Sergey, can you please review?
From: Jérôme Glisse <[email protected]>
Subject: zram: pass down the bvec we need to read into in the work struct
When scheduling work item to read page we need to pass down the proper bvec struct which points to the page to read into. Before this patch it uses a randomly initialized bvec (only if PAGE_SIZE != 4096) which is wrong.
Note that without this patch on arch/kernel where PAGE_SIZE != 4096 userspace could read random memory through a zram block device (thought userspace probably would have no control on the address being read).
---
drivers/block/zram/zram_drv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/block/zram/zram_drv.c renamed from drivers/block/zram/zram_drv.c~zram-pass-down-the-bvec-we-need-to-read-into-in-the-work-struct +3 -2
@@ -774,18 +774,18 @@ struct zram_work {struct zram *zram;unsigned long entry;struct bio *bio; +struct bio_vec bvec; };#if PAGE_SIZE !=4096 static void zram_sync_read (struct work_struct *work) { -struct bio_vec bvec; struct zram_work *zw = container_of(work, struct zram_work, work);struct zram *zram = zw->zram;unsigned long entry = zw->entry;struct bio *bio = zw->bio; -read_from_bdev_async (zram, &bvec, entry, bio); +read_from_bdev_async (zram, &zw->bvec, entry, bio); }/*
@@ -798,6 +798,7 @@ static int read_from_bdev_sync(struct zr {struct zram_work work; + work.bvec = *bvec; work.zram = zram; work.entry = entry; work.bio = bio;
_
Sergey Senozhatsky
Reviewed-byQuoted 8 lines · Andrew Morton
Quoted 4 lines
Adding more Cc and stable (i thought this was 5.1 addition). Note that without this patch on
arch/kernelwherePAGE_SIZE!= 4096 userspace could read random memory through a zram block device (thought userspace probably would have no control on the address being read).Looks good to me.
Minchan & Sergey, can you please review?
Sorry.
Looks OK to me.
-ss