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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 4 Jun 2020 15:07:33 +0200
From:   Dmitry Vyukov <dvyukov@...gle.com>
To:     Andrey Konovalov <andreyknvl@...gle.com>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Alan Stern <stern@...land.harvard.edu>,
        Andrew Morton <akpm@...ux-foundation.org>,
        USB list <linux-usb@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Alexander Potapenko <glider@...gle.com>,
        Marco Elver <elver@...gle.com>
Subject: Re: [PATCH v4 5/7] kcov: use t->kcov_mode as enabled indicator

On Thu, Mar 26, 2020 at 3:44 PM Andrey Konovalov <andreyknvl@...gle.com> wrote:
>
> Currently kcov_remote_start() and kcov_remote_stop() check t->kcov to
> find out whether the coverage is already being collected by the
> current task. Use t->kcov_mode for that instead. This doesn't change
> the overall behavior in any way, but serves as a preparation for the
> following softirq coverage collection support patch.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@...gle.com>

Reviewed-by: Dmitry Vyukov <dvyukov@...gle.com>

> ---
>  kernel/kcov.c | 32 +++++++++++++++++++++++---------
>  1 file changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/kernel/kcov.c b/kernel/kcov.c
> index b985b7a72870..e43f06b5b2e4 100644
> --- a/kernel/kcov.c
> +++ b/kernel/kcov.c
> @@ -746,26 +746,33 @@ static const struct file_operations kcov_fops = {
>   * In turns kcov_remote_stop() clears those pointers from task_struct to stop
>   * collecting coverage and copies all collected coverage into the kcov area.
>   */
> +
> +static inline bool kcov_mode_enabled(unsigned int mode)
> +{
> +       return (mode & ~KCOV_IN_CTXSW) != KCOV_MODE_DISABLED;
> +}
> +
>  void kcov_remote_start(u64 handle)
>  {
> +       struct task_struct *t = current;
>         struct kcov_remote *remote;
>         struct kcov *kcov;
> +       unsigned int mode;
>         void *area;
> -       struct task_struct *t;
>         unsigned int size;
> -       enum kcov_mode mode;
>         int sequence;
>
>         if (WARN_ON(!kcov_check_handle(handle, true, true, true)))
>                 return;
>         if (WARN_ON(!in_task()))
>                 return;
> -       t = current;
> +
>         /*
>          * Check that kcov_remote_start is not called twice
>          * nor called by user tasks (with enabled kcov).
>          */
> -       if (WARN_ON(t->kcov))
> +       mode = READ_ONCE(t->kcov_mode);
> +       if (WARN_ON(kcov_mode_enabled(mode)))
>                 return;
>
>         kcov_debug("handle = %llx\n", handle);
> @@ -863,13 +870,20 @@ static void kcov_move_area(enum kcov_mode mode, void *dst_area,
>  void kcov_remote_stop(void)
>  {
>         struct task_struct *t = current;
> -       struct kcov *kcov = t->kcov;
> -       void *area = t->kcov_area;
> -       unsigned int size = t->kcov_size;
> -       int sequence = t->kcov_sequence;
> +       struct kcov *kcov;
> +       unsigned int mode;
> +       void *area;
> +       unsigned int size;
> +       int sequence;
>
> -       if (!kcov)
> +       mode = READ_ONCE(t->kcov_mode);
> +       barrier();
> +       if (!kcov_mode_enabled(mode))
>                 return;
> +       kcov = t->kcov;
> +       area = t->kcov_area;
> +       size = t->kcov_size;
> +       sequence = t->kcov_sequence;
>
>         kcov_stop(t);
>
> --
> 2.26.0.rc2.310.g2932bb562d-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ