* FAILED: patch "[PATCH] dm verity: fix crash on bufio buffer that was allocated with" failed to apply to 4.14-stable tree
@ 2018-09-23 19:17 gregkh
2018-12-23 19:23 ` Sudip Mukherjee
0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2018-09-23 19:17 UTC (permalink / raw)
To: mpatocka, jin.xiao, snitzer; +Cc: stable
The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
>From e4b069e0945fa14c71cf8b5b89f8b1b2aa68dbc2 Mon Sep 17 00:00:00 2001
From: Mikulas Patocka <mpatocka@redhat.com>
Date: Wed, 22 Aug 2018 12:45:51 -0400
Subject: [PATCH] dm verity: fix crash on bufio buffer that was allocated with
vmalloc
Since commit d1ac3ff008fb ("dm verity: switch to using asynchronous hash
crypto API") dm-verity uses asynchronous crypto calls for verification,
so that it can use hardware with asynchronous processing of crypto
operations.
These asynchronous calls don't support vmalloc memory, but the buffer data
can be allocated with vmalloc if dm-bufio is short of memory and uses a
reserved buffer that was preallocated in dm_bufio_client_create().
Fix verity_hash_update() so that it deals with vmalloc'd memory
correctly.
Reported-by: "Xiao, Jin" <jin.xiao@intel.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: d1ac3ff008fb ("dm verity: switch to using asynchronous hash crypto API")
Cc: stable@vger.kernel.org # 4.12+
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index 12decdbd722d..fc65f0dedf7f 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -99,10 +99,26 @@ static int verity_hash_update(struct dm_verity *v, struct ahash_request *req,
{
struct scatterlist sg;
- sg_init_one(&sg, data, len);
- ahash_request_set_crypt(req, &sg, NULL, len);
-
- return crypto_wait_req(crypto_ahash_update(req), wait);
+ if (likely(!is_vmalloc_addr(data))) {
+ sg_init_one(&sg, data, len);
+ ahash_request_set_crypt(req, &sg, NULL, len);
+ return crypto_wait_req(crypto_ahash_update(req), wait);
+ } else {
+ do {
+ int r;
+ size_t this_step = min_t(size_t, len, PAGE_SIZE - offset_in_page(data));
+ flush_kernel_vmap_range((void *)data, this_step);
+ sg_init_table(&sg, 1);
+ sg_set_page(&sg, vmalloc_to_page(data), this_step, offset_in_page(data));
+ ahash_request_set_crypt(req, &sg, NULL, this_step);
+ r = crypto_wait_req(crypto_ahash_update(req), wait);
+ if (unlikely(r))
+ return r;
+ data += this_step;
+ len -= this_step;
+ } while (len);
+ return 0;
+ }
}
/*
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] dm verity: fix crash on bufio buffer that was allocated with" failed to apply to 4.14-stable tree
2018-09-23 19:17 FAILED: patch "[PATCH] dm verity: fix crash on bufio buffer that was allocated with" failed to apply to 4.14-stable tree gregkh
@ 2018-12-23 19:23 ` Sudip Mukherjee
2019-01-02 16:04 ` Mikulas Patocka
0 siblings, 1 reply; 4+ messages in thread
From: Sudip Mukherjee @ 2018-12-23 19:23 UTC (permalink / raw)
To: gregkh, Mike Snitzer, Mikulas Patocka; +Cc: jin.xiao, stable
[-- Attachment #1: Type: text/plain, Size: 439 bytes --]
Hi Greg,
On Sun, Sep 23, 2018 at 09:17:16PM +0200, gregkh@linuxfoundation.org wrote:
>
> The patch below does not apply to the 4.14-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
The attached backported patch will apply to 4.14-stable tree. But I will
want to for an ack.
--
Regards
Sudip
[-- Attachment #2: 0001-dm-verity-fix-crash-on-bufio-buffer-that-was-allocat.patch --]
[-- Type: text/x-diff, Size: 2412 bytes --]
From 3027f3f3f9c61c4b870c23096050dd948ac2ceb1 Mon Sep 17 00:00:00 2001
From: Mikulas Patocka <mpatocka@redhat.com>
Date: Wed, 22 Aug 2018 12:45:51 -0400
Subject: [PATCH] dm verity: fix crash on bufio buffer that was allocated with
vmalloc
commit e4b069e0945fa14c71cf8b5b89f8b1b2aa68dbc2 upstream
Since commit d1ac3ff008fb ("dm verity: switch to using asynchronous hash
crypto API") dm-verity uses asynchronous crypto calls for verification,
so that it can use hardware with asynchronous processing of crypto
operations.
These asynchronous calls don't support vmalloc memory, but the buffer data
can be allocated with vmalloc if dm-bufio is short of memory and uses a
reserved buffer that was preallocated in dm_bufio_client_create().
Fix verity_hash_update() so that it deals with vmalloc'd memory
correctly.
Reported-by: "Xiao, Jin" <jin.xiao@intel.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: d1ac3ff008fb ("dm verity: switch to using asynchronous hash crypto API")
Cc: stable@vger.kernel.org # 4.12+
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
drivers/md/dm-verity-target.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index bda3caca23ca..8573c70a1880 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -139,10 +139,26 @@ static int verity_hash_update(struct dm_verity *v, struct ahash_request *req,
{
struct scatterlist sg;
- sg_init_one(&sg, data, len);
- ahash_request_set_crypt(req, &sg, NULL, len);
-
- return verity_complete_op(res, crypto_ahash_update(req));
+ if (likely(!is_vmalloc_addr(data))) {
+ sg_init_one(&sg, data, len);
+ ahash_request_set_crypt(req, &sg, NULL, len);
+ return verity_complete_op(res, crypto_ahash_update(req));
+ } else {
+ do {
+ int r;
+ size_t this_step = min_t(size_t, len, PAGE_SIZE - offset_in_page(data));
+ flush_kernel_vmap_range((void *)data, this_step);
+ sg_init_table(&sg, 1);
+ sg_set_page(&sg, vmalloc_to_page(data), this_step, offset_in_page(data));
+ ahash_request_set_crypt(req, &sg, NULL, this_step);
+ r = verity_complete_op(res, crypto_ahash_update(req));
+ if (unlikely(r))
+ return r;
+ data += this_step;
+ len -= this_step;
+ } while (len);
+ return 0;
+ }
}
/*
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] dm verity: fix crash on bufio buffer that was allocated with" failed to apply to 4.14-stable tree
2018-12-23 19:23 ` Sudip Mukherjee
@ 2019-01-02 16:04 ` Mikulas Patocka
2019-01-10 19:20 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Mikulas Patocka @ 2019-01-02 16:04 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: gregkh, Mike Snitzer, jin.xiao, stable
On Sun, 23 Dec 2018, Sudip Mukherjee wrote:
> Hi Greg,
>
> On Sun, Sep 23, 2018 at 09:17:16PM +0200, gregkh@linuxfoundation.org wrote:
> >
> > The patch below does not apply to the 4.14-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
>
> The attached backported patch will apply to 4.14-stable tree. But I will
> want to for an ack.
>
> --
> Regards
> Sudip
The patch looks correct.
Acked-by: Mikulas Patocka <mpatocka@redhat.com>
Mikulas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] dm verity: fix crash on bufio buffer that was allocated with" failed to apply to 4.14-stable tree
2019-01-02 16:04 ` Mikulas Patocka
@ 2019-01-10 19:20 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2019-01-10 19:20 UTC (permalink / raw)
To: Mikulas Patocka; +Cc: Sudip Mukherjee, Mike Snitzer, jin.xiao, stable
On Wed, Jan 02, 2019 at 11:04:23AM -0500, Mikulas Patocka wrote:
>
>
> On Sun, 23 Dec 2018, Sudip Mukherjee wrote:
>
> > Hi Greg,
> >
> > On Sun, Sep 23, 2018 at 09:17:16PM +0200, gregkh@linuxfoundation.org wrote:
> > >
> > > The patch below does not apply to the 4.14-stable tree.
> > > If someone wants it applied there, or to any other stable or longterm
> > > tree, then please email the backport, including the original git commit
> > > id to <stable@vger.kernel.org>.
> >
> > The attached backported patch will apply to 4.14-stable tree. But I will
> > want to for an ack.
> >
> > --
> > Regards
> > Sudip
>
> The patch looks correct.
>
> Acked-by: Mikulas Patocka <mpatocka@redhat.com>
Thanks, now queued up.
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-10 19:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-23 19:17 FAILED: patch "[PATCH] dm verity: fix crash on bufio buffer that was allocated with" failed to apply to 4.14-stable tree gregkh
2018-12-23 19:23 ` Sudip Mukherjee
2019-01-02 16:04 ` Mikulas Patocka
2019-01-10 19:20 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).