This is worse than I first thought. The time grows roughly linear up to
4GB, then apparently enters an infinite loop. Below is the program I
used to time it. On my system it takes 4 minutes to truncate a file to
just under 4GB (something that takes 14 microseconds without ecryptfs).
For 4GB it has so far taken 30 minutes, and will probably never
complete.

#define _FILE_OFFSET_BITS 64

#include <stdio.h>
#include <unistd.h>
#include <sys/fcntl.h>
#include <inttypes.h>

uint64_t usec(struct timeval t)
{
  uint64_t sec=t.tv_sec;
  uint64_t usec=t.tv_usec;
  return sec*1000000+usec;
}

void test(int fd, off_t l)
{
  struct timeval before,after;
  ftruncate(fd,0);
  gettimeofday(&before,NULL);
  ftruncate(fd,l);
  gettimeofday(&after,NULL);
  printf("%llu %llu\n",
         (unsigned long long)(l),
         (unsigned long long)(usec(after)-usec(before)));
}

int main()
{
  off_t ONE=1;
  int i;
  int fd=creat("dummy-file", 0666);
  for (i=1;i<34;++i) {
    test(fd,(ONE<<i)-(ONE<<(i>>1)));
    test(fd,ONE<<i);
  }
}

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/721955

Title:
  ftruncate DoS on ecryptfs

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to