From: "Christian König" <christian.koenig@amd.com>
To: Tianlin Li <tli@digitalocean.com>, kernel-hardening@lists.openwall.com
Cc: keescook@chromium.org, Alex Deucher <alexander.deucher@amd.com>,
David1.Zhou@amd.com, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] drm/radeon: have the callers of set_memory_*() check the return value
Date: Mon, 3 Feb 2020 18:16:33 +0100 [thread overview]
Message-ID: <6e5a18f6-b7f6-c401-c845-fe24b183f348@amd.com> (raw)
In-Reply-To: <20200203161827.768-1-tli@digitalocean.com>
Am 03.02.20 um 17:18 schrieb Tianlin Li:
> Right now several architectures allow their set_memory_*() family of
> functions to fail,
Oh, that is a detail I previously didn't recognized. Which architectures
are that?
Cause the RS400/480, RS690 and RS740 which are affected by this are
integrated in the south-bridge.
> but callers may not be checking the return values.
> If set_memory_*() returns with an error, call-site assumptions may be
> infact wrong to assume that it would either succeed or not succeed at
> all. Ideally, the failure of set_memory_*() should be passed up the
> call stack, and callers should examine the failure and deal with it.
>
> Need to fix the callers and add the __must_check attribute. They also
> may not provide any level of atomicity, in the sense that the memory
> protections may be left incomplete on failure. This issue likely has a
> few steps on effects architectures:
> 1)Have all callers of set_memory_*() helpers check the return value.
> 2)Add __must_check to all set_memory_*() helpers so that new uses do
> not ignore the return value.
> 3)Add atomicity to the calls so that the memory protections aren't left
> in a partial state.
>
> This series is part of step 1. Make drm/radeon check the return value of
> set_memory_*().
>
> Signed-off-by: Tianlin Li <tli@digitalocean.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> v2:
> The hardware is too old to be tested on and the code cannot be simply
> removed from the kernel, so this is the solution for the short term.
> - Just print an error when something goes wrong
> - Remove patch 2.
> v1:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20200107192555.20606-1-tli%40digitalocean.com%2F&data=02%7C01%7Cchristian.koenig%40amd.com%7Cba2176d2ca834214e6b108d7a8c4bb1d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637163435227030235&sdata=mDhUEi3vmxahjsdrZOr83OEIWNBHefO8lkXST%2FW32CE%3D&reserved=0
> ---
> drivers/gpu/drm/radeon/radeon_gart.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
> index f178ba321715..a2cc864aa08d 100644
> --- a/drivers/gpu/drm/radeon/radeon_gart.c
> +++ b/drivers/gpu/drm/radeon/radeon_gart.c
> @@ -80,8 +80,9 @@ int radeon_gart_table_ram_alloc(struct radeon_device *rdev)
> #ifdef CONFIG_X86
> if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480 ||
> rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) {
> - set_memory_uc((unsigned long)ptr,
> - rdev->gart.table_size >> PAGE_SHIFT);
> + if (set_memory_uc((unsigned long)ptr,
> + rdev->gart.table_size >> PAGE_SHIFT))
> + DRM_ERROR("set_memory_uc failed.\n");
> }
> #endif
> rdev->gart.ptr = ptr;
> @@ -106,8 +107,9 @@ void radeon_gart_table_ram_free(struct radeon_device *rdev)
> #ifdef CONFIG_X86
> if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480 ||
> rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) {
> - set_memory_wb((unsigned long)rdev->gart.ptr,
> - rdev->gart.table_size >> PAGE_SHIFT);
> + if (set_memory_wb((unsigned long)rdev->gart.ptr,
> + rdev->gart.table_size >> PAGE_SHIFT))
> + DRM_ERROR("set_memory_wb failed.\n");
> }
> #endif
> pci_free_consistent(rdev->pdev, rdev->gart.table_size,
prev parent reply other threads:[~2020-02-03 17:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-03 16:18 Tianlin Li
2020-02-03 17:16 ` Christian König [this message]
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=6e5a18f6-b7f6-c401-c845-fe24b183f348@amd.com \
--to=christian.koenig@amd.com \
--cc=David1.Zhou@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tli@digitalocean.com \
/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
all inboxes | Powered by JetHome®