From: Greg Kroah-Hartman Date: Fri, 15 Jan 2021 09:58:05 +0000 (+0100) Subject: 4.4-stable patches X-Git-Tag: v4.4.252~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e440971dfbc988a95371c371c36f4ddda35a8d03;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: spi-pxa2xx-fix-use-after-free-on-unbind.patch ubifs-wbuf-don-t-leak-kernel-memory-to-flash.patch --- diff --git a/queue-4.4/series b/queue-4.4/series index e545840797b..1f6604e4b4f 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -8,3 +8,5 @@ powerpc-fix-incorrect-stw-ux-u-x-instructions-in-__s.patch net-ip-always-refragment-ip-defragmented-packets.patch net-fix-pmtu-check-in-nopmtudisc-mode.patch vmlinux.lds.h-add-pgo-and-autofdo-input-sections.patch +ubifs-wbuf-don-t-leak-kernel-memory-to-flash.patch +spi-pxa2xx-fix-use-after-free-on-unbind.patch diff --git a/queue-4.4/spi-pxa2xx-fix-use-after-free-on-unbind.patch b/queue-4.4/spi-pxa2xx-fix-use-after-free-on-unbind.patch new file mode 100644 index 00000000000..68c0743464d --- /dev/null +++ b/queue-4.4/spi-pxa2xx-fix-use-after-free-on-unbind.patch @@ -0,0 +1,49 @@ +From foo@baz Fri Jan 15 10:50:59 AM CET 2021 +From: Lukas Wunner +Date: Mon, 7 Dec 2020 09:17:05 +0100 +Subject: spi: pxa2xx: Fix use-after-free on unbind + +From: Lukas Wunner + +commit 5626308bb94d9f930aa5f7c77327df4c6daa7759 upstream + +pxa2xx_spi_remove() accesses the driver's private data after calling +spi_unregister_controller() even though that function releases the last +reference on the spi_controller and thereby frees the private data. + +Fix by switching over to the new devm_spi_alloc_master/slave() helper +which keeps the private data accessible until the driver has unbound. + +Fixes: 32e5b57232c0 ("spi: pxa2xx: Fix controller unregister order") +Signed-off-by: Lukas Wunner +Cc: # v2.6.17+: 5e844cc37a5c: spi: Introduce device-managed SPI controller allocation +Cc: # v2.6.17+: 32e5b57232c0: spi: pxa2xx: Fix controller unregister order +Cc: # v2.6.17+ +Link: https://lore.kernel.org/r/5764b04d4a6e43069ebb7808f64c2f774ac6f193.1607286887.git.lukas@wunner.de +Signed-off-by: Mark Brown +[sudip: adjust context] +Signed-off-by: Sudip Mukherjee +Signed-off-by: Greg Kroah-Hartman +--- + drivers/spi/spi-pxa2xx.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/spi/spi-pxa2xx.c ++++ b/drivers/spi/spi-pxa2xx.c +@@ -1479,7 +1479,7 @@ static int pxa2xx_spi_probe(struct platf + return -ENODEV; + } + +- master = spi_alloc_master(dev, sizeof(struct driver_data)); ++ master = devm_spi_alloc_master(dev, sizeof(*drv_data)); + if (!master) { + dev_err(&pdev->dev, "cannot alloc spi_master\n"); + pxa_ssp_free(ssp); +@@ -1619,7 +1619,6 @@ out_error_clock_enabled: + free_irq(ssp->irq, drv_data); + + out_error_master_alloc: +- spi_master_put(master); + pxa_ssp_free(ssp); + return status; + } diff --git a/queue-4.4/ubifs-wbuf-don-t-leak-kernel-memory-to-flash.patch b/queue-4.4/ubifs-wbuf-don-t-leak-kernel-memory-to-flash.patch new file mode 100644 index 00000000000..066e4473416 --- /dev/null +++ b/queue-4.4/ubifs-wbuf-don-t-leak-kernel-memory-to-flash.patch @@ -0,0 +1,70 @@ +From foo@baz Fri Jan 15 10:49:43 AM CET 2021 +From: Richard Weinberger +Date: Mon, 16 Nov 2020 22:05:30 +0100 +Subject: ubifs: wbuf: Don't leak kernel memory to flash + +From: Richard Weinberger + +commit 20f1431160c6b590cdc269a846fc5a448abf5b98 upstream + +Write buffers use a kmalloc()'ed buffer, they can leak +up to seven bytes of kernel memory to flash if writes are not +aligned. +So use ubifs_pad() to fill these gaps with padding bytes. +This was never a problem while scanning because the scanner logic +manually aligns node lengths and skips over these gaps. + +Cc: +Fixes: 1e51764a3c2ac05a2 ("UBIFS: add new flash file system") +Signed-off-by: Richard Weinberger +Reviewed-by: Zhihao Cheng +Signed-off-by: Richard Weinberger +[sudip: adjust context] +Signed-off-by: Sudip Mukherjee +Signed-off-by: Greg Kroah-Hartman +--- + fs/ubifs/io.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +--- a/fs/ubifs/io.c ++++ b/fs/ubifs/io.c +@@ -331,7 +331,7 @@ void ubifs_pad(const struct ubifs_info * + { + uint32_t crc; + +- ubifs_assert(pad >= 0 && !(pad & 7)); ++ ubifs_assert(pad >= 0); + + if (pad >= UBIFS_PAD_NODE_SZ) { + struct ubifs_ch *ch = buf; +@@ -721,6 +721,10 @@ int ubifs_wbuf_write_nolock(struct ubifs + * write-buffer. + */ + memcpy(wbuf->buf + wbuf->used, buf, len); ++ if (aligned_len > len) { ++ ubifs_assert(aligned_len - len < 8); ++ ubifs_pad(c, wbuf->buf + wbuf->used + len, aligned_len - len); ++ } + + if (aligned_len == wbuf->avail) { + dbg_io("flush jhead %s wbuf to LEB %d:%d", +@@ -813,13 +817,18 @@ int ubifs_wbuf_write_nolock(struct ubifs + } + + spin_lock(&wbuf->lock); +- if (aligned_len) ++ if (aligned_len) { + /* + * And now we have what's left and what does not take whole + * max. write unit, so write it to the write-buffer and we are + * done. + */ + memcpy(wbuf->buf, buf + written, len); ++ if (aligned_len > len) { ++ ubifs_assert(aligned_len - len < 8); ++ ubifs_pad(c, wbuf->buf + len, aligned_len - len); ++ } ++ } + + if (c->leb_size - wbuf->offs >= c->max_write_size) + wbuf->size = c->max_write_size;