Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Feb 2010 12:42:34 +0700 (KRAT)
From:      Eugene Grosbein <egrosbein@rdtc.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/143568: ktrace is limited with other user's "filesize" limit
Message-ID:  <201002050542.o155gYe9000371@eg.sd.rdtc.ru>
Resent-Message-ID: <201002050550.o155o2P3028546@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         143568
>Category:       kern
>Synopsis:       ktrace is limited with other user's "filesize" limit
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 05 05:50:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Eugene Grosbein
>Release:        FreeBSD 8.0-STABLE i386
>Organization:
RDTC JSC
>Environment:
System: FreeBSD eg.sd.rdtc.ru 8.0-STABLE FreeBSD 8.0-STABLE #6: Mon Jan 11 15:04:08 KRAT 2010 root@eg.sd.rdtc.ru:/usr/local/obj/usr/local/src/sys/EG i386

>Description:
	ktrace stops writing trace file if "filesize" limit is enabled
	by traced process.

>How-To-Repeat:

	Compile this test code: cc -o example example.c
	It needs two command line arguments: filesize limit (in bytes)
	and some user's uid (f.e., 65534 for "nobody").

#include <sys/types.h>
#include <sys/resource.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
  
  struct rlimit rl;

  if (argc > 2) {  
    rl.rlim_cur = atol(argv[1]);
    setrlimit(RLIMIT_FSIZE, &rl);
    seteuid(atol(argv[2]));
    while(1)
      usleep(10);
  }
  return 0;
}

	Use kernel with "options KTRACE" and run the example as root,
	it breaks as soon as trace file size hits limit:

# ktrace ./example 100000 65535
Filesize limit exceeded: 25

	Note that traced code does not write anything, it runs as another user
	and sets limit for itself only and not for ktrace.
	
	This makes it difficult to debug real services using "filesize"
	limit like stock ftpd serving users with limited login class assigned.

>Fix:

	Unknown
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002050542.o155gYe9000371>