linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] async_pq: Remove VLA usage
@ 2018-06-01 20:20 Kyle Spiers
  2018-06-01 20:54 ` Dan Williams
  0 siblings, 1 reply; 4+ messages in thread
From: Kyle Spiers @ 2018-06-01 20:20 UTC (permalink / raw)
  To: dan.j.williams
  Cc: davem, keescook, ray.jui, vkoul, linux-crypto, linux-kernel,
	linux-raid, Kyle Spiers

In the quest to remove VLAs from the kernel[1], this adjusts the
allocation of coefs and blocks to use the existing maximum values
(with one new define, MAX_DISKS for coefs, and a reuse of the
existing NDISKS for blocks).

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Kyle Spiers <ksspiers@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
---
Switch from kmalloc() coefs and blocks to using maximum values
---
 crypto/async_tx/async_pq.c  | 10 ++++++----
 crypto/async_tx/raid6test.c |  4 +++-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/crypto/async_tx/async_pq.c b/crypto/async_tx/async_pq.c
index 56bd612927ab..80dc567801ec 100644
--- a/crypto/async_tx/async_pq.c
+++ b/crypto/async_tx/async_pq.c
@@ -42,6 +42,8 @@ static struct page *pq_scribble_page;
 #define P(b, d) (b[d-2])
 #define Q(b, d) (b[d-1])
 
+#define MAX_DISKS 255
+
 /**
  * do_async_gen_syndrome - asynchronously calculate P and/or Q
  */
@@ -184,7 +186,7 @@ async_gen_syndrome(struct page **blocks, unsigned int offset, int disks,
 	struct dma_device *device = chan ? chan->device : NULL;
 	struct dmaengine_unmap_data *unmap = NULL;
 
-	BUG_ON(disks > 255 || !(P(blocks, disks) || Q(blocks, disks)));
+	BUG_ON(disks > MAX_DISKS || !(P(blocks, disks) || Q(blocks, disks)));
 
 	if (device)
 		unmap = dmaengine_get_unmap_data(device->dev, disks, GFP_NOWAIT);
@@ -196,7 +198,7 @@ async_gen_syndrome(struct page **blocks, unsigned int offset, int disks,
 	    is_dma_pq_aligned(device, offset, 0, len)) {
 		struct dma_async_tx_descriptor *tx;
 		enum dma_ctrl_flags dma_flags = 0;
-		unsigned char coefs[src_cnt];
+		unsigned char coefs[MAX_DISKS];
 		int i, j;
 
 		/* run the p+q asynchronously */
@@ -299,11 +301,11 @@ async_syndrome_val(struct page **blocks, unsigned int offset, int disks,
 	struct dma_chan *chan = pq_val_chan(submit, blocks, disks, len);
 	struct dma_device *device = chan ? chan->device : NULL;
 	struct dma_async_tx_descriptor *tx;
-	unsigned char coefs[disks-2];
+	unsigned char coefs[MAX_DISKS];
 	enum dma_ctrl_flags dma_flags = submit->cb_fn ? DMA_PREP_INTERRUPT : 0;
 	struct dmaengine_unmap_data *unmap = NULL;
 
-	BUG_ON(disks < 4);
+	BUG_ON(disks < 4 || disks > MAX_DISKS);
 
 	if (device)
 		unmap = dmaengine_get_unmap_data(device->dev, disks, GFP_NOWAIT);
diff --git a/crypto/async_tx/raid6test.c b/crypto/async_tx/raid6test.c
index dad95f45b88f..a5edaabae12a 100644
--- a/crypto/async_tx/raid6test.c
+++ b/crypto/async_tx/raid6test.c
@@ -81,11 +81,13 @@ static void raid6_dual_recov(int disks, size_t bytes, int faila, int failb, stru
 			init_async_submit(&submit, 0, NULL, NULL, NULL, addr_conv);
 			tx = async_gen_syndrome(ptrs, 0, disks, bytes, &submit);
 		} else {
-			struct page *blocks[disks];
+			struct page *blocks[NDISKS];
 			struct page *dest;
 			int count = 0;
 			int i;
 
+			BUG_ON(disks > NDISKS);
+
 			/* data+Q failure.  Reconstruct data from P,
 			 * then rebuild syndrome
 			 */
-- 
2.17.0.921.gf22659ad46-goog

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] async_pq: Remove VLA usage
  2018-06-01 20:20 [PATCH v3] async_pq: Remove VLA usage Kyle Spiers
@ 2018-06-01 20:54 ` Dan Williams
  2018-06-05 16:31   ` Vinod
  2018-06-18 14:47   ` Vinod
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Williams @ 2018-06-01 20:54 UTC (permalink / raw)
  To: Kyle Spiers
  Cc: David Miller, Kees Cook, ray.jui, vkoul, linux-crypto,
	Linux Kernel Mailing List, linux-raid

On Fri, Jun 1, 2018 at 1:20 PM, Kyle Spiers <ksspiers@google.com> wrote:
> In the quest to remove VLAs from the kernel[1], this adjusts the
> allocation of coefs and blocks to use the existing maximum values
> (with one new define, MAX_DISKS for coefs, and a reuse of the
> existing NDISKS for blocks).
>
> [1] https://lkml.org/lkml/2018/3/7/621
>
> Signed-off-by: Kyle Spiers <ksspiers@google.com>
> Reviewed-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Dan Williams <dan.j.williams@intel.com>

Vinod, will you have a chance to pick this and carry through dmaengine.git?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] async_pq: Remove VLA usage
  2018-06-01 20:54 ` Dan Williams
@ 2018-06-05 16:31   ` Vinod
  2018-06-18 14:47   ` Vinod
  1 sibling, 0 replies; 4+ messages in thread
From: Vinod @ 2018-06-05 16:31 UTC (permalink / raw)
  To: Dan Williams
  Cc: Kyle Spiers, David Miller, Kees Cook, ray.jui, linux-crypto,
	Linux Kernel Mailing List, linux-raid

On 01-06-18, 13:54, Dan Williams wrote:
> On Fri, Jun 1, 2018 at 1:20 PM, Kyle Spiers <ksspiers@google.com> wrote:
> > In the quest to remove VLAs from the kernel[1], this adjusts the
> > allocation of coefs and blocks to use the existing maximum values
> > (with one new define, MAX_DISKS for coefs, and a reuse of the
> > existing NDISKS for blocks).
> >
> > [1] https://lkml.org/lkml/2018/3/7/621
> >
> > Signed-off-by: Kyle Spiers <ksspiers@google.com>
> > Reviewed-by: Kees Cook <keescook@chromium.org>
> 
> Reviewed-by: Dan Williams <dan.j.williams@intel.com>
> 
> Vinod, will you have a chance to pick this and carry through dmaengine.git?

Sure will do, but after merge window.

Thanks
-- 
~Vinod

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] async_pq: Remove VLA usage
  2018-06-01 20:54 ` Dan Williams
  2018-06-05 16:31   ` Vinod
@ 2018-06-18 14:47   ` Vinod
  1 sibling, 0 replies; 4+ messages in thread
From: Vinod @ 2018-06-18 14:47 UTC (permalink / raw)
  To: Dan Williams
  Cc: Kyle Spiers, David Miller, Kees Cook, ray.jui, linux-crypto,
	Linux Kernel Mailing List, linux-raid

On 01-06-18, 13:54, Dan Williams wrote:
> On Fri, Jun 1, 2018 at 1:20 PM, Kyle Spiers <ksspiers@google.com> wrote:
> > In the quest to remove VLAs from the kernel[1], this adjusts the
> > allocation of coefs and blocks to use the existing maximum values
> > (with one new define, MAX_DISKS for coefs, and a reuse of the
> > existing NDISKS for blocks).
> >
> > [1] https://lkml.org/lkml/2018/3/7/621
> >
> > Signed-off-by: Kyle Spiers <ksspiers@google.com>
> > Reviewed-by: Kees Cook <keescook@chromium.org>
> 
> Reviewed-by: Dan Williams <dan.j.williams@intel.com>
> 
> Vinod, will you have a chance to pick this and carry through dmaengine.git?

Applied now, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-18 14:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-01 20:20 [PATCH v3] async_pq: Remove VLA usage Kyle Spiers
2018-06-01 20:54 ` Dan Williams
2018-06-05 16:31   ` Vinod
2018-06-18 14:47   ` Vinod

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).