NetBSD Problem Report #53491

From kre@munnari.OZ.AU  Wed Aug  1 16:07:52 2018
Return-Path: <kre@munnari.OZ.AU>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E8B3F7A41F
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  1 Aug 2018 16:07:51 +0000 (UTC)
Message-Id: <201808011607.w71G7Es5019837@jinx.noi.kre.to>
Date: Wed, 1 Aug 2018 23:07:14 +0700 (+07)
From: kre@munnari.OZ.AU
To: gnats-bugs@NetBSD.org
Subject: Bizarre definition of POWER_IOC_GET_TYPE_WITH_LOSSAGE
X-Send-Pr-Version: 3.95

>Number:         53491
>Category:       kern
>Synopsis:       Bizarre definition of POWER_IOC_GET_TYPE_WITH_LOSSAGE
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 01 16:10:00 +0000 2018
>Last-Modified:  Wed Aug 01 17:45:00 +0000 2018
>Originator:     Robert Elz
>Release:        NetBSD 8.99.17
>Organization:
>Environment:
System: NetBSD jinx.noi.kre.to 8.99.17 NetBSD 8.99.17 (GENERIC) #1: Sat May 19 20:03:18 ICT 2018 kre@onyx.coe.psu.ac.th:/usr/obj/testing/amd64/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
	In src/sys/power.h observe ...

#define POWER_IOC_GET_TYPE_WITH_LOSSAGE _IOR('P', 0, sizeof(struct power_type))

	which is almost certainly not doing what it intended
	(sizeof(sizeof...)) is going to be (sizeof(size_t))
	which is likely 4 or 8 or something, rather than the
	32 which the code clearly wants.

	The companion:

#define POWER_IOC_GET_TYPE      _IOR('P', 0, struct power_type)

	is defined properly.

>How-To-Repeat:
	UTSL

>Fix:
	I'd just remove the stray "sizeof()" but I am not sure what
	this would do to binary compat, or if in fact this ioctl
	is ever actually used anywhere, so I will leave it for
	someone who has a clue in this area.

>Audit-Trail:
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/53491: Bizarre definition of POWER_IOC_GET_TYPE_WITH_LOSSAGE
Date: Wed, 01 Aug 2018 23:20:57 +0700

 Note that if this gets changed, the ioctl command number will need to
 be changed as well, cannot have 2 that are 0 with the same _IOR and
 structure size.

 In this same area also see:

 src/sys/arch/landisk/include/button.h

 #define BUTTON_IOC_GET_TYPE      _IOR('P', 1, sizeof(struct button_type))

 and  src/sys/coda/coda.h

 #define CIOC_KERNEL_VERSION _IOWR('c', 10, sizeof (int))


From: "Jonathan A. Kollasch" <jakllsch@kollasch.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/53491: Bizarre definition of POWER_IOC_GET_TYPE_WITH_LOSSAGE
Date: Wed, 1 Aug 2018 11:48:08 -0500

 POWER_IOC_GET_TYPE_WITH_LOSSAGE is indeed for backwards compatibility
 with -current after April 18 2003, and before November 6 2009, and for
 releases in the netbsd-2 thru netbsd-5 series.  See the changeset including
 http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/sysmon/sysmon_power.c?rev=1.42&content-type=text/x-cvsweb-markup&only_with_tag=MAIN
 for some additional explanation.

 There should probably be some annotations made in the source that this
 is the case..

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/53491: Bizarre definition of POWER_IOC_GET_TYPE_WITH_LOSSAGE
Date: Thu, 02 Aug 2018 00:42:37 +0700

     Date:        Wed,  1 Aug 2018 16:50:01 +0000 (UTC)
     From:        "Jonathan A. Kollasch" <jakllsch@kollasch.net>
     Message-ID:  <20180801165001.6617C7A421@mollari.NetBSD.org>

   |  POWER_IOC_GET_TYPE_WITH_LOSSAGE is indeed for backwards compatibility

 OK, thanks, that makes sense.

   |  There should probably be some annotations made in the source that this
   |  is the case..

 Agreed...

 And I wonder if it needs to be defined at all #ifndef KERNEL ?    I will check.

 The other two do not have that excuse I believe.

 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.