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
F153923193: D14164.id38838.diff
Fri, Apr 24, 8:13 PM
F153886297: D14164.id38838.diff
Fri, Apr 24, 1:03 PM
F153835788: D14164.id38838.diff
Fri, Apr 24, 3:22 AM
Unknown Object (File)
Thu, Apr 23, 7:41 PM
Unknown Object (File)
Thu, Apr 23, 12:32 PM
Unknown Object (File)
Tue, Apr 21, 6:16 AM
Unknown Object (File)
Sun, Apr 19, 2:13 AM
Unknown Object (File)
Tue, Apr 14, 1:41 AM
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.