NetBSD Problem Report #36661

From yamt@mwd.biglobe.ne.jp  Tue Jul 17 14:56:42 2007
Return-Path: <yamt@mwd.biglobe.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 9964963B96E
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 17 Jul 2007 14:56:42 +0000 (UTC)
Message-Id: <20070717101750.33DF911702@yamt.dyndns.org>
Date: Tue, 17 Jul 2007 19:17:50 +0900 (JST)
From: yamt@mwd.biglobe.ne.jp
Reply-To: yamt@mwd.biglobe.ne.jp
To: gnats-bugs@NetBSD.org
Subject: any users can modify envsys setting
X-Send-Pr-Version: 3.95

>Number:         36661
>Category:       kern
>Synopsis:       any users can modify envsys setting
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 17 15:00:00 +0000 2007
>Closed-Date:    Tue Jul 17 15:42:35 +0000 2007
>Last-Modified:  Tue Jul 17 15:45:01 +0000 2007
>Originator:     YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
>Release:        NetBSD 4.99.23
>Organization:

>Environment:
Architecture: i386
Machine: i386
>Description:
	ENVSYS_SETDICTIONARY can be used without write-access.
	/dev/sysmon's mode mask is 644.
>How-To-Repeat:

>Fix:
	- make sysmonioctl_envsys check FWRITE for ENVSYS_SETDICTIONARY.
	- make envstat(8) use O_WDWR when appropriate.

>Release-Note:

>Audit-Trail:
From: Juan RP <juan@xtrarom.org>
To: gnats-bugs@NetBSD.org
Cc: yamt@mwd.biglobe.ne.jp
Subject: Re: kern/36661: any users can modify envsys setting
Date: Tue, 17 Jul 2007 17:05:59 +0200

 On Tue, 17 Jul 2007 15:00:00 +0000 (UTC)
 yamt@mwd.biglobe.ne.jp wrote:

 > >Description:
 > 	ENVSYS_SETDICTIONARY can be used without write-access.
 > 	/dev/sysmon's mode mask is 644.
 > >How-To-Repeat:
 > 	
 > >Fix:
 > 	- make sysmonioctl_envsys check FWRITE for ENVSYS_SETDICTIONARY.
 > 	- make envstat(8) use O_WDWR when appropriate.

 I asked that two months ago when I started it. Nobody answered me if
 envstat -m should be used only by root or something like this.

 -- 
 Juan Romero Pardines	- The NetBSD Project
 http://plog.xtrarom.org	- NetBSD/pkgsrc news in Spanish

From: Allen Briggs <briggs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, yamt@mwd.biglobe.ne.jp
Subject: Re: kern/36661: any users can modify envsys setting
Date: Tue, 17 Jul 2007 11:19:46 -0400

 On Tue, Jul 17, 2007 at 03:10:04PM +0000, Juan RP wrote:
 >  > >Fix:
 >  > 	- make sysmonioctl_envsys check FWRITE for ENVSYS_SETDICTIONARY.
 >  > 	- make envstat(8) use O_WDWR when appropriate.
 >  
 >  I asked that two months ago when I started it. Nobody answered me if
 >  envstat -m should be used only by root or something like this.

 I'm sorry no one answered.  I don't know about root-only, but it
 makes sense for the "set" operations to be governed by write access
 to the device.  That is consistent with the BSD/*nix model.

 Reading should be governed by read (FREAD) access to the device,
 modifying/setting/writing should be governed by write (FWRITE)
 access.

 -allen

 -- 
 Allen Briggs  |  http://www.ninthwonder.com/~briggs/  |  briggs@ninthwonder.com

From: Juan RP <juan@xtrarom.org>
To: Allen Briggs <briggs@netbsd.org>
Cc: gnats-bugs@NetBSD.org, yamt@mwd.biglobe.ne.jp
Subject: Re: kern/36661: any users can modify envsys setting
Date: Tue, 17 Jul 2007 17:21:15 +0200

 On Tue, 17 Jul 2007 11:19:46 -0400
 Allen Briggs <briggs@netbsd.org> wrote:

 > I'm sorry no one answered.  I don't know about root-only, but it
 > makes sense for the "set" operations to be governed by write access
 > to the device.  That is consistent with the BSD/*nix model.
 > 
 > Reading should be governed by read (FREAD) access to the device,
 > modifying/setting/writing should be governed by write (FWRITE)
 > access.

 No problem, I'm going to fix this in a few minutes.

 -- 
 Juan Romero Pardines	- The NetBSD Project
 http://plog.xtrarom.org	- NetBSD/pkgsrc news in Spanish

State-Changed-From-To: open->closed
State-Changed-By: xtraeme@netbsd.org
State-Changed-When: Tue, 17 Jul 2007 15:42:35 +0000
State-Changed-Why:
Fixed, thanks.


From: Juan Romero Pardines <xtraeme@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: PR/36661 CVS commit: src
Date: Tue, 17 Jul 2007 15:43:08 +0000 (UTC)

 Module Name:	src
 Committed By:	xtraeme
 Date:		Tue Jul 17 15:43:08 UTC 2007

 Modified Files:
 	src/sys/dev/sysmon: sysmon_envsys.c
 	src/usr.sbin/envstat: envstat.c

 Log Message:
 Only allow to use ENVSYS_SETDICTIONARY if the user has write permission
 in the /dev/sysmon device.

 Use O_RDONLY for ENVSYS_GETDICTIONARY and O_RDWR for ENVSYS_SETDICTIONARY
 in envstat(8).

 Fixes PR kern/36661 by YAMAMOTO Takashi.


 To generate a diff of this commit:
 cvs rdiff -r1.21 -r1.22 src/sys/dev/sysmon/sysmon_envsys.c
 cvs rdiff -r1.35 -r1.36 src/usr.sbin/envstat/envstat.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.