From nobody  Sat Dec 13 16:26:35 1997
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.7/8.8.7) id QAA27443;
          Sat, 13 Dec 1997 16:26:35 -0800 (PST)
          (envelope-from nobody)
Message-Id: <199712140026.QAA27443@hub.freebsd.org>
Date: Sat, 13 Dec 1997 16:26:35 -0800 (PST)
From: dswartz@druber.com
To: freebsd-gnats-submit@freebsd.org
Subject: quotas do not work properly with setuid programs.
X-Send-Pr-Version: www-1.0

>Number:         5285
>Category:       kern
>Synopsis:       quotas do not work properly with setuid programs.
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 13 16:30:01 PST 1997
>Closed-Date:    Sun Sep 20 19:59:10 PDT 1998
>Last-Modified:  Sun Sep 20 20:09:43 PDT 1998
>Originator:     Dan Swartzendruber
>Release:        2.2.5
>Organization:
Swartzendruber Consulting
>Environment:
FreeBSD mail2.kersur.net 2.2.5-RELEASE FreeBSD 2.2.5-RELEASE #1: Thu Dec 11 18:11:52 EST 1997     root@mail2.kersur.net:/usr/src/sys/compile/MAIL  i386

>Description:
Apparently, the quota checking code in ufs/ufs/ufs_quota.c (possibly
elsewhere, this is just what I happened to see) does not apply quota
to UID 0, which is not unreasonable.  However, it checks the UID in
the current credential, *not* the current mode the process is in, so
a setuid program that becomes non-privileged does not have that UID
quota applied to it.  This is related to a similar problem report that
was made vs sendmail/mail.local.  The proposed fix does not work, for
the reasons I have already described.
>How-To-Repeat:
Write a "C" program that does setuid(xxx), where xxx is a UID that is
over quota on some filesystem.  Have that program create and write to
a file on that filesystem after doing said setuid().  It will work.

>Fix:
Dunno.

>Release-Note:
>Audit-Trail:

From: Dan Swartzendruber <dswartz@druber.com>
To: freebsd-gnats-submit@freebsd.org, dswartz@druber.com
Cc:  Subject: Re: kern/5285: quotas do not work properly with setuid
  programs.
Date: Sun, 04 Jan 1998 00:33:47 -0500

 I've had some time to poke through the kernel sources, and it sure looks
 like ufs_quota and company are checking the effective UID (that is what
 cr_uid is, no?)  I don't yet understand why that was zero in the case of
 my test program (I proved this also by adding a kernel printf just to make
 sure, and it did print 0).
 
 ---
 Swartzendruber Consulting, Inc.
 
State-Changed-From-To: open->closed 
State-Changed-By: msmith 
State-Changed-When: Sun Sep 20 19:59:10 PDT 1998 
State-Changed-Why:  
Submitter reports that problem no longer manifests.  Changes not specifically 
directed at this problem appear to have fixed same. 
>Unformatted:
