All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: imunsie@au1.ibm.com, benh@kernel.crashing.org
Subject: [PATCH] cxl: fix setting of _PAGE_USER bit when handling page faults
Date: Fri, 18 Mar 2016 15:01:21 +1100	[thread overview]
Message-ID: <1458273681-18588-1-git-send-email-andrew.donnellan@au1.ibm.com> (raw)

When handling page faults, cxl_handle_page_fault() checks whether the page
should be accessible by userspace and have its _PAGE_USER access bit set.
_PAGE_USER should be set if the context's kernel flag isn't set, or if the
page falls outside of kernel memory.

However, the check currently uses the wrong operator, causing it to always
evalute to true. As such, we always set the _PAGE_USER bit, even when it
should be restricted to the kernel.

Fix the check so that the _PAGE_USER bit is set only as intended.

Fixes: f204e0b8cedd ("cxl: Driver code for powernv PCIe based cards for
userspace access")
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

---

Found by Coverity Scan.

Currently, this should only affect cxlflash.
---
 drivers/misc/cxl/fault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c
index 9a8650b..a76cb8a 100644
--- a/drivers/misc/cxl/fault.c
+++ b/drivers/misc/cxl/fault.c
@@ -152,7 +152,7 @@ static void cxl_handle_page_fault(struct cxl_context *ctx,
 	access = _PAGE_PRESENT;
 	if (dsisr & CXL_PSL_DSISR_An_S)
 		access |= _PAGE_RW;
-	if ((!ctx->kernel) || ~(dar & (1ULL << 63)))
+	if ((!ctx->kernel) || !(dar & (1ULL << 63)))
 		access |= _PAGE_USER;
 
 	if (dsisr & DSISR_NOHPTE)
-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

             reply	other threads:[~2016-03-18  4:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18  4:01 Andrew Donnellan [this message]
2016-03-18  6:30 ` [PATCH] cxl: fix setting of _PAGE_USER bit when handling page faults Ian Munsie
2016-03-21  4:38   ` Andrew Donnellan
2016-03-25 10:01 ` Michael Ellerman
2016-03-25 17:15   ` Ian Munsie
2016-03-28 13:42   ` Aneesh Kumar K.V
2016-03-28 18:00     ` Aneesh Kumar K.V
2016-04-11  4:10     ` Andrew Donnellan
2016-04-11  4:27       ` Michael Ellerman
2016-04-11  4:31         ` Aneesh Kumar K.V
2016-04-11 11:14           ` Michael Ellerman
2016-04-11 13:42             ` Aneesh Kumar K.V
2016-04-12 11:42               ` Michael Ellerman
2016-03-29 22:08 ` [PATCH] " Matthew R. Ochs

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=1458273681-18588-1-git-send-email-andrew.donnellan@au1.ibm.com \
    --to=andrew.donnellan@au1.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=imunsie@au1.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /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.