Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp78300rwd; Fri, 26 May 2023 15:19:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6WlaBRMr6yvwIibTPJ0Sawq4vKHPF4sFpCQwIwsHdAdsrH7GcUr/0U9ZM9Nw36uViKQNDy X-Received: by 2002:a17:903:41c2:b0:1a9:498a:1da2 with SMTP id u2-20020a17090341c200b001a9498a1da2mr4792171ple.56.1685139550115; Fri, 26 May 2023 15:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685139550; cv=none; d=google.com; s=arc-20160816; b=zGWpUYQJf2FMHSHYjRgevO2CIT2y4L0qCDVTQNbMltqDZ/JJQTcXTggJ8pf4vrpqCc om0i4OiEZsNX4IC1MSe7u6i5wLJ4EAHDY8Kl2fX/xvKK+mI3aeo/h2O4BAF4ZGnKIHk6 IyEutog6FMOGkkvh/LnGUXADltf/rvVe/XltpCAS6Cdsg8mS2lAIt36slK2RrImCWoyl b5yLyFhokCVi0E2OWmBrmxxeuuxT/euAQTt5yI82+teV8E+UnMrUgVrOcSssBjAvRT3z DRDZGengjrtR4AZwK6bctYpgG7pkkhhnMutmb1xZqhcFoObornHRHfqdOZvsZGqVWLw8 0TGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=qLAvQMER2SOLnEx4GHgiQ/jrA6UEouP5ZxfYcupEztU=; b=bG68RXCdsBl1cy96Wc9yuZzpgXpeyaZLBOhnmRNhGyzk7q81am7ALXN3n9TSSXhECb 38CxY59WoJSPAHTUR29gXvhVkFuOaqMvnSOUnmMau4PN3NlDC3etBlBUrVaYRXBiNX7p NgOeAdg91peK2xFVRiblZTNR+4Du1hoBuqm2FUFt2vjw5ApJx340XHoxGNY+Kok6Ivo4 zj2ToKYTLiG6F98XIGJUYZz/OYL1Hw9PJwKl03PD3X61fzpU8TqQzJIXrGX560DjmF// 3+YoXjdykRkaV9k4E/mLNV7VXf7g7rZPAfM1Ln+pr6mVuFoSMbM71YjgxBq1/mkrMBGn bcYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=LHM4VIKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o25-20020a637319000000b005303b739292si4932124pgc.702.2023.05.26.15.18.55; Fri, 26 May 2023 15:19:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=LHM4VIKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S244447AbjEZV6D (ORCPT + 99 others); Fri, 26 May 2023 17:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244396AbjEZV5h (ORCPT ); Fri, 26 May 2023 17:57:37 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09B14173A for ; Fri, 26 May 2023 14:56:51 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-53eee18a192so1097221a12.3 for ; Fri, 26 May 2023 14:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685138134; x=1687730134; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qLAvQMER2SOLnEx4GHgiQ/jrA6UEouP5ZxfYcupEztU=; b=LHM4VIKOfTqivALm+Z6T0vyzaEZ8AhlZfyeEq/2NxjnrJsNop9k/1j6vyB4aly1Tk1 Qhcz85JZZ2Eap4d1gY1Nc9GWlL4CRrCRGsac372kC2I4k/hR2tP71bADjEXic7xznLov Gum1LlWhXhearuTMzDTEsvFnnji4htZf2/SW1/iA+liz+btyKGDChTaRKsvLQFs70eem nkm4b8yab0Bxg/D9OLLmxU+FhdlXmcVd94NdytevccMe+mAHpPYgisMuebGa+atYZvBc Yxdbn82rY2wqyW4NTfe1uYK6etSCW9yy2qQgGZPkKz5lPCByXkBI8IEB1yIN9GMA+Jkw o50g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685138134; x=1687730134; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qLAvQMER2SOLnEx4GHgiQ/jrA6UEouP5ZxfYcupEztU=; b=NstKNtb09xwh6bYx1qaFZBrpPpcYL8N6MwHQzqxjUK3vIXcst1elAPsMX80u0LOhJo DHeS7BTx07rs1algu/ibZiybVsrUKiEJimmAOTK9Ja2I+/F7b8JWam0l1W50ashlq6wZ jzrMuSkGBis6R+rDj8p2SigsdfGGpQbkH0BJTN2QcMyVPFzUlSRGS3yyhhCQZdS1O2cy NUyiW+b/M93dYci0GBUl5HIRZ27Or+hH6a1XhZZMF0NRuqCVqlodR61BmH1g306i7O/Q QXc1YevpiCCHAGRPy+CfqjSdyiKPMl6cg5BTgdcVeVfIxMSeZtPTSBRyGXkly/G43QvO Skgw== X-Gm-Message-State: AC+VfDz2vLG2KCEaYoVUnWepxp4iMmnDi5vcTMzOpoeCeEZs/bgAJfoY sUoLcGY7L/H9Bo15ax5TANU= X-Received: by 2002:a17:902:c94a:b0:1af:e2f2:1cce with SMTP id i10-20020a170902c94a00b001afe2f21ccemr5250821pla.38.1685138133854; Fri, 26 May 2023 14:55:33 -0700 (PDT) Received: from smtpclient.apple ([66.170.99.95]) by smtp.gmail.com with ESMTPSA id n14-20020a170902e54e00b001a2135e7eabsm3691204plf.16.2023.05.26.14.55.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 May 2023 14:55:33 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: [PATCH v2] x86/lib: Do not use local symbols with SYM_CODE_START_LOCAL() From: Nadav Amit In-Reply-To: Date: Fri, 26 May 2023 14:55:21 -0700 Cc: Borislav Petkov , Jiri Slaby , Thomas Gleixner , Ingo Molnar , Dave Hansen , X86 ML , LKML Content-Transfer-Encoding: quoted-printable Message-Id: <49861038-B8CA-4CDD-BD44-73066FF453F3@gmail.com> References: <20230525184244.2311-1-namit@vmware.com> <38e24fd4-9213-229d-9919-7ae3bfb113bb@intel.com> <24E47178-C177-425F-A8EF-CFFAE22597D4@gmail.com> <20230526155336.GAZHDWAFi1FRqq83TP@nazgul.local> <0F07EEDB-8A3F-4224-9FF1-43A5300B1B8B@gmail.com> <20230526204559.GAZHEahxxnQaHhSUul@nazgul.local> To: Dave Hansen X-Mailer: Apple Mail (2.3731.500.231) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On May 26, 2023, at 2:17 PM, Dave Hansen = wrote: >=20 > On 5/26/23 14:10, Nadav Amit wrote: >>>> I did not ask to make them global. Just to keep them as local after >>>> linkage in the executable, like all other functions in the kernel. >>> Ok, not global. But local and present in the symbol table: >>>=20 >>> 105185: ffffffff81b89330 17 NOTYPE LOCAL DEFAULT 1 = bad_get_user_clac >>>=20 >>> And again, this helps how exactly? >> Allowing debuggers, tracers, disassemblers and instrumentation tools = to >> work the same way they work as they work with any other piece of code = in >> the kernel. >>=20 >> I personally work on code instrumentation and this makes my life hard = for >> no good reason. >>=20 >> [ Perhaps the question should go the other way around: why addresses = of >> code in these functions should not be mapped to any symbol? ] >=20 > Nadav, is there a chance you could give us a real-life example of how > this affects you as an end user? What's a specific tool that you were > using or a specific problem that you were trying to solve where these > local symbols caused a problem? How would the global symbol have = helped? >=20 > I can certainly _imagine_ some, but I'm curious what you saw that > prompted you to send this patch. So my tool takes a branch trace and then simulates the code execution. As a preparatory step I need to disassemble the code, yet as I do not know where the symbol starts and its size, I can only disassemble one instruction at a time. [ I prefer to disassemble the whole symbol at = once not just for performance, but also to figure out if it includes some instructions that my simulator does not know to simulate correctly. ] In addition, as I read the code from kcore and the binary keeps = changing, I want to assume that if I do not find an address in the symbol table = [*] then it means this is some dynamically generated code that is no longer available through kcore (eBPF, ftrace, etc.). These are only 2 things that break to one extent or another. I can have workarounds for them (I already do). I just see no reason to treat these two symbols differently. I would also note that I can think of many many additional reasons to have each piece of code mapped back to a symbol (besides debuggers, tracers, etc.) For instance, security monitoring tools should prefer to be able to check what code is running in the kernel. I seriously see no downside here and only benefit in consistency and usability. I have no hidden agenda if for some reason you suspect that I do. I don=E2=80=99t want to start talking too much about the tool I = work on, as I am afraid it is off-topic, but I hope to open source it soon.=20 -- [*] I know kallsyms does not give sizes, but I make some reasonable assumptions and augment kallsyms with the symbols from the binary.=