Bug 192544

Summary: [kern] values returned from some net.inet.tcp sysctls broken on CURRENT
Product: Base System Reporter: Enji Cooper <ngie>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Many People CC: emaste, hiren, hps, hselasky, jmg
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Enji Cooper freebsd_committer freebsd_triage 2014-08-10 05:55:10 UTC
hiren@/jmg@ noted that the output from certain sysctls appears to be broken in recent versions of CURRENT. In particular, it seems to be returning a single nul terminated string instead of a full string for net.inet.tcp.cc.algorithm (and friends):

$ uname -o -r
FreeBSD 9.2-RELEASE-p10
$ sysctl net.inet.tcp.cc.algorithm
net.inet.tcp.cc.algorithm: newreno

# uname -a
FreeBSD isilon-fuji-current.local 11.0-CURRENT FreeBSD 11.0-CURRENT #16 r268804+343692e(isilon-atf): Mon Jul 14 12:17:25 PDT 2014     root@isilon-fuji-current.local:/usr/obj/usr/src/sys/FUJI  i386
# sysctl net.inet.tcp.cc.algorithm
net.inet.tcp.cc.algorithm: n

Is some of the new code after recent sysctl(9) refactoring not properly dereferencing memory?
Comment 1 commit-hook freebsd_committer freebsd_triage 2014-08-10 07:52:25 UTC
A commit references this bug:

Author: hselasky
Date: Sun Aug 10 07:51:55 UTC 2014
New revision: 269777
URL: http://svnweb.freebsd.org/changeset/base/269777

Log:
  Fix string length argument passed to "sysctl_handle_string()" so that
  the complete string is returned by the function and not just only one
  byte.

  PR:	192544
  MFC after:	2 weeks

Changes:
  head/sys/netinet/cc/cc.c
Comment 2 Hans Petter Selasky freebsd_committer freebsd_triage 2014-08-10 07:54:01 UTC
Hi, This is a bug in the network driver code and not in the sysctl patch.
Anyhow, please test the patch above.

--HPS
Comment 3 Enji Cooper freebsd_committer freebsd_triage 2014-08-12 02:00:35 UTC
Renaming title to reflect actual issue.
Comment 4 Enji Cooper freebsd_committer freebsd_triage 2014-08-12 02:01:43 UTC
(In reply to Hans Petter Selasky from comment #2)
> Hi, This is a bug in the network driver code and not in the sysctl patch.
> Anyhow, please test the patch above.

The patch looks ok for net.inet.tcp.cc ; I did code inspection for other potential affected areas but I didn't find any [at first glance].
Comment 5 commit-hook freebsd_committer freebsd_triage 2014-08-27 14:08:16 UTC
A commit references this bug:

Author: hselasky
Date: Wed Aug 27 14:07:24 UTC 2014
New revision: 270711
URL: http://svnweb.freebsd.org/changeset/base/270711

Log:
  MFC r269777:
  Fix string length argument passed to "sysctl_handle_string()" so that
  the complete string is returned by the function and not just only one
  byte.

  PR:	192544

Changes:
_U  stable/10/
  stable/10/sys/netinet/cc/cc.c
Comment 6 commit-hook freebsd_committer freebsd_triage 2014-08-27 14:12:18 UTC
A commit references this bug:

Author: hselasky
Date: Wed Aug 27 14:11:26 UTC 2014
New revision: 270712
URL: http://svnweb.freebsd.org/changeset/base/270712

Log:
  MFC r269777:
  Fix string length argument passed to "sysctl_handle_string()" so that
  the complete string is returned by the function and not just only one
  byte.

  PR:	192544

Changes:
_U  stable/9/sys/
  stable/9/sys/netinet/cc/cc.c
Comment 7 commit-hook freebsd_committer freebsd_triage 2014-08-27 14:14:20 UTC
A commit references this bug:

Author: hselasky
Date: Wed Aug 27 14:13:48 UTC 2014
New revision: 270713
URL: http://svnweb.freebsd.org/changeset/base/270713

Log:
  MFC r269777:
  Fix string length argument passed to "sysctl_handle_string()" so that
  the complete string is returned by the function and not just only one
  byte.

  PR:	192544

Changes:
_U  stable/8/sys/
_U  stable/8/sys/netinet/
  stable/8/sys/netinet/cc/cc.c
Comment 8 Hans Petter Selasky freebsd_committer freebsd_triage 2014-08-27 14:15:00 UTC
Please re-open if still an issue.

Thank you!

--HPS