Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4813309yba; Tue, 30 Apr 2019 04:57:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMg9mycj0NM59kLw3xOpa7i1d+rEF9/ap7Z6aepA4t12NEBMgP7gswQ1JZ4DmoP0J3g939 X-Received: by 2002:a17:902:d83:: with SMTP id 3mr71240797plv.125.1556625437188; Tue, 30 Apr 2019 04:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556625437; cv=none; d=google.com; s=arc-20160816; b=oLQvJ3n+GN3e9z0oHWDUPSbhbxo2xoC9D/N7SXqA8RMD7w2tTxITvvRTr1rCTkqHOn KboDf7c+THOFCbi9zFa0mGdbUrbhWBgHc5/bN0pPdE8iidJvd0kUJ9vDqToWFSL5gyso p1aHE/YLxfPIcIHumKj2RJHB7ttu2VXVSvvPwK/JSeA5m3erc9sNqBWtlX0k70q8UzyQ WUHRvi2rCIct84JA3ZNJ27DRUEMQP62Wt5U92Kkr3nuqvwscRLKRn6I6p0+3nxYx/nYQ beL6ikGTEHgZGxAg+a1OmUt6NnlMiKakkkWt0p1GkNvhXrz4vHJiAVuSU0XyOFHEj/JL D8AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2UVyZk4XTYFlaEQcuxt9QlixH/mxywmu0DZoldJNcRs=; b=qVzcSpJMFJpckVp5TtJSl1bWLxthFvsG7vpOhfpWum6u+/beeDSzPsBv/SkA22cC21 RoewE/KWhnivPf8yMPwgXaNIgmeW72/2zS8JwCA1AkkpH/QmJbWcRHcT22nE4AsO3gJq g6OEZorNev7y2OMuqZSrOm1Pwh8bZW5utprQxFI5JLezwmD6BOkNBXejhkbNjlSQMTIr Xf/z8BgmDqkaFA2PzQPgqOrwwixrEFSfOhhdV0dbnQzrTl7Jf5CEkMBllpjA3Wkh2oys GX44NbNg4KAKcCJakAUqze9Hs6E9QN/5KQOHdsf3u2CtrUPfURPByhIfapi3Fia1Fb9/ aHbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Nw8Pw9Ez; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c68si23546510pfa.56.2019.04.30.04.57.02; Tue, 30 Apr 2019 04:57:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Nw8Pw9Ez; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731095AbfD3Ltz (ORCPT + 99 others); Tue, 30 Apr 2019 07:49:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:36590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731083AbfD3Ltz (ORCPT ); Tue, 30 Apr 2019 07:49:55 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 C74B420449; Tue, 30 Apr 2019 11:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556624994; bh=t74Bakk3a87504pVuuIccZKC5EyAKwMCin+kox/pFXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nw8Pw9EzXOyshzr13btzt8+LtMu7qWUcwJYZhL6/F9OzKcoTM8p6fNKsZCi2RzkZK U014Rq4xIrWmrk8lls80ZCeXCMj64/AaztQbw7FBOVdyXHMLZvFKtbWEkcuWODi/7P ZlTzWSHtcISS4irv1Oc4MHRErxy2XIpV2ijbVlls= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Andrew Morton , Sergey Senozhatsky , Minchan Kim , Nitin Gupta , Linus Torvalds Subject: [PATCH 5.0 16/89] zram: pass down the bvec we need to read into in the work struct Date: Tue, 30 Apr 2019 13:38:07 +0200 Message-Id: <20190430113610.433951117@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113609.741196396@linuxfoundation.org> References: <20190430113609.741196396@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jérôme Glisse commit e153abc0739ff77bd89c9ba1688cdb963464af97 upstream. 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 Reviewed-by: Andrew Morton Reviewed-by: Sergey Senozhatsky Acked-by: Minchan Kim Cc: Nitin Gupta Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- drivers/block/zram/zram_drv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/block/zram/zram_drv.c +++ b/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; }; #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;