From patchwork Mon Aug 14 21:37:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9900181 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 20669602D9 for ; Mon, 14 Aug 2017 21:38:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14588283FF for ; Mon, 14 Aug 2017 21:38:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08C682873A; Mon, 14 Aug 2017 21:38:21 +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 232F5283FF for ; Mon, 14 Aug 2017 21:38:19 +0000 (UTC) Received: (qmail 23801 invoked by uid 550); 14 Aug 2017 21:38:17 -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 23780 invoked from network); 14 Aug 2017 21:38:16 -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=eiMcuVzT/Cpt7IA76r6DkfR6XdsEXpFEkaly6Xznduw=; b=VIUp7I8OjNsQl7Z2Ylf0WqZk8RxVUgcMYFGERwl0STgb7q6WzbN78QLYFHFsoMM22h bHpifUFvqaj1uuIIS1D+29CF4SdB0NmLFh5URDtQRSB6rVM6C3rm7tAUKM5bsE7kg+hK IUhJLxVk4oAghyTcfIoR93VQ2k0jwDTOMsQTlWlE4uRXKF8uREiQmmC2djCJff+edIk6 gLi5bsIj7OXanPa9NJINxMXUoD5ykLneQTEPfNetFyYaUf4IDJUDJioUou7//Iao4B7I 6ZUJVbckGL1hlt/XjAZshOcKdXDFcemIkY7kUdXAQqptRxsHQQOT2l/61PyJf8Bk1JTn TaKQ== 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=eiMcuVzT/Cpt7IA76r6DkfR6XdsEXpFEkaly6Xznduw=; b=R0TalAEJSP77NEAN57wOZS29jRr+Umt5Hei8nUQHpvtXOsc3lfKZ5IdnBdv4P9K49L tYh82PbUxscIrP74L0s4PPyjbae3ede43vJjlxv1fueNqAi19VtldNJ7Ezc0kZ1uNH9z LNU3RZubWzYXkIDDmh2s6o1SMCcYq2Bem5nDbjuBT7ZJDQzyfnPyCkcqr55x1tbEPGDh Cjy8bm285wW6VWoMthSJvRe52L0sioXRtDnQKIM+ZPUbQOGcMtsXTYf2jJ8Kv2i1aqUm prEbcJNl0R0ZVOJHf3v1srj7NJMrXN5j05KKPTwXC8G6cNxIobeLh1c2+CGSsLq7NlqL an6g== X-Gm-Message-State: AHYfb5iP7Zf6mr6SFUxMdSNkKai03qqOreYm/yWBzhKU0hJkmutatLfh h85gleWg2lhtx9iC X-Received: by 10.98.219.133 with SMTP id f127mr26762756pfg.29.1502746684548; Mon, 14 Aug 2017 14:38:04 -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:29 -0700 Message-Id: <20170814213732.104301-1-thgarnie@google.com> X-Mailer: git-send-email 2.14.1.480.gb18f417b89-goog Subject: [kernel-hardening] [PATCH v3 1/4] syscalls: Use CHECK_DATA_CORRUPTION for addr_limit_user_check X-Virus-Scanned: ClamAV using ClamSMTP Use CHECK_DATA_CORRUPTION instead of BUG_ON to provide more flexibility on address limit failures. By default, send a SIGKILL signal to kill the current process preventing exploitation of a bad address limit. Make the TIF_FSCHECK flag optional so ARM can use this function. Signed-off-by: Thomas Garnier --- include/linux/syscalls.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 88951b795ee3..65e273aadada 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -219,21 +219,25 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event) } \ static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)) -#ifdef TIF_FSCHECK /* * Called before coming back to user-mode. Returning to user-mode with an * address limit different than USER_DS can allow to overwrite kernel memory. */ static inline void addr_limit_user_check(void) { - +#ifdef TIF_FSCHECK if (!test_thread_flag(TIF_FSCHECK)) return; +#endif - BUG_ON(!segment_eq(get_fs(), USER_DS)); + if (CHECK_DATA_CORRUPTION(!segment_eq(get_fs(), USER_DS), + "Invalid address limit on user-mode return")) + force_sig(SIGKILL, current); + +#ifdef TIF_FSCHECK clear_thread_flag(TIF_FSCHECK); -} #endif +} asmlinkage long sys32_quotactl(unsigned int cmd, const char __user *special, qid_t id, void __user *addr);