From patchwork Fri Jun 10 23:35:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 12878210 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2EB16C433EF for ; Sat, 11 Jun 2022 00:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=MFrxVgA2ml4SsyDS9ktPORkJlVZS8/0jk2/iwUkx9LY=; b=4JOx5Jg7/p6Ce64MqMBRAvIlZ+ odLE7kiCBN7KELa55Oh9W8vYhOdCBZ6/2/yotN/kZmu/mN4Tjz7PGQakZUZv7eeT3MY7ii/2YEQhe lJqnuN0weaSPNIFfNawaFv2r1mMstkGR1S1C+/EuiIOWafhincIqMbOyj6sVuwjLfqC/LqqcrbAuj QlQ0P0wFC2AJYHymoKh1Uf/hssdkyOmkDBRHmJR6rmWo19/s1n7FsnFCD3biQgVSJHl3zYDOnmcE+ 83e920TH+qwjQJSuspQ55XXC1R47KqEvfSAfgTAqeJR+2k+Cd0Nt7AJyFFPpHY8J3TXHeEhEDB/VK nrEnRR1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzoXZ-00AYzb-FM; Fri, 10 Jun 2022 23:59:45 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzoXP-00AYwD-0c for linux-arm-kernel@bombadil.infradead.org; Fri, 10 Jun 2022 23:59:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=c2CIP9lJW3Vwk5QL6viVMvuyWt16DF+L+Hkpp3NHFPU=; b=GpJsdU1MEcumFhywFCdb12Un4J MzFvjh+uzxLmcK+H+8s35uMbi1tg+lJva8XDv3X+QKgMtfds4bthtjGY2bSSsCjFHrPNnawen56pw 8b7lkD1ovceFPoBYJQG2lYVyO1YNKPCF/S3TsBwctWt87zUW5Il45qYxVighY2ZjCcoSfwsxesqjM 5NLAYyI+mdK53hm7YbN/odA1qUVRvpR5qMotEr1b2a++gWC2wtODeHB/9pZ7pPjOBnFDmlMydb/6I fH23H2+Bsfj28dymA0z3yoQZZLvOMR/fp9ml366fc7TXHBqr6u4iosMtTB8lsarR4byoz6u93sTGX Y/rlNIFA==; Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by casper.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzoAP-00Eq5i-Hw for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 23:35:53 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-313cfb0c181so5701177b3.20 for ; Fri, 10 Jun 2022 16:35:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=c2CIP9lJW3Vwk5QL6viVMvuyWt16DF+L+Hkpp3NHFPU=; b=bZ0OwARdGc3yu8CswzfT+1uQ6TcGmp1AR/m1+MAFrKy37VbeoHqWN4ZXuy7LkPp7D+ FDmJFl/mZmgSREzzUNarX0PhaWe0cRxh46RzI9WvN5gFuTRWabOKhtlGV3v1xePxwNU+ qWf5OkYVxmYyHD7fbiyxlqaTuhls0/3Xvims4ZjiTf649xL9NryzLpQLw96MAtUzmzgd /VweRNmEe08BkfrTtgryJL56gtCVFt2xeCCJvTTmrHe62eKfSPtMacqwEFncv9tJeWAR f33zRw8XryiGdqTxGisO1fsoa99c+RLTNe/z8Z9/SmjulnrcdevMsW/NHF8oe4AkLXlj ZCbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=c2CIP9lJW3Vwk5QL6viVMvuyWt16DF+L+Hkpp3NHFPU=; b=tviVyhMefayPonFXvnDyTk57kACLlzvUb3O3LTEG+PxqMxR9oXn7c0TtJOEt9MOawW EkOgXTVL0UJJaMCV30gn2a0ZkHE0xjT4GsMgmAJcsalD0D2WSi32eeSnhBdQ2sVGyv0s RnUL+L5LY70FrWc6myDVXccYXXZShld/sXe7pPSwPLL3/cts3N5J5TTF/BWwCOBzUO/e 2djUqHVG4rLnym0zl564478ghL8HmSYEKNtBKT3MLZuOCDEpmHu4IDz5CESLRAYP2rM3 lZYjzeNACNMIqcikOC5hejLEeUBmXa3c7dCq01NMhua9bfuCBrrj97/IbzmMS+L1Tn3u FQLw== X-Gm-Message-State: AOAM532AN38tYWlJgGvukBqdSzR58tJny64vetNvBS6sPiqVpZeRbro8 E/r1nm9ase8xWVnNqn/c3rT8OpqUz2b1E0NwGjY= X-Google-Smtp-Source: ABdhPJzbLjbgBkiT7ukd1d/Nm2vzD579Psp0PgoL3wD0GPfrTh6ciaa1jHBKL7NVGhlMo4aiyWjAedJH7pKBZesYTqU= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f464:6db6:3d47:ed14]) (user=samitolvanen job=sendgmr) by 2002:a5b:982:0:b0:63e:7d7e:e2f2 with SMTP id c2-20020a5b0982000000b0063e7d7ee2f2mr44757278ybq.549.1654904146897; Fri, 10 Jun 2022 16:35:46 -0700 (PDT) Date: Fri, 10 Jun 2022 16:35:06 -0700 In-Reply-To: <20220610233513.1798771-1-samitolvanen@google.com> Message-Id: <20220610233513.1798771-14-samitolvanen@google.com> Mime-Version: 1.0 References: <20220610233513.1798771-1-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=2540; h=from:subject; bh=wkxTracRlh48gJXB/sqV6igwxwar57UIoToIvjngLK8=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBio9UuxPblg4Uoded/YFk1E0wzoSbYH57F/K8/DM+S r1qJ8O6JAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCYqPVLgAKCRBMtfaEi7xW7rY/C/ 4m/NOSBpwS0Czw/rZryoUepjdULMbzlVZDXNI27hhZMA63z8eMpozt3+ZW/D0tiuzcAUVGcaodI08b S6UpbNtPb+dQ1HWqeDj5jIEVXUt5IytXnHQfT8ygUin8anKc0V79P4Tzz4dyM1lOs8NgXH/OziIhbK LxQZFid9wKx35uD/iVHVtVMzjB8Y6xOUMH3R9x2iKBFoHtzuicfledhljWW7RVSsnuL3+9OD7jOmkl JCeTQ2IyZMOvaP9A+oXOxAbLf79bs1+a/IFWldHwUMPFSHkOPRPlaRRC4PD89HDhYumL9sJvsS70rZ MK5OWPrVCi4qfhYXQU8hi0F54skmllftnoDVL79ukfhZAksebFSxjPLrCGfBAEMfwmC6hrc+nJ9MPQ oFY8wvdD6Zo2R7bmBMYQVY55UyE1VvdU5S/UY237DWflo1b/Q/pa1Zp+gbKLMYaP0Q8I7cjsoK3DIy B//tJN9fdzFinWYpnVwZLbolnTKtnXMh6uck7H3DDeukM= X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [RFC PATCH v3 13/20] treewide: Drop WARN_ON_FUNCTION_MISMATCH From: Sami Tolvanen To: linux-kernel@vger.kernel.org Cc: Kees Cook , Josh Poimboeuf , Peter Zijlstra , x86@kernel.org, Catalin Marinas , Will Deacon , Mark Rutland , Nathan Chancellor , Nick Desaulniers , Joao Moreira , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Sami Tolvanen X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220611_003549_617430_D980C875 X-CRM114-Status: GOOD ( 13.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org CONFIG_CFI_CLANG no longer breaks cross-module function address equality, which makes WARN_ON_FUNCTION_MISMATCH unnecessary. Remove the definition and switch back to WARN_ON_ONCE. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- include/asm-generic/bug.h | 16 ---------------- kernel/kthread.c | 3 +-- kernel/workqueue.c | 2 +- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index ba1f860af38b..4050b191e1a9 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -220,22 +220,6 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...); # define WARN_ON_SMP(x) ({0;}) #endif -/* - * WARN_ON_FUNCTION_MISMATCH() warns if a value doesn't match a - * function address, and can be useful for catching issues with - * callback functions, for example. - * - * With CONFIG_CFI_CLANG, the warning is disabled because the - * compiler replaces function addresses taken in C code with - * local jump table addresses, which breaks cross-module function - * address equality. - */ -#if defined(CONFIG_CFI_CLANG) && defined(CONFIG_MODULES) -# define WARN_ON_FUNCTION_MISMATCH(x, fn) ({ 0; }) -#else -# define WARN_ON_FUNCTION_MISMATCH(x, fn) WARN_ON_ONCE((x) != (fn)) -#endif - #endif /* __ASSEMBLY__ */ #endif diff --git a/kernel/kthread.c b/kernel/kthread.c index 544fd4097406..19d446f4e3a9 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -1050,8 +1050,7 @@ static void __kthread_queue_delayed_work(struct kthread_worker *worker, struct timer_list *timer = &dwork->timer; struct kthread_work *work = &dwork->work; - WARN_ON_FUNCTION_MISMATCH(timer->function, - kthread_delayed_work_timer_fn); + WARN_ON_ONCE(timer->function != kthread_delayed_work_timer_fn); /* * If @delay is 0, queue @dwork->work immediately. This is for diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 4056f2a3f9d5..2fed7bb018a7 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1651,7 +1651,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq, struct work_struct *work = &dwork->work; WARN_ON_ONCE(!wq); - WARN_ON_FUNCTION_MISMATCH(timer->function, delayed_work_timer_fn); + WARN_ON_ONCE(timer->function != delayed_work_timer_fn); WARN_ON_ONCE(timer_pending(timer)); WARN_ON_ONCE(!list_empty(&work->entry));