Bug 14966

Summary: patch to zero spare stat fields
Product: Base System Reporter: kbyanc <kbyanc>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.2-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description kbyanc 1999-11-18 01:20:01 UTC
  The stat structure defines 2 spare fields which were filled with random contents from the kernel stack. After
some discussion on freebsd-security
http://docs.freebsd.org/cgi/mid.cgi?db=irt&id=Pine.BSF.4.05.9911171152270.8195-100000@kronos.alcnet.com
  it was suggested that if a program was ever to be able to test for the presence of valid values in new fields
which may use the currently spare space, then we need to zero that space now. This patch zeros the spare fields of
both struct stat and struct nstat (ostat doesn't contain any spare fields) with minimal impact on the code.

  Actually this patch also fixed a slight mistake in the ofstat code which filled in the ostat structure even if
an error occurred. The patch changes ostat to behave more like nfstat and only copy the structure if an error has
not occurred.

  Kelly

Fix: Apply this patch in /sys/kern:
How-To-Repeat: 
  Call stat() twice on a file with an intervening syscall and memcmp the 2 structures you get back. Even if the
file's metadata has not changed, the structures will differ (specifically the spare fields will differ).
Comment 1 Matt Dillon freebsd_committer freebsd_triage 1999-11-18 08:16:08 UTC
State Changed
From-To: open->closed

Patch committed to -current and -stable