Page MenuHomeFreeBSD

netdump: send key before dump, in case dump fails
ClosedPublic

Authored by vangyzen on Aug 7 2021, 2:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 21 2024, 1:49 AM
Unknown Object (File)
Nov 18 2024, 4:34 PM
Unknown Object (File)
Nov 18 2024, 4:20 PM
Unknown Object (File)
Nov 18 2024, 3:19 PM
Unknown Object (File)
Nov 8 2024, 11:54 AM
Unknown Object (File)
Oct 29 2024, 7:43 PM
Unknown Object (File)
Oct 29 2024, 3:23 PM
Unknown Object (File)
Oct 23 2024, 7:53 PM

Details

Summary

Previously, if an encrypted netdump failed, such as due to a timeout or
network failure, the key was not saved, so a partial dump was
completely useless.

Send the key first, so the partial dump can be decrypted, because even a
partial dump can be useful.

Test Plan

I ran ls in a loop during a netdump and watched netdumpd create the
key file first. Decryption was successful.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 40976
Build 37865: arc lint + arc unit

Event Timeline

sys/kern/kern_shutdown.c
1504

How can this situation arise? keysize will be 0 if kdc is NULL.

sys/netinet/netdump/netdump_client.c
352

Do you need a netdump_cleanup() call in the error paths?

sys/netinet/netdump/netdump_client.c
352

Yup, since line 339 is setting the global pcb.

vangyzen marked 2 inline comments as done.
  • CR feedback: call cleanup on error paths
vangyzen added inline comments.
sys/kern/kern_shutdown.c
1504

This avoids a NULL dereference. In the old code, we dereferenced kdc without testing for NULL. Unfortunately, I don't have more detail, since I made this change locally six months ago, failed to explain this bit in the internal code review, and forgot to upstream it right away. It _seems_ like we should hit it easily. Maybe clang is reordering things enough to accidentally protect us?

sys/netinet/netdump/netdump_client.c
352

Good catch. Thanks.

vangyzen added inline comments.
sys/kern/kern_shutdown.c
1504

Or maybe I made this change purely for symmetry with dump_start, and the NULL dereference would have happened in that function without this extra guard?

sys/kern/kern_shutdown.c
1504

I see. kdc->kdc_dumpkey will just evaluate to (char *)kdc + offsetof(struct kerneldumpcrypto, kdc_dumpkey) because kdc_dumpkey is a VLA, so no dereference happens. Do you have some local changes which invalidate that?

vangyzen added inline comments.
sys/kern/kern_shutdown.c
1504

I see. Thanks. I obviously didn't look that closely at the type. My bad.

As it turns out, key is no longer used in this function, so I'll just remove it.

vangyzen marked an inline comment as done.
  • CR feedback: remove unused "key" local var
This revision is now accepted and ready to land.Aug 11 2021, 1:48 PM