{"push_id":970858451,"size":1,"distinct_size":1,"ref":"refs/heads/stable/10","head":"cb56e836d9a9db908a5f1e021e6483e1e8aab048","before":"f1429e95c359a7e76f8385cdd47f887b7d1bbd0e","commits":[{"sha":"cb56e836d9a9db908a5f1e021e6483e1e8aab048","author":{"email":"bfed11ad5cdd21dfd9ed695a5c3e9ad4e680f6af@FreeBSD.org","name":"jhb"},"message":"MFC 287442,287537,288944:\nFix corruption of coredumps due to procstat notes changing size during\ncoredump generation.  The changes in r287442 required some reworking\nsince the 'fo_fill_kinfo' file op does not exist in stable/10.\n\n287442:\nDetect badly behaved coredump note helpers\n\nCoredump notes depend on being able to invoke dump routines twice; once\nin a dry-run mode to get the size of the note, and another to actually\nemit the note to the corefile.\n\nWhen a note helper emits a different length section the second time\naround than the length it requested the first time, the kernel produces\na corrupt coredump.\n\nNT_PROCSTAT_FILES output length, when packing kinfo structs, is tied to\nthe length of filenames corresponding to vnodes in the process' fd table\nvia vn_fullpath.  As vnodes may move around during dump, this is racy.\n\nSo:\n\n - Detect badly behaved notes in putnote() and pad underfilled notes.\n\n - Add a fail point, debug.fail_point.fill_kinfo_vnode__random_path to\n   exercise the NT_PROCSTAT_FILES corruption.  It simply picks random\n   lengths to expand or truncate paths to in fo_fill_kinfo_vnode().\n\n - Add a sysctl, kern.coredump_pack_fileinfo, to allow users to\n   disable kinfo packing for PROCSTAT_FILES notes.  This should avoid\n   both FILES note corruption and truncation, even if filenames change,\n   at the cost of about 1 kiB in padding bloat per open fd.  Document\n   the new sysctl in core.5.\n\n - Fix note_procstat_files to self-limit in the 2nd pass.  Since\n   sometimes this will result in a short write, pad up to our advertised\n   size.  This addresses note corruption, at the risk of sometimes\n   truncating the last several fd info entries.\n\n - Fix NT_PROCSTAT_FILES consumers libutil and libprocstat to grok the\n   zero padding.\n\n287537:\nFollow-up to r287442: Move sysctl to compiled-once file\n\nAvoid duplicate sysctl nodes.\n\n288944:\nFix core corruption caused by race in note_procstat_vmmap\n\nThis fix is spiritually similar to r287442 and was discovered thanks to\nthe KASSERT added in that revision.\n\nNT_PROCSTAT_VMMAP output length, when packing kinfo structs, is tied to\nthe length of filenames corresponding to vnodes in the process' vm map\nvia vn_fullpath.  As vnodes may move during coredump, this is racy.\n\nWe do not remove the race, only prevent it from causing coredump\ncorruption.\n\n- Add a sysctl, kern.coredump_pack_vmmapinfo, to allow users to disable\n  kinfo packing for PROCSTAT_VMMAP notes.  This avoids VMMAP corruption\n  and truncation, even if names change, at the cost of up to PATH_MAX\n  bytes per mapped object.  The new sysctl is documented in core.5.\n\n- Fix note_procstat_vmmap to self-limit in the second pass.  This\n  addresses corruption, at the cost of sometimes producing a truncated\n  result.\n\n- Fix PROCSTAT_VMMAP consumers libutil (and libprocstat, via copy-paste)\n  to grok the new zero padding.\n\nApproved by:\tre (gjb)","distinct":true,"url":"https://api.github.com/repos/bsd-hacker/freebsd/commits/cb56e836d9a9db908a5f1e021e6483e1e8aab048"}]}