lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJD7tkZNAts_4M9TZx02L1y24hp5ty4H5vgrzryZk4a_uFR=6Q@mail.gmail.com>
Date:   Thu, 7 Apr 2022 22:00:07 -0700
From:   Yosry Ahmed <yosryahmed@...gle.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     David Rientjes <rientjes@...gle.com>, Tejun Heo <tj@...nel.org>,
        Zefan Li <lizefan.x@...edance.com>,
        Jonathan Corbet <corbet@....net>,
        Shuah Khan <shuah@...nel.org>, Yu Zhao <yuzhao@...gle.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Wei Xu <weixugc@...gle.com>, Greg Thelen <gthelen@...gle.com>,
        Chen Wandun <chenwandun@...wei.com>,
        Vaibhav Jain <vaibhav@...ux.ibm.com>,
        Johannes Weiner <hannes@...xchg.org>, Huang@...gle.com,
        Ying <ying.huang@...el.com>,
        Michal Koutný <mkoutny@...e.com>,
        Tim Chen <tim.c.chen@...ux.intel.com>, cgroups@...r.kernel.org,
        linux-doc@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linux-MM <linux-mm@...ck.org>, linux-kselftest@...r.kernel.org,
        Michal Hocko <mhocko@...nel.org>,
        Shakeel Butt <shakeelb@...gle.com>,
        Roman Gushchin <roman.gushchin@...ux.dev>
Subject: Re: [PATCH v2 3/4] selftests: cgroup: fix alloc_anon_noexit()
 instantly freeing memory

On Thu, Apr 7, 2022 at 4:04 PM Yosry Ahmed <yosryahmed@...gle.com> wrote:
>
> On Thu, Apr 7, 2022 at 3:43 PM Yosry Ahmed <yosryahmed@...gle.com> wrote:
> >
> > Currently, alloc_anon_noexit() calls alloc_anon() which instantly frees
> > the allocated memory. alloc_anon_noexit() is usually used with
> > cg_run_nowait() to run a process in the background that allocates
> > memory. It makes sense for the background process to keep the memory
> > allocated and not instantly free it (otherwise there is no point of
> > running it in the background).
> >
> > Signed-off-by: Yosry Ahmed <yosryahmed@...gle.com>
> > ---
> >  tools/testing/selftests/cgroup/test_memcontrol.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c
> > index 36ccf2322e21..c1ec71d83af7 100644
> > --- a/tools/testing/selftests/cgroup/test_memcontrol.c
> > +++ b/tools/testing/selftests/cgroup/test_memcontrol.c
> > @@ -211,13 +211,18 @@ static int alloc_pagecache_50M_noexit(const char *cgroup, void *arg)
> >  static int alloc_anon_noexit(const char *cgroup, void *arg)
> >  {
> >         int ppid = getppid();
> > +       size_t size = (unsigned long)arg;
> > +       char *buf, *ptr;
> >
> > -       if (alloc_anon(cgroup, arg))
> > -               return -1;
> > +       buf = malloc(size);
> > +       for (ptr = buf; ptr < buf + size; ptr += PAGE_SIZE)
> > +               *ptr = 0;
> >
> >         while (getppid() == ppid)
> >                 sleep(1);
> >
> > +       printf("Freeing buffer");
>
> Hey Andew,
>
> I am very sorry but I left a debugging printf there by mistake. If
> it's no hassle, do you mind removing it from the patch (assuming I
> won't need to send a v3 anyway)?

Never mind I already sent v3 and removed it with other fixes.
>
> Thanks!
>
> > +       free(buf);
> >         return 0;
> >  }
> >
> > --
> > 2.35.1.1178.g4f1659d476-goog
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ