Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98460C43218 for ; Fri, 26 Apr 2019 05:23:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 661AB2084F for ; Fri, 26 Apr 2019 05:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556256223; bh=uWVIYcsvHKQSRI2NmghCzGKRr7eJCuoaCxIe+q8Ss9I=; h=Date:From:To:Subject:List-ID:From; b=uUbMIvUOed9WDooHg3E+qJBRZq1dzLX7UrNiN1JXWF6yZu+8ZLQjIBhZOY0ans4EU jpLsIIjegIPMFrZKek+dRwO8b9fBlNbncnKSoDhszJkuBXCpPvH0UQ4imlZQYjokGP 2tH019wXHVeAYLjqxBie4x0h1GeVCxbttvjHl+ds= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726960AbfDZFXn (ORCPT ); Fri, 26 Apr 2019 01:23:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:48064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725881AbfDZFXm (ORCPT ); Fri, 26 Apr 2019 01:23:42 -0400 Received: from localhost.localdomain (c-73-223-200-170.hsd1.ca.comcast.net [73.223.200.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 905AC2084F; Fri, 26 Apr 2019 05:23:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556256222; bh=uWVIYcsvHKQSRI2NmghCzGKRr7eJCuoaCxIe+q8Ss9I=; h=Date:From:To:Subject:From; b=WBCV5hA2ldJd+YjSF78QdcdQhzcF66Ijla+6OLDE5bxfdp8dk/0nbw+grS9wfpBk+ sYvCdd0z1FFaruH6sS4zk1RnJ33L0mcABBgvn3x+bHdTgH6FCmguAQVbaqpGA+bdwO +7PJEPn9ETQPktl4sPjqOr0+qL62b6yD3DA2s3OI= Date: Thu, 25 Apr 2019 22:23:41 -0700 From: akpm@linux-foundation.org To: akpm@linux-foundation.org, jglisse@redhat.com, minchan@kernel.org, mm-commits@vger.kernel.org, ngupta@vflare.org, sergey.senozhatsky@gmail.com, stable@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 2/9] zram: pass down the bvec we need to read into in the work struct Message-ID: <20190426052341.Bl_ww9dL5%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org =46rom: J=C3=A9r=C3=B4me Glisse 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 !=3D 4096) which is wrong. Note that without this patch on arch/kernel where PAGE_SIZE !=3D 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=C3=A9r=C3=B4me Glisse Reviewed-by: Andrew Morton Reviewed-by: Sergey Senozhatsky Acked-by: Minchan Kim Cc: Nitin Gupta Cc: Signed-off-by: Andrew Morton --- drivers/block/zram/zram_drv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/block/zram/zram_drv.c~zram-pass-down-the-bvec-we-need-to-read= -into-in-the-work-struct +++ a/drivers/block/zram/zram_drv.c @@ -774,18 +774,18 @@ struct zram_work { struct zram *zram; unsigned long entry; struct bio *bio; + struct bio_vec bvec; }; =20 #if PAGE_SIZE !=3D 4096 static void zram_sync_read(struct work_struct *work) { - struct bio_vec bvec; struct zram_work *zw =3D container_of(work, struct zram_work, work); struct zram *zram =3D zw->zram; unsigned long entry =3D zw->entry; struct bio *bio =3D zw->bio; =20 - read_from_bdev_async(zram, &bvec, entry, bio); + read_from_bdev_async(zram, &zw->bvec, entry, bio); } =20 /* @@ -798,6 +798,7 @@ static int read_from_bdev_sync(struct zr { struct zram_work work; =20 + work.bvec =3D *bvec; work.zram =3D zram; work.entry =3D entry; work.bio =3D bio; _