From: Alistair Popple <apopple@nvidia.com>
To: Colin King <colin.king@canonical.com>
Cc: Ben Skeggs <bskeggs@redhat.com>, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
Stephen Rothwell <sfr@canb.auug.org.au>,
Andrew Morton <akpm@linux-foundation.org>,
<dri-devel@lists.freedesktop.org>,
<nouveau@lists.freedesktop.org>,
<kernel-janitors@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][next] nouveau/svm: Fix missing failure check on call to make_device_exclusive_range
Date: Thu, 27 May 2021 10:30:34 +1000 [thread overview]
Message-ID: <2050838.rP6W8OkBfs@nvdebian> (raw)
In-Reply-To: <20210526140459.3749959-1-colin.king@canonical.com>
On Thursday, 27 May 2021 12:04:59 AM AEST Colin King wrote:
> The call to make_device_exclusive_range can potentially fail leaving
> pointer page not initialized that leads to an uninitialized pointer
> read issue. Fix this by adding a check to see if the call failed and
> returning the error code.
>
> Addresses-Coverity: ("Uninitialized pointer read")
> Fixes: c620bba9828c ("nouveau/svm: implement atomic SVM access")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/nouveau/nouveau_svm.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c
> b/drivers/gpu/drm/nouveau/nouveau_svm.c index 84726a89e665..b913b4907088
> 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_svm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
> @@ -609,8 +609,10 @@ static int nouveau_atomic_range_fault(struct
> nouveau_svmm *svmm,
>
> notifier_seq = mmu_interval_read_begin(¬ifier->notifier);
> mmap_read_lock(mm);
> - make_device_exclusive_range(mm, start, start + PAGE_SIZE,
> - &page, drm->dev);
> + ret = make_device_exclusive_range(mm, start, start +
> PAGE_SIZE, + &page,
> drm->dev); + if (ret < 0)
> + goto out;
Thanks for spotting, this is fixing get_user_pages() inside
make_device_exclusive_range() returning an error. However the check needs to
happen after dropping mmap_lock below:
> mmap_read_unlock(mm);
> if (!page) {
> ret = -EINVAL;
> --
> 2.31.1
WARNING: multiple messages have this Message-ID (diff)
From: Alistair Popple <apopple@nvidia.com>
To: Colin King <colin.king@canonical.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
David Airlie <airlied@linux.ie>,
nouveau@lists.freedesktop.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
Ben Skeggs <bskeggs@redhat.com>, Daniel Vetter <daniel@ffwll.ch>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [Nouveau] [PATCH][next] nouveau/svm: Fix missing failure check on call to make_device_exclusive_range
Date: Thu, 27 May 2021 10:30:34 +1000 [thread overview]
Message-ID: <2050838.rP6W8OkBfs@nvdebian> (raw)
In-Reply-To: <20210526140459.3749959-1-colin.king@canonical.com>
On Thursday, 27 May 2021 12:04:59 AM AEST Colin King wrote:
> The call to make_device_exclusive_range can potentially fail leaving
> pointer page not initialized that leads to an uninitialized pointer
> read issue. Fix this by adding a check to see if the call failed and
> returning the error code.
>
> Addresses-Coverity: ("Uninitialized pointer read")
> Fixes: c620bba9828c ("nouveau/svm: implement atomic SVM access")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/nouveau/nouveau_svm.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c
> b/drivers/gpu/drm/nouveau/nouveau_svm.c index 84726a89e665..b913b4907088
> 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_svm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
> @@ -609,8 +609,10 @@ static int nouveau_atomic_range_fault(struct
> nouveau_svmm *svmm,
>
> notifier_seq = mmu_interval_read_begin(¬ifier->notifier);
> mmap_read_lock(mm);
> - make_device_exclusive_range(mm, start, start + PAGE_SIZE,
> - &page, drm->dev);
> + ret = make_device_exclusive_range(mm, start, start +
> PAGE_SIZE, + &page,
> drm->dev); + if (ret < 0)
> + goto out;
Thanks for spotting, this is fixing get_user_pages() inside
make_device_exclusive_range() returning an error. However the check needs to
happen after dropping mmap_lock below:
> mmap_read_unlock(mm);
> if (!page) {
> ret = -EINVAL;
> --
> 2.31.1
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
WARNING: multiple messages have this Message-ID (diff)
From: Alistair Popple <apopple@nvidia.com>
To: Colin King <colin.king@canonical.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
David Airlie <airlied@linux.ie>,
nouveau@lists.freedesktop.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
Ben Skeggs <bskeggs@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH][next] nouveau/svm: Fix missing failure check on call to make_device_exclusive_range
Date: Thu, 27 May 2021 10:30:34 +1000 [thread overview]
Message-ID: <2050838.rP6W8OkBfs@nvdebian> (raw)
In-Reply-To: <20210526140459.3749959-1-colin.king@canonical.com>
On Thursday, 27 May 2021 12:04:59 AM AEST Colin King wrote:
> The call to make_device_exclusive_range can potentially fail leaving
> pointer page not initialized that leads to an uninitialized pointer
> read issue. Fix this by adding a check to see if the call failed and
> returning the error code.
>
> Addresses-Coverity: ("Uninitialized pointer read")
> Fixes: c620bba9828c ("nouveau/svm: implement atomic SVM access")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/nouveau/nouveau_svm.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c
> b/drivers/gpu/drm/nouveau/nouveau_svm.c index 84726a89e665..b913b4907088
> 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_svm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
> @@ -609,8 +609,10 @@ static int nouveau_atomic_range_fault(struct
> nouveau_svmm *svmm,
>
> notifier_seq = mmu_interval_read_begin(¬ifier->notifier);
> mmap_read_lock(mm);
> - make_device_exclusive_range(mm, start, start + PAGE_SIZE,
> - &page, drm->dev);
> + ret = make_device_exclusive_range(mm, start, start +
> PAGE_SIZE, + &page,
> drm->dev); + if (ret < 0)
> + goto out;
Thanks for spotting, this is fixing get_user_pages() inside
make_device_exclusive_range() returning an error. However the check needs to
happen after dropping mmap_lock below:
> mmap_read_unlock(mm);
> if (!page) {
> ret = -EINVAL;
> --
> 2.31.1
next prev parent reply other threads:[~2021-05-27 0:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-26 14:04 [PATCH][next] nouveau/svm: Fix missing failure check on call to make_device_exclusive_range Colin King
2021-05-26 14:04 ` [Nouveau] " Colin King
2021-05-27 0:30 ` Alistair Popple [this message]
2021-05-27 0:30 ` Alistair Popple
2021-05-27 0:30 ` [Nouveau] " Alistair Popple
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=2050838.rP6W8OkBfs@nvdebian \
--to=apopple@nvidia.com \
--cc=airlied@linux.ie \
--cc=akpm@linux-foundation.org \
--cc=bskeggs@redhat.com \
--cc=colin.king@canonical.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=sfr@canb.auug.org.au \
/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.