Page MenuHomeFreeBSD

geom: don't write stack garbage in disk labels
ClosedPublic

Authored by asomers on Feb 2 2018, 5:32 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 26 2024, 12:00 AM
Unknown Object (File)
Sep 25 2024, 9:03 PM
Unknown Object (File)
Sep 24 2024, 9:08 PM
Unknown Object (File)
Sep 24 2024, 9:08 PM
Unknown Object (File)
Sep 24 2024, 9:08 PM
Unknown Object (File)
Sep 24 2024, 9:08 PM
Unknown Object (File)
Sep 22 2024, 5:26 PM
Unknown Object (File)
Sep 19 2024, 12:18 PM
Subscribers

Details

Summary

geom: don't write stack garbage in disk labels

Most consumers of g_metadata_store were passing in partially unallocated
memory, resulting in stack garbage being written to disk labels. Be
more careful to only pass in the true size of the label.

gvirstor repeated the same mistake, but in the kernel.

Also, glabel's label contained a fixed-size string that wasn't
initialized to zero.

PR: 222077

Test Plan

existing geom tests

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

How sure are we that none of these routines are accessing sector past the relevant struct size? Without investigating that, I'd be more comfortable with the lesser change that just zeroed the sector arrays.

sbin/geom/class/label/geom_label.c
148 ↗(On Diff #38772)

this comment can probably be killed?

Zero the sectors the brute force way, without relying on any specific behavior of g_metadata_store

This revision is now accepted and ready to land.Feb 4 2018, 5:59 AM
This revision was automatically updated to reflect the committed changes.