Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1607433 > unrolled thread
| Started by | Colin King <colin.king@canonical.com> |
|---|---|
| First post | 2017-03-23 13:30 +0100 |
| Last post | 2017-03-24 04:50 +0100 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer Colin King <colin.king@canonical.com> - 2017-03-23 13:30 +0100
Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer Chris Wilson <chris@chris-wilson.co.uk> - 2017-03-23 13:40 +0100
Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer Frans Klaver <fransklaver@gmail.com> - 2017-03-23 14:50 +0100
Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer Zhenyu Wang <zhenyuw@linux.intel.com> - 2017-03-24 04:50 +0100
| From | Colin King <colin.king@canonical.com> |
|---|---|
| Date | 2017-03-23 13:30 +0100 |
| Subject | [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer |
| Message-ID | <toa2l-28N-5@gated-at.bofh.it> |
From: Colin Ian King <colin.king@canonical.com>
info is being checked to see if it is a null pointer, however, vpgu is
dereferencing info before this check, leading to a potential null
pointer dereference. If info is null, then the error message being
printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
use a null vpgu as the macro has a sanity check to see if vpgu is null,
so this is OK.
Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")
Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 1ea3eb270de8..f8619a772c44 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
{
- struct intel_vgpu *vgpu = info->vgpu;
-
if (!info) {
+ struct intel_vgpu *vgpu = NULL;
+
gvt_vgpu_err("kvmgt_guest_info invalid\n");
return false;
}
--
2.11.0
[toc] | [next] | [standalone]
| From | Chris Wilson <chris@chris-wilson.co.uk> |
|---|---|
| Date | 2017-03-23 13:40 +0100 |
| Subject | Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer |
| Message-ID | <toac2-2e7-11@gated-at.bofh.it> |
| In reply to | #1607433 |
On Thu, Mar 23, 2017 at 12:22:30PM +0000, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > info is being checked to see if it is a null pointer, however, vpgu is > dereferencing info before this check, leading to a potential null > pointer dereference. If info is null, then the error message being > printed by macro gvt_vgpu_err and this requires vpgu to exist. We can > use a null vpgu as the macro has a sanity check to see if vpgu is null, > so this is OK. It is never NULL, it gets checked by its only caller. -Chris -- Chris Wilson, Intel Open Source Technology Centre
[toc] | [prev] | [next] | [standalone]
| From | Frans Klaver <fransklaver@gmail.com> |
|---|---|
| Date | 2017-03-23 14:50 +0100 |
| Subject | Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer |
| Message-ID | <tobhM-2SB-19@gated-at.bofh.it> |
| In reply to | #1607433 |
On Thu, Mar 23, 2017 at 1:22 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> info is being checked to see if it is a null pointer, however, vpgu is
> dereferencing info before this check, leading to a potential null
> pointer dereference. If info is null, then the error message being
> printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> use a null vpgu as the macro has a sanity check to see if vpgu is null,
> so this is OK.
>
> Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")
s,nefore,before,
>
> Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index 1ea3eb270de8..f8619a772c44 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
>
> static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
> {
> - struct intel_vgpu *vgpu = info->vgpu;
> -
> if (!info) {
> + struct intel_vgpu *vgpu = NULL;
> +
> gvt_vgpu_err("kvmgt_guest_info invalid\n");
> return false;
> }
Does this mean the original gvt_err() macro is no longer there?
And apparently gvt_vgpu_err is a macro that depends on the specifics
of its environment? Yikes.
Cheers,
Frans
[toc] | [prev] | [next] | [standalone]
| From | Zhenyu Wang <zhenyuw@linux.intel.com> |
|---|---|
| Date | 2017-03-24 04:50 +0100 |
| Subject | Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer |
| Message-ID | <toooF-3Yi-3@gated-at.bofh.it> |
| In reply to | #1607509 |
[Multipart message — attachments visible in raw view] — view raw
On 2017.03.23 14:43:44 +0100, Frans Klaver wrote:
> On Thu, Mar 23, 2017 at 1:22 PM, Colin King <colin.king@canonical.com> wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > info is being checked to see if it is a null pointer, however, vpgu is
> > dereferencing info before this check, leading to a potential null
> > pointer dereference. If info is null, then the error message being
> > printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> > use a null vpgu as the macro has a sanity check to see if vpgu is null,
> > so this is OK.
> >
> > Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")
>
> s,nefore,before,
>
>
> >
> > Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> > index 1ea3eb270de8..f8619a772c44 100644
> > --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> > +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> > @@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
> >
> > static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
> > {
> > - struct intel_vgpu *vgpu = info->vgpu;
> > -
> > if (!info) {
> > + struct intel_vgpu *vgpu = NULL;
> > +
> > gvt_vgpu_err("kvmgt_guest_info invalid\n");
> > return false;
> > }
>
> Does this mean the original gvt_err() macro is no longer there?
>
> And apparently gvt_vgpu_err is a macro that depends on the specifics
> of its environment? Yikes.
>
The null check is redundant there, we can just remove that block and extra
vgpu variable.
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web