From patchwork Mon Aug 14 21:37:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9900189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B0478602D9 for ; Mon, 14 Aug 2017 21:38:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4AE8283FF for ; Mon, 14 Aug 2017 21:38:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 998502873A; Mon, 14 Aug 2017 21:38:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id B21EF283FF for ; Mon, 14 Aug 2017 21:38:39 +0000 (UTC) Received: (qmail 24248 invoked by uid 550); 14 Aug 2017 21:38:23 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 24200 invoked from network); 14 Aug 2017 21:38:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4jvmx+gZhslZzgRz7H9EaSvUVcChMEg5trpN0+OOsH8=; b=ORnPO6XO7hb9XI9woDr7i1YOZXY7rMaRggJk2XBubi0l7i5hwHj131II9B2ymb13Ig g+tfM7nxaPMhJ4i0r74fd/fd/2++zugiXkffGjD88Z7zEIQAbK8vNce2oIsAX0/3fua0 AQ8gJ+CaHZUIVGIr471HcMFfBBLJ40jScsyXXTuUxxgrxQLy7SUyElxn03s4poxmhV5L IBgoGau/SGjBZZboHFtKzTJ15xR9cZSFQ8chWdEK+T1WkTr4b7M4uZ5duB2y7i9sXCev 9SDJ+Wx0bEceDWlnAxAyAC6/0PXObRFV4Ucvg8zGDCCJX4NcqBXjHxqr0cjP6+etnUpr ygfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4jvmx+gZhslZzgRz7H9EaSvUVcChMEg5trpN0+OOsH8=; b=oNI3aYViGPNo3xB5j+b+iJ5d9PISBkMz/mCe3YTxUzPjxy7LFYdfaaAE8hXuHUclbM 7Wave4906OfF/u9y1m09voxc+MZaJagrZg6QPtDSHx4RY+DhmI4mo04UAw4RmRTYVg/1 Bci6HkSbOxGF48loONGlV1spDMfURFV0v13Z6eM+dBwuab1fim+VfNnLCcZNffsSY8UB 7EyUJcSBpdeHk1jfRWxIsEEU8ZFiTxKx8C8CN4TmcRvKm6m1j1TwlyKKjH5fRPqb2TBo YcWYLtQprIxt7n04loVA5KyKpQl8XI8d5jX8/ccArlxeBHuOVqj85qqYbLEomTWsTkV6 elfg== X-Gm-Message-State: AHYfb5huax+20gyFAzO+eW53hxqpx2O8hzG/u76SZShO/SDUPZje/wyX ErfxW34KyWBdttae X-Received: by 10.98.7.204 with SMTP id 73mr26397548pfh.110.1502746687094; Mon, 14 Aug 2017 14:38:07 -0700 (PDT) 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 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> Subject: [kernel-hardening] [PATCH v3 4/4] arm64/syscalls: Move address limit check in loop X-Virus-Scanned: ClamAV using ClamSMTP 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 {