From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752573AbdHNViM (ORCPT ); Mon, 14 Aug 2017 17:38:12 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:36197 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752513AbdHNViI (ORCPT ); Mon, 14 Aug 2017 17:38:08 -0400 From: Thomas Garnier To: Al Viro , Dave Hansen , Arnd Bergmann , Thomas Gleixner , Thomas Garnier , Yonghong Song , David Howells , Russell King , Kees Cook , Andy Lutomirski , Will Drewry , Dave Martin , Catalin Marinas , Will Deacon Cc: linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com Subject: [PATCH v3 4/4] arm64/syscalls: Move address limit check in loop Date: Mon, 14 Aug 2017 14:37:32 -0700 Message-Id: <20170814213732.104301-4-thgarnie@google.com> X-Mailer: git-send-email 2.14.1.480.gb18f417b89-goog In-Reply-To: <20170814213732.104301-1-thgarnie@google.com> References: <20170814213732.104301-1-thgarnie@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A bug was reported on ARM where set_fs might be called after it was checked on the work pending function. ARM64 is not affected by this bug but has a similar construct. In order to avoid any similar problems in the future, the addr_limit_user_check function is moved at the beginning of the loop. Fixes: cf7de27ab351 ("arm64/syscalls: Check address limit on user-mode return") Reported-by: Leonard Crestez Signed-off-by: Thomas Garnier --- 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 c45214f8fb54..0bdc96c61bc0 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.1.480.gb18f417b89-goog