Subject: kern/5350: COMPAT_FREEBSD issetugid
To: None <gnats-bugs@gnats.netbsd.org>
From: Minoura Makoto <minoura@kw.netlaputa.ne.jp>
List: netbsd-bugs
Date: 04/22/1998 22:03:48
>Number:         5350
>Category:       kern
>Synopsis:       COMPAT_FREEBSD issetugid
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 22 06:05:01 1998
>Last-Modified:
>Originator:     Minoura Makoto
>Organization:
MINOURA, Makoto <minoura@kw.netlaputa.ne.jp> or <minoura@kyogoku.com>
Nakahara-ku Kawasaki-Shi, JAPAN
>Release:        Apr 20, '98
>Environment:
System: NetBSD daisy 1.3E NetBSD 1.3E (DAISY) #54: Wed Apr 22 21:35:54 JST 1998 root@daisy:/usr/src/sys/arch/i386/compile/DAISY i386


>Description:
	FreeBSD-2.2.5 has a new systemcall issetugid borrowed from
	OpenBSD 2.0.
>How-To-Repeat:
	
>Fix:
diff -crN src.ORIG/sys/compat/freebsd/freebsd_misc.c src/sys/compat/freebsd/freebsd_misc.c
*** src.ORIG/sys/compat/freebsd/freebsd_misc.c	Tue Oct 21 17:17:42 1997
--- src/sys/compat/freebsd/freebsd_misc.c	Wed Apr 22 21:35:11 1998
***************
*** 104,106 ****
--- 104,125 ----
  
  	return ENOSYS;	/* XXX */
  }
+ 
+ int
+ freebsd_sys_issetugid(p, v, retval)
+         struct proc *p;
+ 	void *v;
+ 	register_t *retval;
+ {
+ 	/*
+ 	 * Note: OpenBSD sets a P_SUGIDEXEC flag set at execve() time,
+ 	 * we use P_SUGID because we consider changing the owners as
+ 	 * "tainting" as well.
+ 	 * This is significant for procs that start as root and "become"
+ 	 * a user without an exec - programs cannot know *everything*
+ 	 * that libc *might* have put in their data segment.
+ 	 */
+ 	if (p->p_flag & P_SUGID)
+ 		return (1);
+ 	return (0);
+ }
diff -crN src.ORIG/sys/compat/freebsd/syscalls.master src/sys/compat/freebsd/syscalls.master
*** src.ORIG/sys/compat/freebsd/syscalls.master	Thu Feb 19 21:11:47 1998
--- src/sys/compat/freebsd/syscalls.master	Wed Apr 22 21:34:53 1998
***************
*** 439,444 ****
  250	UNIMPL
  251	UNIMPL
  252	UNIMPL
! 253	UNIMPL
  254	STD		{ int freebsd_sys_lchown(char *path, int uid, \
  			    int gid); }
--- 439,444 ----
  250	UNIMPL
  251	UNIMPL
  252	UNIMPL
! 253	STD		{ int freebsd_sys_issetugid(void); }
  254	STD		{ int freebsd_sys_lchown(char *path, int uid, \
  			    int gid); }
>Audit-Trail:
>Unformatted: