]> git.proxmox.com Git - mirror_lxcfs.git/log
mirror_lxcfs.git
8 years agobindings: return value type fixup
Wolfgang Bumiller [Fri, 5 Feb 2016 10:50:32 +0000 (11:50 +0100)]
bindings: return value type fixup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoconfigure.ac: add -Wno-portability
Serge Hallyn [Thu, 4 Feb 2016 08:04:37 +0000 (00:04 -0800)]
configure.ac: add -Wno-portability

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #76 from hallyn/2016-02-03/pidfile
Serge Hallyn [Thu, 4 Feb 2016 00:26:52 +0000 (16:26 -0800)]
Merge pull request #76 from hallyn/2016-02-03/pidfile

2016 02 03/pidfile

8 years agodrop glibc travis exceptions - we don't use glibc any more
Serge Hallyn [Wed, 3 Feb 2016 21:25:19 +0000 (13:25 -0800)]
drop glibc travis exceptions - we don't use glibc any more

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoAdd a pidfile
Serge Hallyn [Wed, 3 Feb 2016 21:24:11 +0000 (13:24 -0800)]
Add a pidfile

and update testsuite to use pidfile

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agodrop a debugging printf
Serge Hallyn [Wed, 3 Feb 2016 21:04:04 +0000 (13:04 -0800)]
drop a debugging printf

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #75 from hallyn/n
Serge Hallyn [Wed, 3 Feb 2016 01:45:43 +0000 (17:45 -0800)]
Merge pull request #75 from hallyn/n

Don't tie entries in 'hierarchies' to their subsystem id

8 years agoDon't tie entries in 'hierarchies' to their subsystem id
Serge Hallyn [Wed, 3 Feb 2016 01:23:50 +0000 (17:23 -0800)]
Don't tie entries in 'hierarchies' to their subsystem id

There's no place where we rely on it, and it gets out of whack
if cgroups have been unmounted+remounted.

This is an alternative to https://github.com/lxc/lxcfs/pull/70.
Thanks to smemsh for the report and proposed fix.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #74 from hallyn/2016-02-02/split.2
Serge Hallyn [Wed, 3 Feb 2016 00:46:57 +0000 (16:46 -0800)]
Merge pull request #74 from hallyn/2016-02-02/split.2

2016 02 02/split.2

8 years agoMake the bulk of the lxcfs code reloadable
Serge Hallyn [Mon, 1 Feb 2016 11:21:01 +0000 (12:21 +0100)]
Make the bulk of the lxcfs code reloadable

Move the majority of the code (the bits most likely to have security
bugs coming up) reloadable.  Sending USR1 signal to lxcfs will cause
it to reload the shared library so as to immediately start using the
fixed code.  This allows us to upgrade lxcfs in the majority of
cases without having to restart containers.

To achieve this, some code was moved around so that lxcfs.c itself
does not risk pinning any symbols from the shared library (which
would prevent it being unloaded).  We track the number of threads
currently using the bindings, and do the reload after it hits
zero (specifically, the next time that we turn the count from 0 to 1)

Also add a test case to make sure an updated library does in fact
get loaded.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoAvoid redefinition of ret in local scope
Serge Hallyn [Mon, 1 Feb 2016 11:23:30 +0000 (12:23 +0100)]
Avoid redefinition of ret in local scope

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #72 from stgraber/master
Serge Hallyn [Tue, 2 Feb 2016 18:53:07 +0000 (10:53 -0800)]
Merge pull request #72 from stgraber/master

Don't hardcode strings in testsuites

8 years agoDon't hardcode strings in testsuites
Stéphane Graber [Tue, 2 Feb 2016 16:54:02 +0000 (17:54 +0100)]
Don't hardcode strings in testsuites

With this, we should be able to run more than one testsuite at once.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoMerge pull request #69 from sforshee/fixes
Serge Hallyn [Fri, 29 Jan 2016 10:43:07 +0000 (11:43 +0100)]
Merge pull request #69 from sforshee/fixes

Random fixes

8 years agoRemove unused chunks in caching code
Seth Forshee [Thu, 28 Jan 2016 16:17:42 +0000 (17:17 +0100)]
Remove unused chunks in caching code

Several pieces of code which deal with caching contents for proc
files contain code like this:

  if (l >= cache_size) {
      ...
      goto err;
  }
  if (l < cache_size) {
      ...
  } else {
      ...
  }

When the first condition is false the second condition will
always be true, so the code in the else block is never used.
The second if/else statement can then just be replaced with the
code from the if block.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
8 years agoAvoid theoretical underflow in prune_init_{slice,scope}
Seth Forshee [Thu, 28 Jan 2016 16:10:22 +0000 (17:10 +0100)]
Avoid theoretical underflow in prune_init_{slice,scope}

In practice these should never underflow, but in theory it's possible.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
8 years agotests: update to handle lxcfs virtualizing based on init
Serge Hallyn [Thu, 28 Jan 2016 13:48:19 +0000 (14:48 +0100)]
tests: update to handle lxcfs virtualizing based on init

lxcfs used to use $current's cgroups to virtualize proc, but
switched in 0.17 to using $current's init's cgroups.  The
tests need to be updated to reflect that.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agomkdir_p: check for null not \0, and fail if enomem
Serge Hallyn [Wed, 27 Jan 2016 13:30:29 +0000 (14:30 +0100)]
mkdir_p: check for null not \0, and fail if enomem

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agopam: free path when pruning
Serge Hallyn [Wed, 27 Jan 2016 13:07:51 +0000 (14:07 +0100)]
pam: free path when pruning

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agopam: detect write failure in write_int()
Serge Hallyn [Wed, 27 Jan 2016 13:03:03 +0000 (14:03 +0100)]
pam: detect write failure in write_int()

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agopam: always free line and close file
Serge Hallyn [Wed, 27 Jan 2016 12:59:49 +0000 (13:59 +0100)]
pam: always free line and close file

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agohandle case where only one of comounted controllers is mounted
Serge Hallyn [Wed, 27 Jan 2016 12:52:40 +0000 (13:52 +0100)]
handle case where only one of comounted controllers is mounted

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agopam: don't let add_controller fail
Serge Hallyn [Wed, 27 Jan 2016 12:48:57 +0000 (13:48 +0100)]
pam: don't let add_controller fail

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoconfigure.ac: release LXCFS 0.17 lxcfs-0.17
Serge Hallyn [Tue, 26 Jan 2016 19:18:47 +0000 (11:18 -0800)]
configure.ac: release LXCFS 0.17

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agotravis: install pam
Serge Hallyn [Sat, 23 Jan 2016 04:35:19 +0000 (20:35 -0800)]
travis: install pam

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agomake HASH a smidge safer
Serge Hallyn [Sat, 23 Jan 2016 03:49:14 +0000 (19:49 -0800)]
make HASH a smidge safer

per tych0 suggestion

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoturn pidns store into a hashtable
Serge Hallyn [Sat, 23 Jan 2016 00:37:22 +0000 (16:37 -0800)]
turn pidns store into a hashtable

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoprune unused init pid store entries
Serge Hallyn [Fri, 22 Jan 2016 23:49:42 +0000 (15:49 -0800)]
prune unused init pid store entries

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agopam_cgfs.so: chown user's cgroups
Serge Hallyn [Fri, 22 Jan 2016 23:03:10 +0000 (15:03 -0800)]
pam_cgfs.so: chown user's cgroups

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agosilence some warnings
Serge Hallyn [Fri, 22 Jan 2016 22:51:43 +0000 (14:51 -0800)]
silence some warnings

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agocache the init pids
Serge Hallyn [Fri, 22 Jan 2016 22:01:44 +0000 (14:01 -0800)]
cache the init pids

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoepoll: update timeout and retry at eintr
Serge Hallyn [Fri, 22 Jan 2016 19:00:16 +0000 (11:00 -0800)]
epoll: update timeout and retry at eintr

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agomore sanity checking
Serge Hallyn [Fri, 22 Jan 2016 08:49:34 +0000 (00:49 -0800)]
more sanity checking

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agofirst start to converting permissions checks
Serge Hallyn [Fri, 22 Jan 2016 04:00:11 +0000 (20:00 -0800)]
first start to converting permissions checks

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoDon't use tasks file to determine access rights to its cgroup
Serge Hallyn [Fri, 22 Jan 2016 03:47:25 +0000 (19:47 -0800)]
Don't use tasks file to determine access rights to its cgroup

Also rename 'fpath' to 'last' when it is simply referring to the
last path element.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoswitch to epoll
Serge Hallyn [Fri, 22 Jan 2016 02:55:59 +0000 (18:55 -0800)]
switch to epoll

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agosimplify getreaperage
Serge Hallyn [Fri, 22 Jan 2016 02:21:13 +0000 (18:21 -0800)]
simplify getreaperage

We don't need to switch to their ns, mount their proc, and check /proc/1.
Just find out their init pid using scm credentials and check /pid/$initpid
in our own procfs.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agouse the init pid for reaper age
Serge Hallyn [Fri, 22 Jan 2016 02:11:05 +0000 (18:11 -0800)]
use the init pid for reaper age

And rename the function which returns a task's init pid.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoadd pam module
Serge Hallyn [Wed, 20 Jan 2016 06:04:54 +0000 (22:04 -0800)]
add pam module

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoRemove obsolete options from readme
Serge Hallyn [Thu, 21 Jan 2016 21:21:58 +0000 (13:21 -0800)]
Remove obsolete options from readme

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoremove stale comment
Serge Hallyn [Thu, 21 Jan 2016 20:50:42 +0000 (12:50 -0800)]
remove stale comment

fuse does in fact filter .. for us.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoFix Busted Swap Accounting
Nehal J Wani [Tue, 19 Jan 2016 19:07:16 +0000 (00:37 +0530)]
Fix Busted Swap Accounting

When no limit is specified using lxc.cgroup.memory.memsw.limit_in_bytes,
overflow occurs while calculating Swap{Total,Free}. Commit a2de34b tried
to fix this, but introduced another bug, wherein if
memory.memsw.limit_in_bytes >= memory.limit_in_bytes, then Swap{Total,Free}
are not shown as expected.

When a container is spawned with the settings...

lxc.cgroup.memory.limit_in_bytes = 256M
lxc.cgroup.memory.memsw.limit_in_bytes = 512M

...I find that inside the container, we have:

[root@test ~]# free -m
             total       used       free     shared    buffers     cached
Mem:           256         24        231          6          0         20
-/+ buffers/cache:          3        252
Swap:         1023          0       1023

The total swap should have been 256MB, but it is being
shown as ~1GB (same as host). Basically, the memsw setting is being
ignored.

This patch attempts to fix this by assuming that the when no limit is
specified, the value is same that as of cgroup /

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #67 from mortzu/patch-1
Serge Hallyn [Tue, 19 Jan 2016 15:49:10 +0000 (07:49 -0800)]
Merge pull request #67 from mortzu/patch-1

There is no debug mode

8 years agoThere is no debug mode
Moritz Kaspar Rudert [Mon, 18 Jan 2016 22:48:23 +0000 (23:48 +0100)]
There is no debug mode

8 years agoconfigure.ac: release LXCFS 0.16 lxcfs-0.16
Serge Hallyn [Sat, 9 Jan 2016 02:26:45 +0000 (18:26 -0800)]
configure.ac: release LXCFS 0.16

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agosimplify and fix must_strcat_pid
Serge Hallyn [Fri, 8 Jan 2016 20:20:01 +0000 (12:20 -0800)]
simplify and fix must_strcat_pid

Like the last commit by Wolfgang, merge the alloc cases into one
realloc.  Dereference *src as it must be after all.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agocgfs: make dorealloc allocate the first batch, too
Wolfgang Bumiller [Fri, 8 Jan 2016 20:16:16 +0000 (12:16 -0800)]
cgfs: make dorealloc allocate the first batch, too

With a short first line the case can be
 *mem = NULL
 oldlen = 0
 newlen = 5 (anything < 50)
making newbatches == oldbatches == 1 causing the
 (newbatches <= oldbatches)
condition to be true.

Let realloc() handle *mem==NULL and use
(!*mem || newbatches > oldbatches) as the only condition.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoconfigure.ac: release LXCFS 0.15 lxcfs-0.15
Serge Hallyn [Fri, 8 Jan 2016 01:56:25 +0000 (17:56 -0800)]
configure.ac: release LXCFS 0.15

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agodo not dereference char* for realloc
Serge Hallyn [Fri, 8 Jan 2016 01:56:15 +0000 (17:56 -0800)]
do not dereference char* for realloc

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoconfigure.ac: Release LXCFS v0.14 lxcfs-0.14
Serge Hallyn [Thu, 7 Jan 2016 23:41:50 +0000 (15:41 -0800)]
configure.ac: Release LXCFS v0.14

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoadd processed reboot hook to gitignore
Serge Hallyn [Thu, 7 Jan 2016 23:40:29 +0000 (15:40 -0800)]
add processed reboot hook to gitignore

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agodon't use sh -u
Serge Hallyn [Thu, 7 Jan 2016 22:51:56 +0000 (14:51 -0800)]
don't use sh -u

That causes failure when we check (with test -n) for an env variable which does not exist.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoFix comparison of string to number.
Serge Hallyn [Thu, 7 Jan 2016 19:22:07 +0000 (11:22 -0800)]
Fix comparison of string to number.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agodorealloc: avoid extra reallocs
Serge Hallyn [Thu, 7 Jan 2016 19:17:17 +0000 (11:17 -0800)]
dorealloc: avoid extra reallocs

The original check was very wrong, using % instead of /.  However
the length we track is the actual used length, not the allocated
length, which is always (len / BATCH_SIZE) + 1.  We don't want
to realloc when newlen is between oldlen and (oldlen / BATCH_SIZE) + 1)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agocgfs: improve read_file and append_line
Wolfgang Bumiller [Thu, 7 Jan 2016 11:59:55 +0000 (12:59 +0100)]
cgfs: improve read_file and append_line

getline() returns the length which can be passed to
append_line to avoid a strlen() call.

Additionally with the length already known memcpy() can be
used instead of strcpy(). A +1 to the length will include
the terminating null byte as it is included in getline(3)'s
output.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agocgfs: fix dorealloc's batch allocation
Wolfgang Bumiller [Thu, 7 Jan 2016 11:59:54 +0000 (12:59 +0100)]
cgfs: fix dorealloc's batch allocation

The initial check should use real lengths as with modulo a
new required length of eg. 52 would be considered smaller
than an old length of 48 (2 < 48).

To get the 'batches' count 'newlen' must be divided and not
taken modulo BATCH_SIZE. Otherwise '101', which would need a
3rd batch to reach 150, would end up with two (2*50 = 100
bytes) and thereby be truncated instead.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agofix leak in realloc loop in must_strcat_pid
Wolfgang Bumiller [Thu, 7 Jan 2016 11:59:53 +0000 (12:59 +0100)]
fix leak in realloc loop in must_strcat_pid

If the first realloc() call fails then 'd' becomes NULL,
subsequent realloc() retries will behave like malloc() and
the the original src pointer is never freed. Further more
the newly allocated data then contains uninitialized data
where the previous pids had been stored.
Avoid this by passing the the original pointer from '*src'
to realloc().

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoavoid strlen in must_strcat_pid
Wolfgang Bumiller [Thu, 7 Jan 2016 11:59:52 +0000 (12:59 +0100)]
avoid strlen in must_strcat_pid

sprintf() already returns the length

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agofix missing dereferencing in must_strcat_pid
Wolfgang Bumiller [Thu, 7 Jan 2016 11:59:51 +0000 (12:59 +0100)]
fix missing dereferencing in must_strcat_pid

Fixes a segfault when reading a /tasks file of a cgroup
containing a large number of pids.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #64 from evgeni/doc-include-fixes
Serge Hallyn [Fri, 1 Jan 2016 18:45:00 +0000 (10:45 -0800)]
Merge pull request #64 from evgeni/doc-include-fixes

update README about the hooks configuration needed

8 years agoupdate README about the hooks configuration needed
Evgeni Golov [Fri, 1 Jan 2016 18:11:42 +0000 (19:11 +0100)]
update README about the hooks configuration needed

- fix the paths for the files and config
- include lxc.mount.auto = cgroup:mixed

Signed-off-by: Evgeni Golov <evgeni@debian.org>
8 years agoDon't assume lxc knows about cgroup namespaces
Serge Hallyn [Fri, 1 Jan 2016 01:47:45 +0000 (17:47 -0800)]
Don't assume lxc knows about cgroup namespaces

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agodon't mount lxcfs cgroups if we have cgroup namespaces
Serge Hallyn [Tue, 10 Nov 2015 15:12:36 +0000 (09:12 -0600)]
don't mount lxcfs cgroups if we have cgroup namespaces

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agouptime: fix pid1 and reaper_busy times
Wolfgang Bumiller [Mon, 14 Dec 2015 08:03:14 +0000 (09:03 +0100)]
uptime: fix pid1 and reaper_busy times

- reaper_busy was off by a factor of 10 (possibly originally
for precision?)
- get_pid1_time was expecting a '1' byte like in
the pid_to/from_ns_wrapper functions instead of reading its
value which is what is actually written

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #57 from tych0/can-see-root-cgroup
Serge Hallyn [Mon, 7 Dec 2015 18:08:04 +0000 (12:08 -0600)]
Merge pull request #57 from tych0/can-see-root-cgroup

caller_may_see_dir: correctly handle tasks in /

8 years agocaller_may_see_dir: correctly handle tasks in /
Tycho Andersen [Mon, 7 Dec 2015 17:13:23 +0000 (10:13 -0700)]
caller_may_see_dir: correctly handle tasks in /

See comment for details.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
8 years agomeminfo: fix report swap usage
Serge Hallyn [Sun, 6 Dec 2015 16:39:55 +0000 (10:39 -0600)]
meminfo: fix report swap usage

when swap controller is enabled but no limits are set, the limits
show up as (unsigned) -1.  This messes up, for instance, 'free -m'.

Closes #56.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agotests/main.sh: support running without having built lxcfs
Serge Hallyn [Thu, 3 Dec 2015 03:02:01 +0000 (21:02 -0600)]
tests/main.sh: support running without having built lxcfs

This is the case in adt.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agomake test_confinement.sh executable
Serge Hallyn [Wed, 25 Nov 2015 18:18:54 +0000 (12:18 -0600)]
make test_confinement.sh executable

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoconfigure.ac: release v0.13 lxcfs-0.13
Serge Hallyn [Wed, 25 Nov 2015 16:25:01 +0000 (10:25 -0600)]
configure.ac: release v0.13

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agocaller_may_see_dir: prune init slice
Serge Hallyn [Mon, 23 Nov 2015 20:41:24 +0000 (14:41 -0600)]
caller_may_see_dir: prune init slice

Otherwise systemd is denied permission to see cgroups in
name=systemd in the container.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoadd check for defunct processes at end
Serge Hallyn [Mon, 23 Nov 2015 01:48:10 +0000 (19:48 -0600)]
add check for defunct processes at end

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agolxcfs.c: minor cleanups
Serge Hallyn [Mon, 23 Nov 2015 01:47:24 +0000 (19:47 -0600)]
lxcfs.c: minor cleanups

Make some of these fns easier to read.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoget_task_reaper_pid: clean up forked child
Serge Hallyn [Mon, 23 Nov 2015 01:31:28 +0000 (19:31 -0600)]
get_task_reaper_pid: clean up forked child

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #54 from hallyn/2015-11-20/glibc
Serge Hallyn [Fri, 20 Nov 2015 21:17:59 +0000 (15:17 -0600)]
Merge pull request #54 from hallyn/2015-11-20/glibc

work around weird glibc assert

8 years agowork around weird glibc assert
Serge Hallyn [Fri, 20 Nov 2015 18:29:11 +0000 (12:29 -0600)]
work around weird glibc assert

tl;dr realloc only in BATCH_SIZE increments.

longer version
I can't reproduce it separately yet, but on i386 xenial, lxcfs
is failing on reading meminfo, hitting a glibc assertion in malloc.c:

lxcfs: malloc.c:2373: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 *(sizeof(size_t))) - 1)) & ~((2 *(sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long) old_end & pagemask) == 0)' failed.

The relevant glibc code:

  /*
     If not the first time through, we require old_size to be
     at least MINSIZE and to have prev_inuse set.
   */
  assert ((old_top == initial_top (av) && old_size == 0) ||
          ((unsigned long) (old_size) >= MINSIZE &&
           prev_inuse (old_top) &&
           ((unsigned long) old_end & pagemask) == 0));

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agotravis: install libattr1-dev to fix building of tests
Serge Hallyn [Thu, 19 Nov 2015 19:53:39 +0000 (13:53 -0600)]
travis: install libattr1-dev to fix building of tests

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoprint_subsystems: print to stderr
Serge Hallyn [Thu, 19 Nov 2015 19:35:43 +0000 (13:35 -0600)]
print_subsystems: print to stderr

Dietmar pointed out that printing to stdout seems to mess up
systemd logging.

Reported-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoAdd files needed to build tests to EXTRA_DIST
Serge Hallyn [Tue, 17 Nov 2015 22:53:29 +0000 (16:53 -0600)]
Add files needed to build tests to EXTRA_DIST

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoconfigure.ac: release v0.12
Serge Hallyn [Tue, 17 Nov 2015 21:21:42 +0000 (15:21 -0600)]
configure.ac: release v0.12

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoremove stray debug statement lxcfs-0.12
Serge Hallyn [Tue, 17 Nov 2015 00:45:49 +0000 (18:45 -0600)]
remove stray debug statement

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoImplement privilege check when moving tasks
Serge Hallyn [Fri, 13 Nov 2015 23:18:55 +0000 (17:18 -0600)]
Implement privilege check when moving tasks

When writing pids to a tasks file in lxcfs, lxcfs was checking
for privilege over the tasks file but not over the pid being
moved.  Since the cgm_movepid request is done as root on the host,
not with the requestor's credentials, we must copy the check which
cgmanager was doing to ensure that the requesting task is allowed
to change the victim task's cgroup membership.

This is CVE-2015-1344
https://bugs.launchpad.net/ubuntu/+source/lxcfs/+bug/1512854

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoFix checking of parent directories
Serge Hallyn [Fri, 13 Nov 2015 23:07:36 +0000 (17:07 -0600)]
Fix checking of parent directories

Taken from the justification in the launchpad bug:

To a task in freezer cgroup /a/b/c/d, it should appear that there are no
cgroups other than its descendents. Since this is a filesystem, we must have
the parent directories, but each parent cgroup should only contain the child
which the task can see.

So, when this task looks at /a/b, it should see only directory 'c' and no
files. Attempt to create /a/b/x should result in -EPERM, whether /a/b/x already
exists or not. Attempts to query /a/b/x should result in -ENOENT whether /a/b/x
exists or not. Opening /a/b/tasks should result in -ENOENT.

The caller_may_see_dir checks specifically whether a task may see a cgroup
directory - i.e. /a/b/x if opening /a/b/x/tasks, and /a/b/c/d if doing
opendir('/a/b/c/d').

caller_is_in_ancestor() will return true if the caller in /a/b/c/d looks at
/a/b/c/d/e. If the caller is in a child cgroup of the queried one - i.e. if the
task in /a/b/c/d queries /a/b, then *nextcg will container the next (the only)
directory which he can see in the path - 'c'.

Beyond this, regular DAC permissions should apply, with the
root-in-user-namespace privilege over its mapped uids being respected. The
fc_may_access check does this check for both directories and files.

This is CVE-2015-1342 (LP: #1508481)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #53 from hallyn/reboot
Serge Hallyn [Mon, 16 Nov 2015 20:18:26 +0000 (14:18 -0600)]
Merge pull request #53 from hallyn/reboot

Add a hook to make reboot sleep 0.5s

8 years agoAdd a hook to make reboot sleep 0.5s (v2)
Serge Hallyn [Thu, 12 Nov 2015 17:15:06 +0000 (11:15 -0600)]
Add a hook to make reboot sleep 0.5s (v2)

To ensure that the new container does not get cached directory entry
information from before we removed the container's cgroup using cgroupfs.

Changelog: make sure lxc.reboot.hook shows up in 'make dist'

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoLimit caching to 0.5s
Serge Hallyn [Thu, 12 Nov 2015 07:41:52 +0000 (01:41 -0600)]
Limit caching to 0.5s

If a cgroup is deleted or chmoded using the underlying cgroupfs, then we
want to minimize the amount of time during which we get stale info.  At the
same time, we don't want to do away with caching in the fuse kernel module
altogether, since calling out to userspace is expensive.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agochown cgroup files after chowning dirs
Serge Hallyn [Wed, 11 Nov 2015 01:38:40 +0000 (19:38 -0600)]
chown cgroup files after chowning dirs

cgmanager used to do this for us.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agomkdir: don't do it as setresid
Serge Hallyn [Wed, 11 Nov 2015 00:42:34 +0000 (18:42 -0600)]
mkdir: don't do it as setresid

First of all the code was wrong anyway.

Secondly, doing mkdir under setres{ug}id won't work because that
won't respect privilege that callers in user namespaces may have.

We check the permissions meticulously anyway, so do the mkdir as
root and then chown the new cgroup.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoImplement SwapTotal and SwapFree support for /proc/meminfo
Teemu Grönqvist [Sat, 31 Oct 2015 19:56:07 +0000 (21:56 +0200)]
Implement SwapTotal and SwapFree support for /proc/meminfo

[ Serge: s/cgm_/cgfs_/ ]

Signed-off-by: Teemu Grönqvist <teemu.gronqvist@net9.fi>
8 years agoMakefile.am: add cgfs.h to lxcfs_SOURCES
Serge Hallyn [Mon, 9 Nov 2015 20:48:10 +0000 (14:48 -0600)]
Makefile.am: add cgfs.h to lxcfs_SOURCES

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoUse cpuacct info for /proc/uptime idle field
Serge Hallyn [Mon, 9 Nov 2015 05:26:33 +0000 (23:26 -0600)]
Use cpuacct info for /proc/uptime idle field

As future work, the calculation of the reaper pid (to find its cpuacct cgroup)
and its reaper age could be combined into one step.

Closes #50

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoUse find_mounted_controller in get_pid_cgroup
Serge Hallyn [Mon, 9 Nov 2015 05:13:50 +0000 (23:13 -0600)]
Use find_mounted_controller in get_pid_cgroup

So that get_pid_cgroup("cpu", pid) works when cpu is comounted.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agofind_mounted_controller: support comounted controllers
Serge Hallyn [Mon, 9 Nov 2015 05:12:30 +0000 (23:12 -0600)]
find_mounted_controller: support comounted controllers

So that when an internal fn asks for a cgroup value in 'cpu',
it finds it under 'cpu,cpuacct'.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoconvert to using cgfs instead of cgmanager
Serge Hallyn [Mon, 2 Nov 2015 22:56:36 +0000 (16:56 -0600)]
convert to using cgfs instead of cgmanager

remove lxcfs_mkdir - it is not needed since we don't need a clean dbus connection

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agodrop support for precise's glib
Serge Hallyn [Sat, 31 Oct 2015 04:33:16 +0000 (23:33 -0500)]
drop support for precise's glib

since we can't run in travis anyway

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agook, don't run the tests after all bc we'd need to modprobe fuse
Serge Hallyn [Sat, 31 Oct 2015 04:32:25 +0000 (23:32 -0500)]
ok, don't run the tests after all bc we'd need to modprobe fuse

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agotravis: satisfy older glib by calling g_type_init
Serge Hallyn [Sat, 31 Oct 2015 04:27:12 +0000 (23:27 -0500)]
travis: satisfy older glib by calling g_type_init

Sad, really.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agotravis: forget it for now
Serge Hallyn [Sat, 31 Oct 2015 04:21:49 +0000 (23:21 -0500)]
travis: forget it for now

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agotravis: no really
Serge Hallyn [Sat, 31 Oct 2015 02:42:33 +0000 (21:42 -0500)]
travis: no really

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agotravis: noninteractive upgrade
Serge Hallyn [Sat, 31 Oct 2015 02:37:28 +0000 (21:37 -0500)]
travis: noninteractive upgrade

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>