Bug 244584 - netstat -sz clears igmp version in kernel memory. Subsequent netstat -s reports igmp version error
Summary: netstat -sz clears igmp version in kernel memory. Subsequent netstat -s repo...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Hiroki Sato
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-03 22:05 UTC by ghuckriede
Modified: 2024-01-20 22:17 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ghuckriede 2020-03-03 22:05:45 UTC
Overview:
When netstat clears the socket stats it causes the igmp version to be cleared also.  This causes the display of the igmp stats to display an error.


Steps to Reproduce:
# netstat -sz
# netstat -sp igmp


Actual Results:
After running netstat with "-sz" any subsequent display of the igmp protocol will result in the following error messages being displayed
netstat: igmp_stats: version mismatch (0 != 3)


Expected Results:
No error message after clearing stats


Build Date & Hardware:
12.0
FreeBSD FreeBSD_12.0_ghuckriede 12.0-RELEASE-p3 FreeBSD 12.0-RELEASE-p3 GENERIC  amd64

HEAD
uname -a
FreeBSD FreeBSD_head_ghuckriede 13.0-CURRENT FreeBSD 13.0-CURRENT #2 r358592: Tue Mar  3 15:38:05 EST 2020     ghuckriede@FreeBSD_head_ghuckriede:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64


Additional Information:
Using a debugger shows that the entire igmpstat structure is getting cleared after the netstat -sz command.

The define for igmpstat is here https://svnweb.freebsd.org/base/head/sys/netinet/igmp.c?revision=358013&view=markup&pathrev=358013#l234
Comment 1 Hiroki Sato freebsd_committer freebsd_triage 2020-03-03 22:17:45 UTC
Take.
Comment 2 commit-hook freebsd_committer freebsd_triage 2020-03-07 08:41:26 UTC
A commit references this bug:

Author: hrs
Date: Sat Mar  7 08:41:11 UTC 2020
New revision: 358730
URL: https://svnweb.freebsd.org/changeset/base/358730

Log:
  Fix an issue of net.inet.igmp.stats handler.
  The header of (struct igmpstat) could be cleared by sysctl(3).
  This can be reproduced by "netstat -s -z -p igmp".

  PR:	244584
  MFC after:	1 week

Changes:
  head/sys/netinet/igmp.c
  head/usr.bin/netstat/inet.c
Comment 3 Ed Maste freebsd_committer freebsd_triage 2021-11-04 17:29:45 UTC
Was committed prior to stable/13 branch, not merged to stable/12.

hrs@ should we merge it there too?