* [PATCH][next] nouveau/svm: Fix missing failure check on call to make_device_exclusive_range
@ 2021-05-26 14:04 Colin King
2021-05-27 0:30 ` Alistair Popple
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-05-26 14:04 UTC (permalink / raw)
To: Ben Skeggs, David Airlie, Daniel Vetter, Alistair Popple,
Stephen Rothwell, Andrew Morton, dri-devel, nouveau
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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;
mmap_read_unlock(mm);
if (!page) {
ret = -EINVAL;
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][next] nouveau/svm: Fix missing failure check on call to make_device_exclusive_range
2021-05-26 14:04 [PATCH][next] nouveau/svm: Fix missing failure check on call to make_device_exclusive_range Colin King
@ 2021-05-27 0:30 ` Alistair Popple
0 siblings, 0 replies; 2+ messages in thread
From: Alistair Popple @ 2021-05-27 0:30 UTC (permalink / raw)
To: Colin King
Cc: Ben Skeggs, David Airlie, Daniel Vetter, Stephen Rothwell,
Andrew Morton, dri-devel, nouveau, kernel-janitors, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-27 0:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 14:04 [PATCH][next] nouveau/svm: Fix missing failure check on call to make_device_exclusive_range Colin King
2021-05-27 0:30 ` Alistair Popple
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).