Skip to content

Commit e153abc

Browse files
Jérôme Glissetorvalds
authored andcommitted
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). Link: http://lkml.kernel.org/r/20190408183219.26377-1-jglisse@redhat.com Signed-off-by: Jérôme Glisse <jglisse@redhat.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Acked-by: Minchan Kim <minchan@kernel.org> Cc: Nitin Gupta <ngupta@vflare.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 89c02e6 commit e153abc

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎drivers/block/zram/zram_drv.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,18 +774,18 @@ struct zram_work {
774774
struct zram *zram;
775775
unsigned long entry;
776776
struct bio *bio;
777+
struct bio_vec bvec;
777778
};
778779

779780
#if PAGE_SIZE != 4096
780781
static void zram_sync_read(struct work_struct *work)
781782
{
782-
struct bio_vec bvec;
783783
struct zram_work *zw = container_of(work, struct zram_work, work);
784784
struct zram *zram = zw->zram;
785785
unsigned long entry = zw->entry;
786786
struct bio *bio = zw->bio;
787787

788-
read_from_bdev_async(zram, &bvec, entry, bio);
788+
read_from_bdev_async(zram, &zw->bvec, entry, bio);
789789
}
790790

791791
/*
@@ -798,6 +798,7 @@ static int read_from_bdev_sync(struct zram *zram, struct bio_vec *bvec,
798798
{
799799
struct zram_work work;
800800

801+
work.bvec = *bvec;
801802
work.zram = zram;
802803
work.entry = entry;
803804
work.bio = bio;

0 commit comments

Comments
 (0)