linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Vyukov <dvyukov@google.com>
To: Andrey Konovalov <andreyknvl@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Andrew Morton <akpm@linux-foundation.org>,
	USB list <linux-usb@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Alexander Potapenko <glider@google.com>,
	Marco Elver <elver@google.com>
Subject: Re: [PATCH v4 3/7] kcov: move t->kcov assignments into kcov_start/stop
Date: Thu, 4 Jun 2020 14:09:20 +0200	[thread overview]
Message-ID: <CACT4Y+aH-ScaO4wwciZQbOB-tLXYun3vFwGNf8MOpCQ+JMbptg@mail.gmail.com> (raw)
In-Reply-To: <6644839d3567df61ade3c4b246a46cacbe4f9e11.1585233617.git.andreyknvl@google.com>

On Thu, Mar 26, 2020 at 3:44 PM Andrey Konovalov <andreyknvl@google.com> wrote:
>
> Every time kcov_start/stop() is called, t->kcov is also assigned, so
> move the assignment into the functions.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>

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

> ---
>  kernel/kcov.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/kernel/kcov.c b/kernel/kcov.c
> index cc5900ac2467..888d0a236b04 100644
> --- a/kernel/kcov.c
> +++ b/kernel/kcov.c
> @@ -309,10 +309,12 @@ void notrace __sanitizer_cov_trace_switch(u64 val, u64 *cases)
>  EXPORT_SYMBOL(__sanitizer_cov_trace_switch);
>  #endif /* ifdef CONFIG_KCOV_ENABLE_COMPARISONS */
>
> -static void kcov_start(struct task_struct *t, unsigned int size,
> -                       void *area, enum kcov_mode mode, int sequence)
> +static void kcov_start(struct task_struct *t, struct kcov *kcov,
> +                       unsigned int size, void *area, enum kcov_mode mode,
> +                       int sequence)
>  {
>         kcov_debug("t = %px, size = %u, area = %px\n", t, size, area);
> +       t->kcov = kcov;
>         /* Cache in task struct for performance. */
>         t->kcov_size = size;
>         t->kcov_area = area;
> @@ -326,6 +328,7 @@ static void kcov_stop(struct task_struct *t)
>  {
>         WRITE_ONCE(t->kcov_mode, KCOV_MODE_DISABLED);
>         barrier();
> +       t->kcov = NULL;
>         t->kcov_size = 0;
>         t->kcov_area = NULL;
>  }
> @@ -333,7 +336,6 @@ static void kcov_stop(struct task_struct *t)
>  static void kcov_task_reset(struct task_struct *t)
>  {
>         kcov_stop(t);
> -       t->kcov = NULL;
>         t->kcov_sequence = 0;
>         t->kcov_handle = 0;
>  }
> @@ -584,9 +586,8 @@ static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd,
>                         return mode;
>                 kcov_fault_in_area(kcov);
>                 kcov->mode = mode;
> -               kcov_start(t, kcov->size, kcov->area, kcov->mode,
> +               kcov_start(t, kcov, kcov->size, kcov->area, kcov->mode,
>                                 kcov->sequence);
> -               t->kcov = kcov;
>                 kcov->t = t;
>                 /* Put either in kcov_task_exit() or in KCOV_DISABLE. */
>                 kcov_get(kcov);
> @@ -778,7 +779,6 @@ void kcov_remote_start(u64 handle)
>         kcov = remote->kcov;
>         /* Put in kcov_remote_stop(). */
>         kcov_get(kcov);
> -       t->kcov = kcov;
>         /*
>          * Read kcov fields before unlock to prevent races with
>          * KCOV_DISABLE / kcov_remote_reset().
> @@ -792,7 +792,6 @@ void kcov_remote_start(u64 handle)
>         if (!area) {
>                 area = vmalloc(size * sizeof(unsigned long));
>                 if (!area) {
> -                       t->kcov = NULL;
>                         kcov_put(kcov);
>                         return;
>                 }
> @@ -800,7 +799,7 @@ void kcov_remote_start(u64 handle)
>         /* Reset coverage size. */
>         *(u64 *)area = 0;
>
> -       kcov_start(t, size, area, mode, sequence);
> +       kcov_start(t, kcov, size, area, mode, sequence);
>
>  }
>  EXPORT_SYMBOL(kcov_remote_start);
> @@ -873,7 +872,6 @@ void kcov_remote_stop(void)
>                 return;
>
>         kcov_stop(t);
> -       t->kcov = NULL;
>
>         spin_lock(&kcov->lock);
>         /*
> --
> 2.26.0.rc2.310.g2932bb562d-goog
>

  reply	other threads:[~2020-06-04 12:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 14:43 [PATCH v4 0/7] kcov: collect coverage from usb soft interrupts Andrey Konovalov
2020-03-26 14:44 ` [PATCH v4 1/7] kcov: cleanup debug messages Andrey Konovalov
2020-06-04 12:05   ` Dmitry Vyukov
2020-03-26 14:44 ` [PATCH v4 2/7] kcov: fix potential use-after-free in kcov_remote_start Andrey Konovalov
2020-06-04 12:06   ` Dmitry Vyukov
2020-03-26 14:44 ` [PATCH v4 3/7] kcov: move t->kcov assignments into kcov_start/stop Andrey Konovalov
2020-06-04 12:09   ` Dmitry Vyukov [this message]
2020-03-26 14:44 ` [PATCH v4 4/7] kcov: move t->kcov_sequence assignment Andrey Konovalov
2020-06-04 13:07   ` Dmitry Vyukov
2020-03-26 14:44 ` [PATCH v4 5/7] kcov: use t->kcov_mode as enabled indicator Andrey Konovalov
2020-06-04 13:07   ` Dmitry Vyukov
2020-03-26 14:44 ` [PATCH v4 6/7] kcov: collect coverage from interrupts Andrey Konovalov
2020-06-04 13:11   ` Dmitry Vyukov
2020-03-26 14:44 ` [PATCH v4 7/7] usb: core: kcov: collect coverage from usb complete callback Andrey Konovalov
2020-06-04 13:12   ` Dmitry Vyukov
2020-06-04 13:46 ` [PATCH v4 0/7] kcov: collect coverage from usb soft interrupts Andrey Konovalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACT4Y+aH-ScaO4wwciZQbOB-tLXYun3vFwGNf8MOpCQ+JMbptg@mail.gmail.com \
    --to=dvyukov@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).