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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 2 Feb 2021 16:45:06 +0100
From:   SeongJae Park <sjpark@...zon.com>
To:     Shakeel Butt <shakeelb@...gle.com>
CC:     SeongJae Park <sjpark@...zon.com>,
        Andrea Arcangeli <aarcange@...hat.com>, <acme@...nel.org>,
        <alexander.shishkin@...ux.intel.com>, <amit@...nel.org>,
        <benh@...nel.crashing.org>, <brendan.d.gregg@...il.com>,
        Brendan Higgins <brendanhiggins@...gle.com>,
        Qian Cai <cai@....pw>,
        Colin Ian King <colin.king@...onical.com>,
        Jonathan Corbet <corbet@....net>,
        "David Hildenbrand" <david@...hat.com>, <dwmw@...zon.com>,
        Marco Elver <elver@...gle.com>, "Du, Fan" <fan.du@...el.com>,
        <foersleo@...zon.de>, "Greg Thelen" <gthelen@...gle.com>,
        Ian Rogers <irogers@...gle.com>, <jolsa@...hat.com>,
        "Kirill A. Shutemov" <kirill@...temov.name>,
        Mark Rutland <mark.rutland@....com>,
        Mel Gorman <mgorman@...e.de>, Minchan Kim <minchan@...nel.org>,
        Ingo Molnar <mingo@...hat.com>, <namhyung@...nel.org>,
        "Peter Zijlstra (Intel)" <peterz@...radead.org>,
        Randy Dunlap <rdunlap@...radead.org>,
        Rik van Riel <riel@...riel.com>,
        David Rientjes <rientjes@...gle.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Mike Rapoport <rppt@...nel.org>, <sblbir@...zon.com>,
        Shuah Khan <shuah@...nel.org>, <sj38.park@...il.com>,
        <snu@...zon.de>, Vlastimil Babka <vbabka@...e.cz>,
        Vladimir Davydov <vdavydov.dev@...il.com>,
        Yang Shi <yang.shi@...ux.alibaba.com>,
        Huang Ying <ying.huang@...el.com>, <zgf574564920@...il.com>,
        <linux-damon@...zon.com>, Linux MM <linux-mm@...ck.org>,
        <linux-doc@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v23 07/15] mm/damon: Implement a debugfs-based user space interface

On Tue, 2 Feb 2021 07:07:24 -0800 Shakeel Butt <shakeelb@...gle.com> wrote:

> On Tue, Feb 2, 2021 at 2:30 AM SeongJae Park <sjpark@...zon.com> wrote:
> >
> >> On Mon, 1 Feb 2021 09:37:39 -0800 Shakeel Butt <shakeelb@...gle.com> wrote:
> >>
> >>> On Tue, Dec 15, 2020 at 3:59 AM SeongJae Park <sjpark@...zon.com> wrote:
> >>>>
> >>>> From: SeongJae Park <sjpark@...zon.de>
> >>>>
> >>>> DAMON is designed to be used by kernel space code such as the memory
> >>>> management subsystems, and therefore it provides only kernel space API.
> >>>
> >>> Which kernel space APIs are being referred here?
> >>
> >> The symbols in 'include/linux/damon.h'
> >>
> >>>
> >>>> That said, letting the user space control DAMON could provide some
> >>>> benefits to them.  For example, it will allow user space to analyze
> >>>> their specific workloads and make their own special optimizations.
> >>>>
> >>>> For such cases, this commit implements a simple DAMON application kernel
> >>>> module, namely 'damon-dbgfs', which merely wraps the DAMON api and
> >>>> exports those to the user space via the debugfs.
> >>>>
> >> [...]
> >>>> +static ssize_t dbgfs_target_ids_write(struct file *file,
> >>>> +               const char __user *buf, size_t count, loff_t *ppos)
> >>>> +{
> >>>> +       struct damon_ctx *ctx = file->private_data;
> >>>> +       char *kbuf, *nrs;
> >>>> +       unsigned long *targets;
> >>>> +       ssize_t nr_targets;
> >>>> +       ssize_t ret = count;
> >>>> +       int i;
> >>>> +       int err;
> >>>> +
> >>>> +       kbuf = user_input_str(buf, count, ppos);
> >>>> +       if (IS_ERR(kbuf))
> >>>> +               return PTR_ERR(kbuf);
> >>>> +
> >>>> +       nrs = kbuf;
> >>>> +
> >>>> +       targets = str_to_target_ids(nrs, ret, &nr_targets);
> >>>> +       if (!targets) {
> >>>> +               ret = -ENOMEM;
> >>>> +               goto out;
> >>>> +       }
> >>>> +
> >>>> +       if (targetid_is_pid(ctx)) {
> >>>> +               for (i = 0; i < nr_targets; i++)
> >>>> +                       targets[i] = (unsigned long)find_get_pid(
> >>>> +                                       (int)targets[i]);
> >>>> +       }
> >>>> +
> >>>> +       mutex_lock(&ctx->kdamond_lock);
> >>>> +       if (ctx->kdamond) {
> >>>> +               ret = -EINVAL;
> >>>> +               goto unlock_out;
> >>>
> >>> You need to put_pid on the targets array.
> >>
> >> Good catch!
> >>
> >>>
> >>>> +       }
> >>>> +
> >>>> +       err = damon_set_targets(ctx, targets, nr_targets);
> >>>> +       if (err)
> >>>> +               ret = err;
> >>>
> >>> You need to handle the partial failure from damon_set_targets().
> >>
> >> My intention is to keep partial success as is.
> >
> > But, we should put_pid() partial failures...  I will simply make this to
> > completely fail with no registered target.
> >
> 
> You can simplify by simply restricting to one pid/target per each write syscall.

Right, thanks for the suggestion.  However, I already almost finished writing
the fix.  If there is no other concern, I'd like to keep current interface.


Thanks,
SeongJae Park

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ