Skip to content

Commit 7d35a60

Browse files
committed
Merge: block: initialize integrity buffer to zero before writing it to media
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5088 JIRA: https://issues.redhat.com/browse/RHEL-54768 CVE: CVE-2024-43854 Signed-off-by: Ming Lei <ming.lei@redhat.com> Approved-by: Jeff Moyer <jmoyer@redhat.com> Approved-by: John B. Wyatt IV <jwyatt@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2 parents 9fca874 + 9106ac8 commit 7d35a60

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

block/bio-integrity.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ bool bio_integrity_prep(struct bio *bio)
217217
unsigned long start, end;
218218
unsigned int len, nr_pages;
219219
unsigned int bytes, offset, i;
220+
gfp_t gfp = GFP_NOIO;
220221

221222
if (!bi)
222223
return true;
@@ -239,11 +240,19 @@ bool bio_integrity_prep(struct bio *bio)
239240
if (!bi->profile->generate_fn ||
240241
!(bi->flags & BLK_INTEGRITY_GENERATE))
241242
return true;
243+
244+
/*
245+
* Zero the memory allocated to not leak uninitialized kernel
246+
* memory to disk. For PI this only affects the app tag, but
247+
* for non-integrity metadata it affects the entire metadata
248+
* buffer.
249+
*/
250+
gfp |= __GFP_ZERO;
242251
}
243252

244253
/* Allocate kernel buffer for protection data */
245254
len = bio_integrity_bytes(bi, bio_sectors(bio));
246-
buf = kmalloc(len, GFP_NOIO);
255+
buf = kmalloc(len, gfp);
247256
if (unlikely(buf == NULL)) {
248257
printk(KERN_ERR "could not allocate integrity buffer\n");
249258
goto err_end_io;

0 commit comments

Comments
 (0)