Skip to contentSkip to conversation

Patch "lib/mpi: kunmap after finishing accessing buffer" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Sep 4, 2017 Stable branch

lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

lib/mpi: kunmap after finishing accessing buffer

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
lib-mpi-kunmap-after-finishing-accessing-buffer.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From dea3eb8b452e36cf2dd572b0a797915ccf452ae6 Mon Sep 17 00:00:00 2001

From: Stephan Mueller <[email protected]>
Date: Thu, 10 Aug 2017 08:06:18 +0200
Subject: lib/mpi: kunmap after finishing accessing buffer

From: Stephan Mueller <[email protected]>

commit dea3eb8b452e36cf2dd572b0a797915ccf452ae6 upstream.

Using sg_miter_start and sg_miter_next, the buffer of an SG is kmap'ed to *buff. The current code calls sg_miter_stop (and thus kunmap) on the SG entry before the last access of *buff.

The patch moves the sg_miter_stop call after the last access to *buff to ensure that the memory pointed to by *buff is still mapped.

Fixes 4816c9406430 ("lib/mpi: Fix SG miter leak")
---
 lib/mpi/mpicoder.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/mpi/mpicoder.c +3 -1
@@ -364,11 +364,11 @@ MPI mpi_read_raw_from_sgl(struct scatter
 	}
 
 	miter.consumed = lzeros;
-	sg_miter_stop(&miter);
 
 	nbytes -= lzeros;
 	nbits = nbytes * 8;
 	if (nbits > MAX_EXTERN_MPI_BITS) {
+		sg_miter_stop(&miter);
 		pr_info("MPI: mpi too large (%u bits)\n", nbits);
 		return NULL;
 	}
@@ -376,6 +376,8 @@ MPI mpi_read_raw_from_sgl(struct scatter
 	if (nbytes > 0)
 		nbits -= count_leading_zeros(*buff) - (BITS_PER_LONG - 8);
 
+	sg_miter_stop(&miter);
+
 	nlimbs = DIV_ROUND_UP(nbytes, BYTES_PER_MPI_LIMB);
 	val = mpi_alloc(nlimbs);
 	if (!val)

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/crypto-algif_skcipher-only-call-put_page-on-referenced-and-used-pages.patch queue-4.9/lib-mpi-kunmap-after-finishing-accessing-buffer.patch