Bug 195445 - bsnmpd returns wrong data in ipAddrTable
Summary: bsnmpd returns wrong data in ipAddrTable
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.1-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Bjoern A. Zeeb
URL:
Keywords: regression
: 203264 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-11-27 10:23 UTC by wolfgang
Modified: 2017-06-11 15:50 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wolfgang 2014-11-27 10:23:20 UTC
On all 10.1-STABLE machines that I tested, bsnmpd returns the same wrong data in ipAddrTable:

$ bsnmpwalk -v 2c -s reader@juno.lyx ipAddrTable
ipAdEntAddr[0.0.0.0] = 0.0.0.0
ipAdEntIfIndex[0.0.0.0] = 1
ipAdEntNetMask[0.0.0.0] = 48.0.0.0
ipAdEntBcastAddr[0.0.0.0] = 0
ipAdEntReasmMaxSize[0.0.0.0] = 65535

This appears to be a regression. Testing against a machine running 8.4-STABLE yields correct ip address for the interfaces.
Comment 1 wolfgang 2015-02-10 22:18:51 UTC
I have tested this on i386, amd64 and mips platforms so far, doesn't work on either one using 10.1-STABLE. All amd64 machines have the output as in the PR, i386 and mips give ipAdEntNetMask[0.0.0.0] = 0.0.0.0 instead.
My only test machine with 8.4-STABLE is an i386, there it works ok.
Comment 2 cb 2016-01-10 03:38:50 UTC
The regression was introduced in r228571, which was copied to the 10-STABLE branch when it was created, but not merged to 9.

http://svnweb.freebsd.org/base/head/contrib/bsnmp/snmp_mibII/mibII.c?r1=228623&r2=228622&pathrev=228623

That change can't possibly work, because struct ifa_msghdr is just the header, and does not include the payload of the message, which the IP addresses are extracted from.

Reverting it fixes the problem for me on amd64 and i386. Presumably it may also cause bsnmpd to fault on architectures with strict alignment requirements.
Comment 3 cb 2016-01-10 03:46:04 UTC
Meant to type r228623 -- the link is correct however.
Comment 4 Bjoern A. Zeeb freebsd_committer 2016-01-23 15:32:44 UTC
Can you try this patch please?

https://people.freebsd.org/~bz/20160123-01-bsnmp-mibII.diff
Comment 5 wolfgang 2016-01-23 16:57:35 UTC
I've tested the patch on 10.2-STABLE with i386 and amd64, both work fine. Will need some time before I can test on mpis64.
Comment 6 commit-hook freebsd_committer 2016-02-03 11:04:26 UTC
A commit references this bug:

Author: bz
Date: Wed Feb  3 11:03:44 UTC 2016
New revision: 295202
URL: https://svnweb.freebsd.org/changeset/base/295202

Log:
  Try to fix a bug introduced in r228623.  We started to copy the ifa_msghdr
  as otherwise platforms with strict alignment would break.  It's unclear
  to me if there's also a problem with access to the address list following
  the structure.  However we never copied the address list after the structure
  and thus are pointing at random memory.  For now just use a pointer to the
  original memory for accessing the address list making it at least work on
  platforms with weak memory access.

  PR:			195445
  Reported by:		wolfgang lyxys.ka.sub.org
  Tested by:		wolfgang lyxys.ka.sub.org (x86)
  MFC after:		3 days

Changes:
  head/contrib/bsnmp/snmp_mibII/mibII.c
Comment 7 commit-hook freebsd_committer 2016-02-07 22:53:26 UTC
A commit references this bug:

Author: bz
Date: Sun Feb  7 22:53:04 UTC 2016
New revision: 295386
URL: https://svnweb.freebsd.org/changeset/base/295386

Log:
  MFC r295202:

   Try to fix a bug introduced in r228623 (head).
   We started to copy the ifa_msghdr as otherwise platforms with strict
   alignment would break.  It is unclear to me if there's also a problem with
   access to the address list following the structure.
   However we never copied the address list after the structure and thus are
   pointing at random memory.  For now just use a pointer to the original
   memory for accessing the address list making it at least work on
   platforms with weak memory access.

   PR:                   195445
   Reported by:          wolfgang lyxys.ka.sub.org
   Tested by:            wolfgang lyxys.ka.sub.org (x86)

  Approved by:		re (marius)

Changes:
_U  stable/10/
  stable/10/contrib/bsnmp/snmp_mibII/mibII.c
Comment 8 Eugene Grosbein freebsd_committer 2017-06-11 15:43:22 UTC
Fixed and MFC'd over a year ago.
Comment 9 Eugene Grosbein freebsd_committer 2017-06-11 15:50:14 UTC
*** Bug 203264 has been marked as a duplicate of this bug. ***