1. 21 Oct, 2017 5 commits
    • ringbuf: implement simple and efficient ringbuffer · f3d05ee6
      Christian Brauner authored
      liblxc will use a ringbuffer implementation that employs mmap()ed memory.
      Specifically, the ringbuffer will create an anonymous memory mapping twice the
      requested size for the ringbuffer. Afterwards, an in-memory file the requested
      size for the ringbuffer will be created. This in-memory file will then be
      memory mapped twice into the previously established anonymous memory mapping
      thereby effectively splitting the anoymous memory mapping in two halves of
      equal size.  This will allow the ringbuffer to get rid of any complex boundary
      and wrap-around calculation logic. Since the underlying physical memory is the
      same in both halves of the memory mapping only a single memcpy() call for both
      reads and writes from and to the ringbuffer is needed.
      
      Design Notes:
      - Since we're using MAP_FIXED memory mappings to map the same in-memory file
        twice into the anonymous memory mapping the kernel requires us to always
        operate on properly aligned pages. To guarantee proper page aligment the size
        of the ringbuffer must always be a muliple of the kernel's page size. This
        also implies that the minimum size of the ringbuffer must be at least equal to
        one page size. This additional requirement is reasonably unproblematic.
        First, any ringbuffer smaller than the size of a single page is very likely
        useless since the standard page size on linux is 4096 bytes.
      - Because liblxc is not able to predict the output a user is going to produce
        (e.g. users could cat binary files onto the console) and because the
        ringbuffer is located in a hotpath and needs to be as performant as possible
        liblxc will not parse the buffer.
      
      Use Case:
      The ringbuffer is needed by liblxc in order to safely log the output of write
      intensive callers that produce unpredictable output or unpredictable amounts of
      output. The console output created by a booting system and the user is one of
      those cases. Allowing a container to log the console's output to a file it
      would be possible for a malicious user to fill up the host filesystem by
      producing random ouput on the container's console if quota support is either
      not enabled or not available for the underlying filesystem. Using a ringbuffer
      is a reliable and secure way to ensure a fixed-size log.
      
      Closes #1857.
      Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
    • utils: add lxc_getpagesize() · e4636123
      Christian Brauner authored
      Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
    • utils: add lxc_cloexec() · b499121f
      Christian Brauner authored
      Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
  2. 20 Oct, 2017 2 commits
  3. 18 Oct, 2017 1 commit
  4. 17 Oct, 2017 2 commits
  5. 16 Oct, 2017 5 commits
  6. 12 Oct, 2017 4 commits
  7. 11 Oct, 2017 4 commits
  8. 10 Oct, 2017 4 commits
  9. 06 Oct, 2017 4 commits
  10. 05 Oct, 2017 4 commits
  11. 04 Oct, 2017 1 commit
    • implement lxc_string_split_quoted · 3dca1af0
      Serge Hallyn authored
      lxc_string_split_quoted() splits a string on spaces, but keeps
      groups in single or double qoutes together.  In other words,
      generally what we'd want for argv behavior.
      
      Switch lxc-execute to use this for lxc.execute.cmd.
      
      Switch lxc-oci template to put the lxc.execute.cmd inside single
      quotes, because parse_line() will eat those.  If we don't do that,
      then if we have lxc.execute.cmd = /bin/echo "hello, world", then the
      last double quote will disappear.
      Signed-off-by: 's avatarSerge Hallyn <shallyn@cisco.com>
  12. 03 Oct, 2017 4 commits