From patchwork Wed Jul 19 17:58:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9852915 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 DB4B8602C8 for ; Wed, 19 Jul 2017 17:59:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2999286CB for ; Wed, 19 Jul 2017 17:59:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6D47286CF; Wed, 19 Jul 2017 17:59:33 +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 1A907286CB for ; Wed, 19 Jul 2017 17:59:32 +0000 (UTC) Received: (qmail 19719 invoked by uid 550); 19 Jul 2017 17:59:30 -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 19696 invoked from network); 19 Jul 2017 17:59:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=iX+2VFIeWmC4EAdyu5b4CAvHE+QnCcnT1dldNzdPYS4=; b=lK1lSUZUHkQHVmaKejJFcF8AUuZ64DYndL3JitEnktDtfEAfPiEii5uxqb03ysc9xe +Jq611gzzl1jcTLtsIjPRwP9pvPbqhuo9+OUNfz5onxR9zh0nM83thfQZci2RmIvZDQk WluRxp+MMr9O+8Grczi//GInb58EKljMjrffL0L5XnfC2OdE5HPU6pL0ueTHngQSiglE DmRUvsWCevK2lGTHfyhnz6CtmUFu3oW26IJ1aNyxHv/9c0Wx6fcOdAfQULPa5K/rBAfg xPP0Ys+ERyc7l29rFJsVnzhSQuck5AirqIrVW0/J1hGl4s0+SJwwGK3biBPeg6U0ZPus VViA== 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; bh=iX+2VFIeWmC4EAdyu5b4CAvHE+QnCcnT1dldNzdPYS4=; b=NZd4qWij9uPDkEZQvuuvn3x25WOvhVOzzLWx0sUafaqMa+0SuxRPLPnFfTTQ4Su/hv hmAZBSmZ2ILYpRHCsDcxYRdc9ZjFo11Rzvz2Fh8lVJkVMQazhnaxQts0kmLYqE/9/ZsD RHf5ZPYVuH89FZZX2nuSZMFAW+4jSvW3OnwxV2ob5v1CfB9yLCfuQYaJPv3hLKtLaxYx /0FfHW3S5UHYdenJHdR52hGAH36Ygn+iY/rYZSpbYeqFcG2x96xuEgTRDDu6YEBHDyWK h1MKSqWloVrBTD+b+2iiPSv61GSDD2OZ10cTpSYC/JpRW/aKVjtKxn8DsOVOzoSDjeVI DNsA== X-Gm-Message-State: AIVw111eyMoRtJMQzV/zHbILyqlpih3wA/M1+QcHV8smXlvGO2KGOV6L VctIaiWA5atAYzIS X-Received: by 10.99.106.69 with SMTP id f66mr954966pgc.282.1500487157141; Wed, 19 Jul 2017 10:59:17 -0700 (PDT) From: Thomas Garnier To: Russell King , Thomas Garnier , Thomas Gleixner , Catalin Marinas , Will Deacon , Dave Martin , Chris Metcalf , Pratyush Anand , leonard.crestez@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Date: Wed, 19 Jul 2017 10:58:58 -0700 Message-Id: <20170719175900.124074-1-thgarnie@google.com> X-Mailer: git-send-email 2.14.0.rc0.284.gd933b75aa4-goog Subject: [kernel-hardening] [PATCH 1/3] arm/syscalls: Move address limit check in loop X-Virus-Scanned: ClamAV using ClamSMTP 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: 73ac5d6a2b6a ("arm/syscalls: Check address limit on user-mode return") Reported-by: Leonard Crestez Signed-off-by: Thomas Garnier Tested-by: Leonard Crestez --- arch/arm/kernel/signal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index 3a48b54c6405..f4574287d14b 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -573,10 +573,10 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall) */ 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 (likely(thread_flags & _TIF_NEED_RESCHED)) { schedule(); } else {