NetBSD Problem Report #44582

From campbell@mumble.net  Tue Feb 15 23:39:32 2011
Return-Path: <campbell@mumble.net>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 2334463B100
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 15 Feb 2011 23:39:32 +0000 (UTC)
Message-Id: <20110215233930.9FDE498298@pluto.mumble.net>
Date: Tue, 15 Feb 2011 23:39:30 +0000 (UTC)
From: Taylor R Campbell <campbell+netbsd@mumble.net>
Reply-To: Taylor R Campbell <campbell+netbsd@mumble.net>
To: gnats-bugs@gnats.NetBSD.org
Subject: 5.1 sysctl(8) fails to understand time_t and bool under current kernels
X-Send-Pr-Version: 3.95

>Number:         44582
>Category:       kern
>Synopsis:       5.1's /sbin/sysctl fails to understand time_t and bool on current kernels
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 15 23:40:01 +0000 2011
>Last-Modified:  Mon Nov 26 04:10:00 +0000 2018
>Originator:     Taylor R Campbell <campbell+netbsd@mumble.net>
>Release:        NetBSD 5.99.44
>Organization:
>Environment:
System: NetBSD oberon.local 5.99.44 NetBSD 5.99.44 (RIAMONODEBUG) #0: Tue Feb  1 20:55:46 UTC 2011 root@smalltalk.local:/home/riastradh/netbsd/current/obj/sys/arch/i386/compile/RIAMONODEBUG i386
Architecture: i386
Machine: i386
>Description:

	When I run 5.1's /sbin/sysctl on a current kernel, it fails to
	understand a number of nodes, because of the introduction of
	CTLTYPE_BOOL and the transition to 64-bit time_t.  jmcneill
	says that COMPAT_50 should make this work.

>How-To-Repeat:

	On a 5.1 kernel:

% sysctl kern.boottime
kern.boottime = Thu Feb  3 15:47:42 2011
% sysctl -M kern.boottime
kern.boottime (1.21): CTLTYPE_STRUCT, size 8, flags 0x200<READONLY,PERMANENT>, ver=350
% sysctl machdep.acpi_vbios_reset
machdep.acpi_vbios_reset = 1
% sysctl -M machdep.acpi_vbios_reset
machdep.acpi_vbios_reset (7.1233): CTLTYPE_INT, size 4, flags 0x70<READWRITE>, func=0xc05c4470, ver=574

	On a current kernel:

% sysctl kern.boottime
sysctl: kern.boottime: sysctl() failed with Cannot allocate memory
% sysctl -M kern.boottime
kern.boottime (1.83): CTLTYPE_STRUCT, size 12, flags 0x200<READONLY,PERMANENT>, ver=153
% sysctl machdep.acpi_vbios_reset
% sysctl -M machdep.acpi_vbios_reset
machdep.acpi_vbios_reset (7.1044): CTLTYPE_???, size 1, flags 0x70<READWRITE>, func=0xc0123eb0, ver=22

>Fix:

	Yes, please!

>Audit-Trail:
From: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Cc: kre@netbsd.org
Subject: Re: kern/44582: 5.1's /sbin/sysctl fails to understand time_t and
 bool on current kernels
Date: Sun, 25 Nov 2018 18:23:52 +0000

 FOr the boottime we have kre's reply:


   | hmmm... feels like KERN_BOOTTIMESPEC should be added instead,
   | and the compat restored for this old API.
   |
   | or should have been 9 years ago :-(

 ps: even if that might have been a reasonable thing to do, way back when,
 now it woulldn't work, as there are parts of the tree that know it is a 
 timespec (before I started updating stuff) and other parts which did not.
 There's no way to provide compat with both.
 --

 Not sure about the other part regarding bool.

From: Robert Elz <kre@munnari.OZ.AU>
To: coypu@sdf.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/44582: 5.1's /sbin/sysctl fails to understand time_t and bool on current kernels
Date: Mon, 26 Nov 2018 11:05:41 +0700

     Date:        Sun, 25 Nov 2018 18:23:52 +0000
     From:        coypu@sdf.org
     Message-ID:  <20181125182352.GA9714@SDF.ORG>

   | FOr the boottime we have kre's reply:

 Note...

   |   | hmmm... feels like KERN_BOOTTIMESPEC should be added instead,
   |   | and the compat restored for this old API.

 That was about the API.   That one is a problem (or could be, this is
 probably not a big enough issue to be too worried about), whereas this
 PR is about the ABI.

 The intent was that should just work, there is still the old (32 bit) timeval
 sysctl with the same OID, which (for most apps) would (or should)
 just work (ie: a -5 or earlier binary with a newer kernel should get a
 timeval with a 32 bit time_t in it.)

 I suspect the issue with sysctl is that it is looking up the name kern.boottime
 (etc) and with a new kernel, that is returning the new version of that node,
 and not kern.obootime (the compat version) - but I don't know enough about
 how that is done to have any idea how it could be fixed.   Maybe the
 sysctl interface itself needs to be versioned whenever one of the nodes is,
 and the old version do lookups in the compat tree, or translate OIDs of
 new nodes into the compat versions, or something.

 This looks to be messy and very hard.

 kre

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.