]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.128/partitions-aix-append-null-character-to-print-data-from-disk.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.9.128 / partitions-aix-append-null-character-to-print-data-from-disk.patch
CommitLineData
13e8e92f
GKH
1From foo@baz Mon Sep 17 12:22:41 CEST 2018
2From: Mauricio Faria de Oliveira <mfo@canonical.com>
3Date: Wed, 25 Jul 2018 22:46:29 -0300
4Subject: partitions/aix: append null character to print data from disk
5
6From: Mauricio Faria de Oliveira <mfo@canonical.com>
7
8[ Upstream commit d43fdae7bac2def8c4314b5a49822cb7f08a45f1 ]
9
10Even if properly initialized, the lvname array (i.e., strings)
11is read from disk, and might contain corrupt data (e.g., lack
12the null terminating character for strings).
13
14So, make sure the partition name string used in pr_warn() has
15the null terminating character.
16
17Fixes: 6ceea22bbbc8 ("partitions: add aix lvm partition support files")
18Suggested-by: Daniel J. Axtens <daniel.axtens@canonical.com>
19Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
20Signed-off-by: Jens Axboe <axboe@kernel.dk>
21Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
22Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23---
24 block/partitions/aix.c | 8 ++++++--
25 1 file changed, 6 insertions(+), 2 deletions(-)
26
27--- a/block/partitions/aix.c
28+++ b/block/partitions/aix.c
29@@ -281,10 +281,14 @@ int aix_partition(struct parsed_partitio
30 next_lp_ix += 1;
31 }
32 for (i = 0; i < state->limit; i += 1)
33- if (lvip[i].pps_found && !lvip[i].lv_is_contiguous)
34+ if (lvip[i].pps_found && !lvip[i].lv_is_contiguous) {
35+ char tmp[sizeof(n[i].name) + 1]; // null char
36+
37+ snprintf(tmp, sizeof(tmp), "%s", n[i].name);
38 pr_warn("partition %s (%u pp's found) is "
39 "not contiguous\n",
40- n[i].name, lvip[i].pps_found);
41+ tmp, lvip[i].pps_found);
42+ }
43 kfree(pvd);
44 }
45 kfree(n);