mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Garnier <thgarnie@google.com>
To: Russell King <linux@armlinux.org.uk>,
	Thomas Garnier <thgarnie@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Dave Martin <Dave.Martin@arm.com>,
	Chris Metcalf <cmetcalf@mellanox.com>,
	Pratyush Anand <panand@redhat.com>,
	leonard.crestez@nxp.com
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	kernel-hardening@lists.openwall.com
Subject: [PATCH 3/3] arm64/syscalls: Move address limit check in loop
Date: Wed, 19 Jul 2017 10:59:00 -0700	[thread overview]
Message-ID: <20170719175900.124074-3-thgarnie@google.com> (raw)
In-Reply-To: <20170719175900.124074-1-thgarnie@google.com>

The original bug was reported on arm but I am fixing arm64 too because
it has a similar code pattern.

The work pending loop can call set_fs after addr_limit_user_check
removed the _TIF_FSCHECK flag. To prevent the infinite loop, move the
addr_limit_user_check call at the beginning of the loop.

Fixes: cf7de27ab351 ("arm64/syscalls: Check address limit on user-mode return")
Reported-by: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Thomas Garnier <thgarnie@google.com>
---
 arch/arm64/kernel/signal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index e3e3293d1123..8e2705983e1d 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -751,10 +751,10 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
 	 */
 	trace_hardirqs_off();
 
-	/* Check valid user FS if needed */
-	addr_limit_user_check();
-
 	do {
+		/* Check valid user FS if needed */
+		addr_limit_user_check();
+
 		if (thread_flags & _TIF_NEED_RESCHED) {
 			schedule();
 		} else {
-- 
2.14.0.rc0.284.gd933b75aa4-goog

  parent reply	other threads:[~2017-07-19 17:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-19 17:58 [PATCH 1/3] arm/syscalls: " Thomas Garnier
2017-07-19 17:58 ` [PATCH 2/3] arm/syscalls: Optimize work flags assembly check Thomas Garnier
2017-07-19 17:59 ` Thomas Garnier [this message]
2017-07-24 17:07 ` [PATCH 1/3] arm/syscalls: Move address limit check in loop Thomas Garnier
2017-07-25 10:28   ` Leonard Crestez
2017-07-25 10:38     ` Russell King - ARM Linux
2017-07-25 20:01       ` Thomas Garnier
2017-07-26 12:02         ` Will Deacon
2017-07-26 14:20           ` Thomas Garnier
2017-07-26 18:25             ` Russell King - ARM Linux
2017-07-26 18:29               ` Thomas Garnier

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=20170719175900.124074-3-thgarnie@google.com \
    --to=thgarnie@google.com \
    --cc=Dave.Martin@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=cmetcalf@mellanox.com \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=leonard.crestez@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=panand@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.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®