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)
Tue, Oct 29, 7:43 PM
Unknown Object (File)
Tue, Oct 29, 3:23 PM
Unknown Object (File)
Wed, Oct 23, 7:53 PM
Unknown Object (File)
Wed, Oct 23, 7:53 PM
Unknown Object (File)
Wed, Oct 23, 7:52 PM
Unknown Object (File)
Wed, Oct 23, 7:52 PM
Unknown Object (File)
Wed, Oct 23, 7:52 PM
Unknown Object (File)
Wed, Oct 23, 7:31 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
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