Bug 245463

Summary: sysctl: Driver tunables that use strings fail with error 14
Product: Base System Reporter: Jeff Pieper <jeffrey.e.pieper>
Component: kernAssignee: Pawel Biernacki <kaktus>
Status: Closed FIXED    
Severity: Affects Many People CC: emaste, erj, jeb, kaktus, krzysztof.galazka
Priority: --- Keywords: needs-qa, regression
Version: CURRENT   
Hardware: Any   
OS: Any   
See Also: https://reviews.freebsd.org/D23378
https://reviews.freebsd.org/D24429

Description Jeff Pieper 2020-04-08 23:10:10 UTC
When changing driver tunables that use strings with kenv, they fail with error 14. For example Intel drivers rx/tx descriptor tunables fail with:

Setting sysctl dev.ixl.0.iflib.override_ntxds failed: 14
Setting sysctl dev.ixl.0.iflib.override_nrxds failed: 14

More than likely this is caused by https://reviews.freebsd.org/D23378. This patch has made changes to the sysctl_handle_string() function. The copyin() function  is now used to copy bytes from user space to kernel space. The problem is that the tunables are already located in the kernel space (kenv). It turns out that changing string parameters using sysctl works well, but if you set string parameters from kenv, the copyin() function fails with error 14.
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2020-04-09 01:59:07 UTC
Associated commit: base r357614
Comment 2 Pawel Biernacki freebsd_committer freebsd_triage 2020-04-15 11:52:52 UTC
Review with a proposed fix: https://reviews.freebsd.org/D24429
Comment 3 commit-hook freebsd_committer freebsd_triage 2020-04-15 16:34:39 UTC
A commit references this bug:

Author: kaktus
Date: Wed Apr 15 16:33:55 UTC 2020
New revision: 359975
URL: https://svnweb.freebsd.org/changeset/base/359975

Log:
  sysctl(9): fix handling string tunables.

  r357614 changed internals of handling string sysctls, and inadvertently
  broke setting string tunables.  Take them into account.

  PR:		245463
  Reported by:	jhb, np
  Reviewed by:	imp, jhb, kib
  Approved by:	kib (mentor)
  Differential Revision:	https://reviews.freebsd.org/D24429

Changes:
  head/sys/kern/kern_sysctl.c