Page MenuHomeFreeBSD

tarfs: Fix two input validation issues.
ClosedPublic

Authored by des on Feb 29 2024, 7:47 PM.
Tags
None
Referenced Files
F87382391: D44161.id135257.diff
Tue, Jul 2, 10:16 AM
F87382145: D44161.id135243.diff
Tue, Jul 2, 10:10 AM
F87381781: D44161.id135456.diff
Tue, Jul 2, 10:01 AM
Unknown Object (File)
Sun, Jun 30, 1:04 PM
Unknown Object (File)
Fri, Jun 28, 7:35 AM
Unknown Object (File)
Sat, Jun 22, 8:00 AM
Unknown Object (File)
Mon, Jun 3, 6:31 AM
Unknown Object (File)
May 26 2024, 2:55 PM
Subscribers

Details

Summary
  • Reject hard or soft links with an empty target path. Currently, a debugging kernel will hit an assertion in tarfs_lookup_path() while a non-debugging kernel will happily create a link to the mount root.
  • Use a temporary variable to store the result of the link target path, and copy it to tnp->other only once we have found it to be valid. Otherwise we error out after creating a reference to the target but before incrementing the target's reference count, which results in a use-after-free situation in the cleanup code.
  • Correctly return ENOENT from tarfs_lookup_path() if the requested path was not found and create_dirs is false. Luckily, existing callers did not rely solely on the return value.

MFC after: 3 days
PR: 277360
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 56355
Build 53243: arc lint + arc unit

Event Timeline

des requested review of this revision.Feb 29 2024, 7:47 PM

fix link to nonexistent target

This revision is now accepted and ready to land.Mar 1 2024, 9:48 PM
This revision was automatically updated to reflect the committed changes.