kern/143568: ktrace is limited with other user's "filesize" limit

Eugene Grosbein egrosbein at
Fri Feb 5 05:50:02 UTC 2010

>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
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 05 05:50:01 UTC 2010
>Originator:     Eugene Grosbein
>Release:        FreeBSD 8.0-STABLE i386
System: FreeBSD 8.0-STABLE FreeBSD 8.0-STABLE #6: Mon Jan 11 15:04:08 KRAT 2010 root at i386

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


	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);
  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.



More information about the freebsd-bugs mailing list