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)
Feb 19 2024, 1:14 AM
Unknown Object (File)
Feb 15 2024, 5:39 PM
Unknown Object (File)
Dec 26 2023, 9:42 AM
Unknown Object (File)
Dec 21 2023, 7:32 PM
Unknown Object (File)
Dec 20 2023, 3:57 AM
Unknown Object (File)
Nov 28 2023, 6:56 AM
Unknown Object (File)
Nov 20 2023, 12:41 AM
Unknown Object (File)
Nov 20 2023, 12:41 AM

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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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