hst will be nul-terminated but may be followed by uninitialized bytes.
Avoid copying all of them since they are exported to userland via
statfs(2).
Reported by: KMSAN
MFC after: 2 weeks
Differential D31167
nfsclient: Avoid copying uninitialized bytes into statfs markj on Jul 13 2021, 10:45 PM. Authored by Tags None Referenced Files
Subscribers
Details hst will be nul-terminated but may be followed by uninitialized bytes. Reported by: KMSAN
Diff Detail
Event TimelineComment Actions This looks ok to me. It does assume that "mnt_stat" is initialized '0', but that is the case. Alternately, you could add M_ZERO to the malloc() for hst, and then it doesn't matter I'll let you decide which you prefer. Comment Actions I thought about using M_ZERO but I think this approach is more internally consistent: there are other strings allocated when mounting that don't require M_ZERO, and NFS itself doesn't care whether the hostname buffer is zeroed. |