Skip to content

Commit 545c980

Browse files
committed
block: initialize integrity buffer to zero before writing it to media
jira LE-3201 cve CVE-2024-43854 Rebuild_History Non-Buildable kernel-rt-4.18.0-553.27.1.rt7.368.el8_10 commit-author Christoph Hellwig <hch@lst.de> commit 899ee2c Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-rt-4.18.0-553.27.1.rt7.368.el8_10/899ee2c3.failed Metadata added by bio_integrity_prep is using plain kmalloc, which leads to random kernel memory being written media. For PI metadata this is limited to the app tag that isn't used by kernel generated metadata, but for non-PI metadata the entire buffer leaks kernel memory. Fix this by adding the __GFP_ZERO flag to allocations for writes. Fixes: 7ba1ba1 ("block: Block layer data integrity support") Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Kanchan Joshi <joshi.k@samsung.com> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Link: https://lore.kernel.org/r/20240613084839.1044015-2-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk> (cherry picked from commit 899ee2c) Signed-off-by: Jonathan Maple <jmaple@ciq.com> # Conflicts: # block/bio-integrity.c
1 parent b06fb0f commit 545c980

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
block: initialize integrity buffer to zero before writing it to media
2+
3+
jira LE-3201
4+
cve CVE-2024-43854
5+
Rebuild_History Non-Buildable kernel-rt-4.18.0-553.27.1.rt7.368.el8_10
6+
commit-author Christoph Hellwig <hch@lst.de>
7+
commit 899ee2c3829c5ac14bfc7d3c4a5846c0b709b78f
8+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
9+
Will be included in final tarball splat. Ref for failed cherry-pick at:
10+
ciq/ciq_backports/kernel-rt-4.18.0-553.27.1.rt7.368.el8_10/899ee2c3.failed
11+
12+
Metadata added by bio_integrity_prep is using plain kmalloc, which leads
13+
to random kernel memory being written media. For PI metadata this is
14+
limited to the app tag that isn't used by kernel generated metadata,
15+
but for non-PI metadata the entire buffer leaks kernel memory.
16+
17+
Fix this by adding the __GFP_ZERO flag to allocations for writes.
18+
19+
Fixes: 7ba1ba12eeef ("block: Block layer data integrity support")
20+
Signed-off-by: Christoph Hellwig <hch@lst.de>
21+
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
22+
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
23+
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
24+
Link: https://lore.kernel.org/r/20240613084839.1044015-2-hch@lst.de
25+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
26+
(cherry picked from commit 899ee2c3829c5ac14bfc7d3c4a5846c0b709b78f)
27+
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
28+
29+
# Conflicts:
30+
# block/bio-integrity.c
31+
diff --cc block/bio-integrity.c
32+
index f4b9fc182299,af7f71d16114..000000000000
33+
--- a/block/bio-integrity.c
34+
+++ b/block/bio-integrity.c
35+
@@@ -221,8 -432,7 +221,12 @@@ bool bio_integrity_prep(struct bio *bio
36+
unsigned long start, end;
37+
unsigned int len, nr_pages;
38+
unsigned int bytes, offset, i;
39+
++<<<<<<< HEAD
40+
+ unsigned int intervals;
41+
+ blk_status_t status;
42+
++=======
43+
+ gfp_t gfp = GFP_NOIO;
44+
++>>>>>>> 899ee2c3829c (block: initialize integrity buffer to zero before writing it to media)
45+
46+
if (!bi)
47+
return true;
48+
@@@ -245,13 -455,19 +249,26 @@@
49+
if (!bi->profile->generate_fn ||
50+
!(bi->flags & BLK_INTEGRITY_GENERATE))
51+
return true;
52+
+
53+
+ /*
54+
+ * Zero the memory allocated to not leak uninitialized kernel
55+
+ * memory to disk. For PI this only affects the app tag, but
56+
+ * for non-integrity metadata it affects the entire metadata
57+
+ * buffer.
58+
+ */
59+
+ gfp |= __GFP_ZERO;
60+
}
61+
+ intervals = bio_integrity_intervals(bi, bio_sectors(bio));
62+
63+
/* Allocate kernel buffer for protection data */
64+
++<<<<<<< HEAD
65+
+ len = intervals * bi->tuple_size;
66+
+ buf = kmalloc(len, GFP_NOIO | q->bounce_gfp);
67+
+ status = BLK_STS_RESOURCE;
68+
++=======
69+
+ len = bio_integrity_bytes(bi, bio_sectors(bio));
70+
+ buf = kmalloc(len, gfp);
71+
++>>>>>>> 899ee2c3829c (block: initialize integrity buffer to zero before writing it to media)
72+
if (unlikely(buf == NULL)) {
73+
printk(KERN_ERR "could not allocate integrity buffer\n");
74+
goto err_end_io;
75+
* Unmerged path block/bio-integrity.c

0 commit comments

Comments
 (0)