[lxc-devel] [PATCH lxcfs 4/5] cgfs: fix dorealloc's batch allocation

Serge Hallyn serge.hallyn at ubuntu.com
Fri Jan 8 21:13:33 UTC 2016


It makes sense.

I was going to give this a few hours before releasing 0.16.

There's one more new commit in git head, can you try the very latest
and make sure it works for you?

Quoting Mathias Gibbens (mathias at calenhad.com):
>   This patch also seems to fix a segfault I encountered today after
> upgrading to lxcfs-0.15. My host is Debian jessie 64bit running
> unprivileged jessie containers with systemd as their init. lxcfs-0.13
> works, lxcfs-0.15 segfaults, and lxcfs-git at 1204f57 works again.
> 
>   In the short time since lxcfs-0.15 is out, can anyone else confirm
> this?
> 
> Mathias
> 
> On Fri, 2016-01-08 at 20:10 +0000, Serge Hallyn wrote:
> > > From 24e98d74ca279ed2dc8e5a025add5a00737ba952 Mon Sep 17 00:00:00
> > 2001
> > > From: Wolfgang Bumiller <w.bumiller at proxmox.com>
> > > Date: Fri, 8 Jan 2016 11:09:57 +0100
> > > Subject: [PATCH lxcfs] 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 at proxmox.com>
> > 
> > Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
> > 
> > Looks good to me, thanks.
> > 
> > > ---
> > >  cgfs.c  | 9 +--------
> > >  lxcfs.c | 2 +-
> > >  2 files changed, 2 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/cgfs.c b/cgfs.c
> > > index 1f31ed1..e6330e3 100644
> > > --- a/cgfs.c
> > > +++ b/cgfs.c
> > > @@ -77,14 +77,7 @@ static void dorealloc(char **mem, size_t oldlen,
> > size_t
> > > newlen)
> > >       int newbatches = (newlen / BATCH_SIZE) + 1;
> > >       int oldbatches = (oldlen / BATCH_SIZE) + 1;
> > >  
> > > -     if (newbatches <= oldbatches)
> > > -             return;
> > > -
> > > -     if (!*mem) {
> > > -             do {
> > > -                     *mem = malloc(newbatches * BATCH_SIZE);
> > > -             } while (!*mem);
> > > -     } else {
> > > +     if (!*mem || newbatches > oldbatches) {
> > >               char *tmp;
> > >               do {
> > >                       tmp = realloc(*mem, newbatches * BATCH_SIZE);
> > > -- 
> > > 2.1.4
> > > 



> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel



More information about the lxc-devel mailing list