From patchwork Mon Nov 23 15:54:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 11925647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C41CC63798 for ; Mon, 23 Nov 2020 15:55:44 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3B31206B6 for ; Mon, 23 Nov 2020 15:55:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JFdN9y4l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3B31206B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:In-Reply-To:Date:References: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=f2AeQs2jPxM+4A80K7Qe53olOQ2h0eXiz1F/ullHZXw=; b=JFdN9y4lief95NMmTVeZsc/vK 453m9aOY+J9Z91wmWG6y+9yDGgDh5+PmrY+nnBAIN01L4kZijbkVzc99KcQZXAqDHrO7BVid0f3Ef SOqs+VlszQFQo2NVVXuPPH14Bu0/TIjuQHzVQRdkwtIqulayba023yjYBOk84zj3/bxujWWJGV8/z UvZjHeRumcLdkvRa7UTW1xuZrLGIBKFMXuZqvR1qRX3fhGt+HC7fEjez8WokKvsBc2ni95l41i4at KDH3lGc23qQ839HQulxotDLG0bb9qRW8SW+Cd2KFLroZeo+jS6jszH0zbmkpVmq7UHVjAhvsDVv/s R6xJs7IBA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khEBF-0001Je-SM; Mon, 23 Nov 2020 15:55:05 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1khEBD-0001Iu-Rs for linux-arm-kernel@lists.infradead.org; Mon, 23 Nov 2020 15:55:04 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 05D891F44CF8 From: Gabriel Krisman Bertazi To: Jann Horn Subject: [PATCH] entry: Fix boot for !CONFIG_GENERIC_ENTRY Organization: Collabora References: <87h7pgqhdf.fsf@collabora.com> Date: Mon, 23 Nov 2020 10:54:58 -0500 In-Reply-To: <87h7pgqhdf.fsf@collabora.com> (Gabriel Krisman Bertazi's message of "Mon, 23 Nov 2020 09:26:20 -0500") Message-ID: <87a6v8qd9p.fsf_-_@collabora.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201123_105504_009944_0191EEC0 X-CRM114-Status: GOOD ( 15.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Semwal , Arnd Bergmann , Song Liu , Kees Cook , Daniel Borkmann , YiFei Zhu , Netdev , Naresh Kamboju , open list , lkft-triage@lists.linaro.org, Andy Lutomirski , Arnd Bergmann , Andy Lutomirski , Yonghong Song , Thomas Gleixner , Andrii Nakryiko , bpf , Linux ARM Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Gabriel Krisman Bertazi writes: > Jann Horn writes: >> As part of fixing this, it might be a good idea to put "enum >> syscall_work_bit" behind a "#ifdef CONFIG_GENERIC_ENTRY" to avoid >> future accidents like this? > > Hi Jan, Arnd, > > That is correct. This is a copy pasta mistake. My apologies. I didn't > have a !GENERIC_ENTRY device to test, but just the ifdef would have > caught it. I have patched it as suggested. Tested on qemu for arm32 and on bare metal for x86-64. Once again, my apologies for the mistake. -- >8 -- Subject: [PATCH] entry: Fix boot for !CONFIG_GENERIC_ENTRY A copy-pasta mistake tries to set SYSCALL_WORK flags instead of TIF flags for !CONFIG_GENERIC_ENTRY. Also, add safeguards to catch this at compilation time. Reported-by: Naresh Kamboju Suggested-by: Jann Horn Signed-off-by: Gabriel Krisman Bertazi Reviewed-by: Kees Cook Tested-by: Naresh Kamboju --- include/linux/thread_info.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index 6a597fd5d351..45ad3176e2fa 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h @@ -35,6 +35,7 @@ enum { GOOD_STACK, }; +#ifdef CONFIG_GENERIC_ENTRY enum syscall_work_bit { SYSCALL_WORK_BIT_SECCOMP, SYSCALL_WORK_BIT_SYSCALL_TRACEPOINT, @@ -48,6 +49,7 @@ enum syscall_work_bit { #define SYSCALL_WORK_SYSCALL_TRACE BIT(SYSCALL_WORK_BIT_SYSCALL_TRACE) #define SYSCALL_WORK_SYSCALL_EMU BIT(SYSCALL_WORK_BIT_SYSCALL_EMU) #define SYSCALL_WORK_SYSCALL_AUDIT BIT(SYSCALL_WORK_BIT_SYSCALL_AUDIT) +#endif #include @@ -127,11 +129,11 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag) clear_bit(SYSCALL_WORK_BIT_##fl, &task_thread_info(t)->syscall_work) #else #define set_syscall_work(fl) \ - set_ti_thread_flag(current_thread_info(), SYSCALL_WORK_##fl) + set_ti_thread_flag(current_thread_info(), TIF_##fl) #define test_syscall_work(fl) \ - test_ti_thread_flag(current_thread_info(), SYSCALL_WORK_##fl) + test_ti_thread_flag(current_thread_info(), TIF_##fl) #define clear_syscall_work(fl) \ - clear_ti_thread_flag(current_thread_info(), SYSCALL_WORK_##fl) + clear_ti_thread_flag(current_thread_info(), TIF_##fl) #define set_task_syscall_work(t, fl) \ set_ti_thread_flag(task_thread_info(t), TIF_##fl)