Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6407473pxv; Thu, 29 Jul 2021 13:56:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH/Xz6fLVjHQkydvuUTRBWwBv7UR2p/JtPwBi0BmWSdip70unrxOnynoLDgfH33K17TV/L X-Received: by 2002:a05:6402:c01:: with SMTP id co1mr8146343edb.287.1627592163464; Thu, 29 Jul 2021 13:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627592163; cv=none; d=google.com; s=arc-20160816; b=Z64hjcnHefDfPBA8+jXKRwvFSWrWkWCpAmfX5NKhDVhrQa/T3mFhshY8kfa1K9f52S 0dCnbzZnuk2aTovBgZ8kEwY4ZogjCNw83bkJAu+Xx2RGlkSYFLeCXrPvPjKOvpNr12UD A4wTl3KGSofKqgUNtvx1hiCZgo/4MsX+Ut62iVdPBZk80pN3FFOpEx0i55anGwsh8yjO +rZKHPwlTY61Rw+7JFSpfECF1y68E0I4HL5kXsybUQCgqkhUn6PT5vLeMAs7Z/Cv2uD5 vJTpVt2SF8mOA1Tq8ITaUPsbwaJ7NuIWoe7vbdVXFOnMJsU7IL959nrZsabgxK4WDs2u T6FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=usBsehgRLO8yBDJdVm0jGsDqhFCcetjnZvT1SyvVNfs=; b=ER71KxwknRdlZ4YfJMBfBkfhiaUhgrJ4H/dDv1zfRKleLiZKjEtXR0FbB6Ly39zk9U keGcqgszlKJpiaEWopxK1cBrwI5aEjq5OyH4m6G6un87M19QK1HM4UmCeVt1tU83q6Ni xEH+PFs8MDXqZNxNKpPcKC1dbtpFzpozNJ0nfqsgGZ6FSHEV+hZwIBMQOuJli+5vBiI4 arUZc0CRQenhpmQFzKhkVztonJz1/hFsJ0hOxJrtRVco38oZh5x1SbRckss3NBSWx7/a uIgZx36hpMVeD8PM7tVHXMDPsjHCvp5j8Tfb2itqYKwkzqfkKVr3AgF9i2V3Nln/Xr4A Uvtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gh0TbzRa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 18si4769154ejc.508.2021.07.29.13.55.39; Thu, 29 Jul 2021 13:56:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gh0TbzRa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233098AbhG2Uy0 (ORCPT + 99 others); Thu, 29 Jul 2021 16:54:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbhG2UyZ (ORCPT ); Thu, 29 Jul 2021 16:54:25 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A60A1C061765 for ; Thu, 29 Jul 2021 13:54:21 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id h8so9978049ede.4 for ; Thu, 29 Jul 2021 13:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=usBsehgRLO8yBDJdVm0jGsDqhFCcetjnZvT1SyvVNfs=; b=Gh0TbzRaoBeJs9ialmAwceZRjyffE2dVJy8s9rQSmMN40X/r1/KR2oTIZ9MfXYwJ7T MpTYGfqj+0M/9T1lzVxW4l2LeNuY9HUr/PTt5WzkT283FRGVhbuUX35S5ZOeinJM7Gvg juTcXgBrG0QXHOwuhh1pji9P8lze6PPZDDwi/18RWfQIOmYw3a8XzyV2RqIMbWJXpMCV HawSskzdX0OG5Kyjfmy1ruwWq3K9T8ZEnjYNtyDe14jwqNro9CPrPHm5E+UTHVam4CXp nZQSlZ5Pn0b9NerlvVAzd1NvBjQchg9GB+ZeMqkqiNOqezr13jKi/llk/2toT6AABeuG eD9w== 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=usBsehgRLO8yBDJdVm0jGsDqhFCcetjnZvT1SyvVNfs=; b=l1/TXh21IQNoVgISFy75IldPxychA+T8ZK7SpE+F9Vnx3Z01SsQ6mNicaEMmf2eNNs VScWUg/szYaXjze7MtkL/7b5fuJaIZCJ70vukFoMoMTUWcA1GhGhM+A3WAJVXrL6ArlT JWkClZteSyaAWtcV4a7bR9v164skegW7q3ekJRwdEgTL6kFwDSUPb88uAsvcSUbpZqtW SOM2KNxFOemKWvyON+bwUcCgZY9UvdSltVi+h1a8gSfwyC3k0i6RsCykzR6+/SJOcGBg O3Tsgl6ZQpCHQ9aUAW2BnLEjuPm244X/8ZUt/56X/QWpmhR8f079K5QYIiL1I6bAG/OW O7fQ== X-Gm-Message-State: AOAM531kl/DwcWqBHuiawVahGd9sVKIq/qaqxGYz0XmROqBAmRMtA+tG 1x1UbXGvk2Q1lEW7NifSKcA= X-Received: by 2002:a05:6402:2919:: with SMTP id ee25mr8299804edb.222.1627592060156; Thu, 29 Jul 2021 13:54:20 -0700 (PDT) Received: from localhost.localdomain (i59F726E2.versanet.de. [89.247.38.226]) by smtp.gmail.com with ESMTPSA id u2sm1625307edd.82.2021.07.29.13.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 13:54:19 -0700 (PDT) From: Padmanabha Srinivasaiah To: jeyu@kernel.org, keescook@chromium.org, nathan@kernel.org, ndesaulniers@google.com Cc: samitolvanen@google.com, treasure4paddy@gmail.com, Miroslav Benes , Stephen Boyd , "Gustavo A. R. Silva" , Joe Perches , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH v3] kallsyms: strip CLANG CFI postfix ".cfi_jt" Date: Thu, 29 Jul 2021 22:53:12 +0200 Message-Id: <20210729205317.25685-1-treasure4paddy@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clang CFI adds a postfix ".cfi_jt" to a symbols of extern functions. For example this breaks syscall tracer that doesn't expect such postfix, so strip out the postfix from the expanded symbol. Signed-off-by: Padmanabha Srinivasaiah --- Change in v3: - Modified commit message to indicate fix is for Clang CFI postfix - Rebased on recent patch from ndesaulniers@google.com. - Fix is enabled even for CONFIG_LTO_CLANG Change in v2: - Use existing routine in kallsyms to strip postfix ".cfi_jt" from extern function name. - Modified the commit message accordingly kernel/kallsyms.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 5cabe4dd3ff4..67d015854cbd 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -174,7 +174,8 @@ static bool cleanup_symbol_name(char *s) * foo.llvm.974640843467629774. This can break hooking of static * functions with kprobes. */ - if (!IS_ENABLED(CONFIG_LTO_CLANG_THIN)) + if (!(IS_ENABLED(CONFIG_LTO_CLANG) || + IS_ENABLED(CONFIG_LTO_CLANG_THIN))) return false; res = strstr(s, ".llvm."); @@ -184,16 +185,24 @@ static bool cleanup_symbol_name(char *s) } /* - * LLVM appends a hash to static function names when ThinLTO and CFI - * are both enabled, i.e. foo() becomes - * foo$707af9a22804d33c81801f27dcfe489b. This causes confusion and - * potentially breaks user space tools, so we strip the suffix from - * expanded symbol names. + * LLVM appends a hash to static function names when both + * (Thin/FULL) LTO and CFI are enabled, i.e. foo() becomes + * foo$707af9a22804d33c81801f27dcfe489b. + * + * In case of non static function symbol , + * the local jump table will have entry as .cfi_jt. + * + * This causes confusion and potentially breaks + * user space tools and some built-in components. + * So we strip the suffix from expanded symbol names. */ if (!IS_ENABLED(CONFIG_CFI_CLANG)) return false; res = strrchr(s, '$'); + if (!res) + res = strstr(s, ".cfi_jt"); + if (res) { *res = '\0'; return true; -- 2.17.1