All of lore.kernel.org
 help / color / mirror / Atom feed
From: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
To: Emil Velikov <emil.l.velikov@gmail.com>
Cc: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Dave Airlie" <airlied@linux.ie>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Christian König" <christian.koenig@amd.com>,
	"ML dri-devel" <dri-devel@lists.freedesktop.org>,
	"Intel Graphics Development" <intel-gfx@lists.freedesktop.org>,
	"Linux-Kernel@Vger. Kernel. Org" <linux-kernel@vger.kernel.org>,
	linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
	skhan@linuxfoundation.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-kernel-mentees@lists.linuxfoundation.org,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>
Subject: Re: [PATCH v5 3/3] drm: protect drm_master pointers in drm_lease.c
Date: Wed, 30 Jun 2021 14:37:23 +0800	[thread overview]
Message-ID: <e2ca777f-f185-688a-5813-0ff2e5025f77@gmail.com> (raw)
In-Reply-To: <CACvgo514T=PZCWwhNsYqCC504SJ+2WivcRtmHhDoKsWMSLFU4A@mail.gmail.com>

On 30/6/21 8:16 am, Emil Velikov wrote:
> Hi Desmond,
> 
> Couple of small suggestions, with those the series is:
> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
> 
> On Tue, 29 Jun 2021 at 04:38, Desmond Cheong Zhi Xi
> <desmondcheongzx@gmail.com> wrote:
> 
>> @@ -128,13 +137,20 @@ bool drm_lease_held(struct drm_file *file_priv, int id)
>>          struct drm_master *master;
>>          bool ret;
>>
>> -       if (!file_priv || !file_priv->master || !file_priv->master->lessor)
>> +       if (!file_priv)
>>                  return true;
>>
>> -       master = file_priv->master;
>> +       master = drm_file_get_master(file_priv);
>> +       if (master == NULL)
>> +               return true;
>> +       if (!master->lessor) {
>> +               drm_master_put(&master);
>> +               return true;
> 
> Let's add a "ret = true; goto unlock;" here, so we can have a single
> drm_master_put() in the function.
> Nearly all code paths touched by this patch already follow this approach.
> 
>> @@ -154,10 +170,16 @@ uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs_in)
>>          int count_in, count_out;
>>          uint32_t crtcs_out = 0;
>>
>> -       if (!file_priv || !file_priv->master || !file_priv->master->lessor)
>> +       if (!file_priv)
>>                  return crtcs_in;
>>
>> -       master = file_priv->master;
>> +       master = drm_file_get_master(file_priv);
>> +       if (master == NULL)
>> +               return crtcs_in;
>> +       if (!master->lessor) {
>> +               drm_master_put(&master);
>> +               return crtcs_in;
> 
> Ditto
> 
> Thanks
> Emil
> 

Sounds good to me, I'll revise these functions. Thanks for the review 
and suggestions, Emil.

Best wishes,
Desmond

WARNING: multiple messages have this Message-ID (diff)
From: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
To: Emil Velikov <emil.l.velikov@gmail.com>
Cc: "Thomas Zimmermann" <tzimmermann@suse.de>,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>,
	"Dave Airlie" <airlied@linux.ie>,
	"Intel Graphics Development" <intel-gfx@lists.freedesktop.org>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Linux-Kernel@Vger. Kernel. Org" <linux-kernel@vger.kernel.org>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Christian König" <christian.koenig@amd.com>,
	linaro-mm-sig@lists.linaro.org,
	"ML dri-devel" <dri-devel@lists.freedesktop.org>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	linux-kernel-mentees@lists.linuxfoundation.org,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH v5 3/3] drm: protect drm_master pointers in drm_lease.c
Date: Wed, 30 Jun 2021 14:37:23 +0800	[thread overview]
Message-ID: <e2ca777f-f185-688a-5813-0ff2e5025f77@gmail.com> (raw)
In-Reply-To: <CACvgo514T=PZCWwhNsYqCC504SJ+2WivcRtmHhDoKsWMSLFU4A@mail.gmail.com>

On 30/6/21 8:16 am, Emil Velikov wrote:
> Hi Desmond,
> 
> Couple of small suggestions, with those the series is:
> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
> 
> On Tue, 29 Jun 2021 at 04:38, Desmond Cheong Zhi Xi
> <desmondcheongzx@gmail.com> wrote:
> 
>> @@ -128,13 +137,20 @@ bool drm_lease_held(struct drm_file *file_priv, int id)
>>          struct drm_master *master;
>>          bool ret;
>>
>> -       if (!file_priv || !file_priv->master || !file_priv->master->lessor)
>> +       if (!file_priv)
>>                  return true;
>>
>> -       master = file_priv->master;
>> +       master = drm_file_get_master(file_priv);
>> +       if (master == NULL)
>> +               return true;
>> +       if (!master->lessor) {
>> +               drm_master_put(&master);
>> +               return true;
> 
> Let's add a "ret = true; goto unlock;" here, so we can have a single
> drm_master_put() in the function.
> Nearly all code paths touched by this patch already follow this approach.
> 
>> @@ -154,10 +170,16 @@ uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs_in)
>>          int count_in, count_out;
>>          uint32_t crtcs_out = 0;
>>
>> -       if (!file_priv || !file_priv->master || !file_priv->master->lessor)
>> +       if (!file_priv)
>>                  return crtcs_in;
>>
>> -       master = file_priv->master;
>> +       master = drm_file_get_master(file_priv);
>> +       if (master == NULL)
>> +               return crtcs_in;
>> +       if (!master->lessor) {
>> +               drm_master_put(&master);
>> +               return crtcs_in;
> 
> Ditto
> 
> Thanks
> Emil
> 

Sounds good to me, I'll revise these functions. Thanks for the review 
and suggestions, Emil.

Best wishes,
Desmond
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

WARNING: multiple messages have this Message-ID (diff)
From: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
To: Emil Velikov <emil.l.velikov@gmail.com>
Cc: "Thomas Zimmermann" <tzimmermann@suse.de>,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>,
	"Dave Airlie" <airlied@linux.ie>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Intel Graphics Development" <intel-gfx@lists.freedesktop.org>,
	"Linux-Kernel@Vger. Kernel. Org" <linux-kernel@vger.kernel.org>,
	"Christian König" <christian.koenig@amd.com>,
	linaro-mm-sig@lists.linaro.org,
	"ML dri-devel" <dri-devel@lists.freedesktop.org>,
	skhan@linuxfoundation.org,
	linux-kernel-mentees@lists.linuxfoundation.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH v5 3/3] drm: protect drm_master pointers in drm_lease.c
Date: Wed, 30 Jun 2021 14:37:23 +0800	[thread overview]
Message-ID: <e2ca777f-f185-688a-5813-0ff2e5025f77@gmail.com> (raw)
In-Reply-To: <CACvgo514T=PZCWwhNsYqCC504SJ+2WivcRtmHhDoKsWMSLFU4A@mail.gmail.com>

On 30/6/21 8:16 am, Emil Velikov wrote:
> Hi Desmond,
> 
> Couple of small suggestions, with those the series is:
> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
> 
> On Tue, 29 Jun 2021 at 04:38, Desmond Cheong Zhi Xi
> <desmondcheongzx@gmail.com> wrote:
> 
>> @@ -128,13 +137,20 @@ bool drm_lease_held(struct drm_file *file_priv, int id)
>>          struct drm_master *master;
>>          bool ret;
>>
>> -       if (!file_priv || !file_priv->master || !file_priv->master->lessor)
>> +       if (!file_priv)
>>                  return true;
>>
>> -       master = file_priv->master;
>> +       master = drm_file_get_master(file_priv);
>> +       if (master == NULL)
>> +               return true;
>> +       if (!master->lessor) {
>> +               drm_master_put(&master);
>> +               return true;
> 
> Let's add a "ret = true; goto unlock;" here, so we can have a single
> drm_master_put() in the function.
> Nearly all code paths touched by this patch already follow this approach.
> 
>> @@ -154,10 +170,16 @@ uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs_in)
>>          int count_in, count_out;
>>          uint32_t crtcs_out = 0;
>>
>> -       if (!file_priv || !file_priv->master || !file_priv->master->lessor)
>> +       if (!file_priv)
>>                  return crtcs_in;
>>
>> -       master = file_priv->master;
>> +       master = drm_file_get_master(file_priv);
>> +       if (master == NULL)
>> +               return crtcs_in;
>> +       if (!master->lessor) {
>> +               drm_master_put(&master);
>> +               return crtcs_in;
> 
> Ditto
> 
> Thanks
> Emil
> 

Sounds good to me, I'll revise these functions. Thanks for the review 
and suggestions, Emil.

Best wishes,
Desmond

WARNING: multiple messages have this Message-ID (diff)
From: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
To: Emil Velikov <emil.l.velikov@gmail.com>
Cc: "Thomas Zimmermann" <tzimmermann@suse.de>,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>,
	"Dave Airlie" <airlied@linux.ie>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Intel Graphics Development" <intel-gfx@lists.freedesktop.org>,
	"Linux-Kernel@Vger. Kernel. Org" <linux-kernel@vger.kernel.org>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Christian König" <christian.koenig@amd.com>,
	linaro-mm-sig@lists.linaro.org,
	"ML dri-devel" <dri-devel@lists.freedesktop.org>,
	skhan@linuxfoundation.org,
	linux-kernel-mentees@lists.linuxfoundation.org,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	linux-media@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH v5 3/3] drm: protect drm_master pointers in drm_lease.c
Date: Wed, 30 Jun 2021 14:37:23 +0800	[thread overview]
Message-ID: <e2ca777f-f185-688a-5813-0ff2e5025f77@gmail.com> (raw)
In-Reply-To: <CACvgo514T=PZCWwhNsYqCC504SJ+2WivcRtmHhDoKsWMSLFU4A@mail.gmail.com>

On 30/6/21 8:16 am, Emil Velikov wrote:
> Hi Desmond,
> 
> Couple of small suggestions, with those the series is:
> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
> 
> On Tue, 29 Jun 2021 at 04:38, Desmond Cheong Zhi Xi
> <desmondcheongzx@gmail.com> wrote:
> 
>> @@ -128,13 +137,20 @@ bool drm_lease_held(struct drm_file *file_priv, int id)
>>          struct drm_master *master;
>>          bool ret;
>>
>> -       if (!file_priv || !file_priv->master || !file_priv->master->lessor)
>> +       if (!file_priv)
>>                  return true;
>>
>> -       master = file_priv->master;
>> +       master = drm_file_get_master(file_priv);
>> +       if (master == NULL)
>> +               return true;
>> +       if (!master->lessor) {
>> +               drm_master_put(&master);
>> +               return true;
> 
> Let's add a "ret = true; goto unlock;" here, so we can have a single
> drm_master_put() in the function.
> Nearly all code paths touched by this patch already follow this approach.
> 
>> @@ -154,10 +170,16 @@ uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs_in)
>>          int count_in, count_out;
>>          uint32_t crtcs_out = 0;
>>
>> -       if (!file_priv || !file_priv->master || !file_priv->master->lessor)
>> +       if (!file_priv)
>>                  return crtcs_in;
>>
>> -       master = file_priv->master;
>> +       master = drm_file_get_master(file_priv);
>> +       if (master == NULL)
>> +               return crtcs_in;
>> +       if (!master->lessor) {
>> +               drm_master_put(&master);
>> +               return crtcs_in;
> 
> Ditto
> 
> Thanks
> Emil
> 

Sounds good to me, I'll revise these functions. Thanks for the review 
and suggestions, Emil.

Best wishes,
Desmond
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2021-06-30  6:37 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-29  3:37 [PATCH v5 0/3] drm: address potential UAF bugs with drm_master ptrs Desmond Cheong Zhi Xi
2021-06-29  3:37 ` [Intel-gfx] " Desmond Cheong Zhi Xi
2021-06-29  3:37 ` Desmond Cheong Zhi Xi
2021-06-29  3:37 ` Desmond Cheong Zhi Xi
2021-06-29  3:37 ` [PATCH v5 1/3] drm: avoid circular locks in drm_mode_getconnector Desmond Cheong Zhi Xi
2021-06-29  3:37   ` [Intel-gfx] " Desmond Cheong Zhi Xi
2021-06-29  3:37   ` Desmond Cheong Zhi Xi
2021-06-29  3:37   ` Desmond Cheong Zhi Xi
2021-06-29  3:37 ` [PATCH v5 2/3] drm: add a locked version of drm_is_current_master Desmond Cheong Zhi Xi
2021-06-29  3:37   ` [Intel-gfx] " Desmond Cheong Zhi Xi
2021-06-29  3:37   ` Desmond Cheong Zhi Xi
2021-06-29  3:37   ` Desmond Cheong Zhi Xi
2021-06-29  3:37 ` [PATCH v5 3/3] drm: protect drm_master pointers in drm_lease.c Desmond Cheong Zhi Xi
2021-06-29  3:37   ` [Intel-gfx] " Desmond Cheong Zhi Xi
2021-06-29  3:37   ` Desmond Cheong Zhi Xi
2021-06-29  3:37   ` Desmond Cheong Zhi Xi
2021-06-29 16:07   ` Daniel Vetter
2021-06-29 16:07     ` [Intel-gfx] " Daniel Vetter
2021-06-29 16:07     ` Daniel Vetter
2021-06-29 16:07     ` Daniel Vetter
2021-06-30  7:18     ` Desmond Cheong Zhi Xi
2021-06-30  7:18       ` [Intel-gfx] " Desmond Cheong Zhi Xi
2021-06-30  7:18       ` Desmond Cheong Zhi Xi
2021-06-30  8:02       ` Daniel Vetter
2021-06-30  8:02         ` [Intel-gfx] " Daniel Vetter
2021-06-30  8:02         ` Daniel Vetter
2021-06-30  8:02         ` Daniel Vetter
2021-06-30 10:39         ` Desmond Cheong Zhi Xi
2021-06-30 10:39           ` [Intel-gfx] " Desmond Cheong Zhi Xi
2021-06-30 10:39           ` Desmond Cheong Zhi Xi
2021-06-30 10:39           ` Desmond Cheong Zhi Xi
2021-06-30  0:16   ` Emil Velikov
2021-06-30  0:16     ` [Intel-gfx] " Emil Velikov
2021-06-30  0:16     ` Emil Velikov
2021-06-30  0:16     ` Emil Velikov
2021-06-30  6:37     ` Desmond Cheong Zhi Xi [this message]
2021-06-30  6:37       ` [Intel-gfx] " Desmond Cheong Zhi Xi
2021-06-30  6:37       ` Desmond Cheong Zhi Xi
2021-06-30  6:37       ` Desmond Cheong Zhi Xi
2021-06-29 17:15 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm: address potential UAF bugs with drm_master ptrs (rev2) Patchwork
2021-06-29 17:30 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-06-29 22:38 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2021-06-30 17:38 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for drm: address potential UAF bugs with drm_master ptrs (rev3) Patchwork

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=e2ca777f-f185-688a-5813-0ff2e5025f77@gmail.com \
    --to=desmondcheongzx@gmail.com \
    --cc=airlied@linux.ie \
    --cc=christian.koenig@amd.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=sumit.semwal@linaro.org \
    --cc=tzimmermann@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.