From patchwork Thu Jun 27 18:16:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1123565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45ZSm80pTDz9sBp; Fri, 28 Jun 2019 04:17:11 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hgYxH-0003fY-Ch; Thu, 27 Jun 2019 18:17:07 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hgYxF-0003e6-LZ for kernel-team@lists.ubuntu.com; Thu, 27 Jun 2019 18:17:05 +0000 Received: from mail-qt1-f198.google.com ([209.85.160.198]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hgYxF-0000Nv-8S for kernel-team@lists.ubuntu.com; Thu, 27 Jun 2019 18:17:05 +0000 Received: by mail-qt1-f198.google.com with SMTP id s22so3255578qtb.22 for ; Thu, 27 Jun 2019 11:17:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6QJbU90fBPkVagKldf+i8fVWNS2FU9f97T2235E/JMk=; b=RAOYTMgF33R6DXbe98SGTejot+9R4JWR5hSLywkRb+qBxwWSKDf8ZD2EX0tcLb/yN7 qDp48WMLbbbwFcHSYIFYSaNGFY2+FNfOn7SYRcJ2ILiQ9s/sDjfql9ETpyDP4IY6Bswo hiJ6nw9xhtKTgngLljF29/jFYKcYGtEKkNpXrVhg76Iqj+3TIkeHij5oA17n9jfRwQX6 hr1kvaaWqV4yesj+jAYu+AG1SuXmegBzbrkXc0Ek+mDfVa2h5NV/eAFna9UoqbM7+U3q oHHt/udKDlmKCNfK+I8osuj7vCB3Yd880r/XifQgF3HD6233UkjEOQCSxZ37CJV4Na78 slIg== X-Gm-Message-State: APjAAAX0aliqXndGaEypYTR4BV9jDGWrhFmh8z+tdOEOADMmVPMj9vdB 4YtW3uodofdxVF/ODqsKWig0onQE9oBjY8iYB6z/uGNYk+YhDhTSQks1UL7hQriTjdyfNNDUM90 4+BRgxA/ZxmE8ZcGjDZKo9TefwLgAiFT3O2Mmxbnc X-Received: by 2002:a0c:c586:: with SMTP id a6mr4524920qvj.177.1561659424019; Thu, 27 Jun 2019 11:17:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSLEy1Lh5KB60IKUtRLvoLTBlRiEBSvTY/TbWwh6IYhEXH41/3mlWZVHDU/i9gMGaQvNLoVA== X-Received: by 2002:a0c:c586:: with SMTP id a6mr4524900qvj.177.1561659423735; Thu, 27 Jun 2019 11:17:03 -0700 (PDT) Received: from gallifrey.lan ([2804:14c:4e3:4a76:fc8a:de0d:44ad:a288]) by smtp.gmail.com with ESMTPSA id k58sm1443903qtc.38.2019.06.27.11.17.02 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 11:17:03 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [x][PATCH 1/3] bio_copy_from_iter(): get rid of copying iov_iter Date: Thu, 27 Jun 2019 15:16:55 -0300 Message-Id: <20190627181657.17808-2-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190627181657.17808-1-marcelo.cerri@canonical.com> References: <20190627181657.17808-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Al Viro BugLink: http://bugs.launchpad.net/bugs/1834499 we want the one passed to it advanced, anyway Signed-off-by: Al Viro (cherry picked from commit 98a09d6106660ec6e69ff2a6fa14039bd504412b) Signed-off-by: Marcelo Henrique Cerri --- NOTE: This commit is only needed for xenial 4.4. --- block/bio.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/block/bio.c b/block/bio.c index 58921797f2e6..2b0c3c08c0b2 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1022,7 +1022,7 @@ static struct bio_map_data *bio_alloc_map_data(unsigned int iov_count, * Copy all pages from iov_iter to bio. * Returns 0 on success, or error on failure. */ -static int bio_copy_from_iter(struct bio *bio, struct iov_iter iter) +static int bio_copy_from_iter(struct bio *bio, struct iov_iter *iter) { int i; struct bio_vec *bvec; @@ -1033,9 +1033,9 @@ static int bio_copy_from_iter(struct bio *bio, struct iov_iter iter) ret = copy_page_from_iter(bvec->bv_page, bvec->bv_offset, bvec->bv_len, - &iter); + iter); - if (!iov_iter_count(&iter)) + if (!iov_iter_count(iter)) break; if (ret < bvec->bv_len) @@ -1234,9 +1234,11 @@ struct bio *bio_copy_user_iov(struct request_queue *q, */ if (((iter->type & WRITE) && (!map_data || !map_data->null_mapped)) || (map_data && map_data->from_user)) { - ret = bio_copy_from_iter(bio, *iter); + ret = bio_copy_from_iter(bio, iter); if (ret) goto cleanup; + } else { + iov_iter_advance(iter, bio->bi_iter.bi_size); } bio->bi_private = bmd; From patchwork Thu Jun 27 18:16:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1123566 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45ZSm83gHQz9sLt; Fri, 28 Jun 2019 04:17:12 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hgYxI-0003gg-Ls; Thu, 27 Jun 2019 18:17:08 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hgYxH-0003fi-PW for kernel-team@lists.ubuntu.com; Thu, 27 Jun 2019 18:17:07 +0000 Received: from mail-qk1-f198.google.com ([209.85.222.198]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hgYxH-0000OO-37 for kernel-team@lists.ubuntu.com; Thu, 27 Jun 2019 18:17:07 +0000 Received: by mail-qk1-f198.google.com with SMTP id o4so3357343qko.8 for ; Thu, 27 Jun 2019 11:17:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cbOE1irN1UPVpGBtijByK439uXHigtlNBfFQCrKl5mw=; b=hd6ziwP7kZxrbTeMBlVq8guiycnjTPtNfeHJTEP8M7sRcbG8120YAKmk/nlAhO8Y0R cp9+KHyj1YAlAKkkFUSDm0hMk2o/k3zqbbHojzRsvI41D5AfM7nK4vul3Xf2RWnXFBBV fs6llKOx+o5oTbcf76J4jLQdTnf3cHEyadmROFPivXRBBTZx9EvYGrjI3UNePBiVfIBD w6XJA77UMAkLVFN/Pt7hUAti4yeYGA0tm9AT5Ok853vZ2lfJyL+ZAYSVPAG6UWVWzwuu SM7OPhuHoo/GW6zEaxNDAF5acldozOqYcdHPkzsrGUcFFK8G3tgs81Q2/ysX2N7sFhT0 d2Ig== X-Gm-Message-State: APjAAAVdvb3Y2yCaEAltU/eSe1ntLd30KXROpoaH6TRJm2SMkVjVMIuH 4aR7bnZ+IyF0i2wn4OVW8hOwDtGxoITzers1u1U6/3jqla0sjEcRgL+7amNm2Xgs22UsLS8CLnL 4RfGQkJxmL3Sclj4u/7KQKQAkBfuhrgk7TM4OaIOY X-Received: by 2002:ac8:124c:: with SMTP id g12mr4229115qtj.57.1561659425827; Thu, 27 Jun 2019 11:17:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8SvnyOkvV2JsinwFEm5TejllJn4g7cvaFOFXQ5GFBYsHSQpMYn/8Ze0wDKB3J+jy7FtAcVg== X-Received: by 2002:ac8:124c:: with SMTP id g12mr4229086qtj.57.1561659425559; Thu, 27 Jun 2019 11:17:05 -0700 (PDT) Received: from gallifrey.lan ([2804:14c:4e3:4a76:fc8a:de0d:44ad:a288]) by smtp.gmail.com with ESMTPSA id k58sm1443903qtc.38.2019.06.27.11.17.03 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 11:17:04 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [c, b, x][PATCH 2/3] block: Clear kernel memory before copying to user Date: Thu, 27 Jun 2019 15:16:56 -0300 Message-Id: <20190627181657.17808-3-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190627181657.17808-1-marcelo.cerri@canonical.com> References: <20190627181657.17808-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Keith Busch BugLink: http://bugs.launchpad.net/bugs/1834499 If the kernel allocates a bounce buffer for user read data, this memory needs to be cleared before copying it to the user, otherwise it may leak kernel memory to user space. Laurence Oberman Signed-off-by: Keith Busch Signed-off-by: Jens Axboe (cherry picked from commit f3587d76da05f68098ddb1cb3c98cc6a9e8a402c) Signed-off-by: Marcelo Henrique Cerri --- block/bio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/bio.c b/block/bio.c index 2b0c3c08c0b2..b1d7e1de7b1a 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1238,6 +1238,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q, if (ret) goto cleanup; } else { + zero_fill_bio(bio); iov_iter_advance(iter, bio->bi_iter.bi_size); } From patchwork Thu Jun 27 18:16:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1123567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45ZSmB494fz9sDn; Fri, 28 Jun 2019 04:17:14 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hgYxK-0003hz-Rv; Thu, 27 Jun 2019 18:17:10 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hgYxJ-0003hN-Lu for kernel-team@lists.ubuntu.com; Thu, 27 Jun 2019 18:17:09 +0000 Received: from mail-qt1-f199.google.com ([209.85.160.199]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hgYxI-0000Oc-UJ for kernel-team@lists.ubuntu.com; Thu, 27 Jun 2019 18:17:09 +0000 Received: by mail-qt1-f199.google.com with SMTP id k8so3279104qtb.12 for ; Thu, 27 Jun 2019 11:17:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NPTlwwXtyFCzFQugIIjanEP7pOtrg6STCKGFr2H6m4k=; b=tMSM9KACtO7/A5vz5x6uLqFInJqtzNsubbVTZbWlr0EseJy1YsFsMFg1FZgRAFbeGX /kec6WgF/71HpaYNlfcbkKA7nVm82XKou9GUhn3Jvo2EVYF2CtXA41AIr8mtagfyxa8O IX1Xb2/S77E9oNB2tvypt4MenVPXQHXdjGGbLWKOzSPz98+B9xpDKgB4laU5lcAWLxBV QBJxZT9CcqiaEgYlBl/nBtAs+P4WX/V/c/DkjEKv+66/yT6I+UNtwBwQsEm9PDlaLUXB G62jWUU0tWCFC11LGt76tDat6ATd1suomCzg+Fdu+YxA3eBQunTNFdZrwKKYA2C7amdA EkEw== X-Gm-Message-State: APjAAAXUanM+YyuIYd9RWPZL0111uTUJzel9DPENWfcYeWghpBJNul/x ZiZI3OxUx/jg+xTOkjR5dYI2pLGoplGaCETro/4/Lq1S/ILGpAlJQ4Z5xD1yUOk/1T/ipWaa8py T1qaLl2RlVhghMD7rteM694zkfc86Ugugt/tHnd6V X-Received: by 2002:a37:ac14:: with SMTP id e20mr4694736qkm.243.1561659427688; Thu, 27 Jun 2019 11:17:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLdSY/wWern0O7yyjUFkdK/v7IZ2uGmcAthxA05IOIAGlKYsAxc63VSEtuwKvFz8K4SKPAMA== X-Received: by 2002:a37:ac14:: with SMTP id e20mr4694715qkm.243.1561659427390; Thu, 27 Jun 2019 11:17:07 -0700 (PDT) Received: from gallifrey.lan ([2804:14c:4e3:4a76:fc8a:de0d:44ad:a288]) by smtp.gmail.com with ESMTPSA id k58sm1443903qtc.38.2019.06.27.11.17.05 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 11:17:06 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [c,b,x][PATCH 3/3] block/bio: Do not zero user pages Date: Thu, 27 Jun 2019 15:16:57 -0300 Message-Id: <20190627181657.17808-4-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190627181657.17808-1-marcelo.cerri@canonical.com> References: <20190627181657.17808-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Keith Busch BugLink: http://bugs.launchpad.net/bugs/1834499 We don't need to zero fill the bio if not using kernel allocated pages. Fixes: f3587d76da05 ("block: Clear kernel memory before copying to user") # v4.20-rc2 Reported-by: Todd Aiken Cc: Laurence Oberman Cc: stable@vger.kernel.org Cc: Bart Van Assche Tested-by: Laurence Oberman Signed-off-by: Keith Busch Signed-off-by: Jens Axboe (cherry picked from commit f55adad601c6a97c8c9628195453e0fb23b4a0ae) Signed-off-by: Marcelo Henrique Cerri --- block/bio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index b1d7e1de7b1a..7dfa9acf1482 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1238,7 +1238,8 @@ struct bio *bio_copy_user_iov(struct request_queue *q, if (ret) goto cleanup; } else { - zero_fill_bio(bio); + if (bmd->is_our_pages) + zero_fill_bio(bio); iov_iter_advance(iter, bio->bi_iter.bi_size); }