From nobody Fri Dec 19 15:34:28 2025 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31FCE311940 for ; Mon, 13 Oct 2025 15:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369991; cv=none; b=Zke7WirCnwHQtBSWg34GilU1PmPqGkzKq8BwAl8chxpEA5w+AUxiZ0+ncCOOmMzrxtMvbbz/Ot+X004jEFz3dAUrJVq6BMOk9puDCfrpLWUYHpfeZgumX0gtzHZtxnXG3YGajtJf7zuyRXeES0K4VcdAEMyAlFb9zFnK2K/pkbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369991; c=relaxed/simple; bh=mUdyWiaMtVvum5RTj9ic5YSdMHipXTsRvWK4ObexLVs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=RvPwlcYm0WnLM7+htWDzX+EiTB9lzkFGnQLhWXwJTyynyxhpIuQQL6AWQGarOe6MBe81Gif5gcvcHf/oXE+/OEePXKw5BKVQC9ayC2A4ldUSFzMt+J5j3CqXctUczLJCiVRFpl1lM0QNliCZxuEQfaOYRItwAO3oANbRGG8cGB8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KjgXCWRq; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KjgXCWRq" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-3ed9557f976so4420232f8f.3 for ; Mon, 13 Oct 2025 08:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760369987; x=1760974787; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=l8l5v6qiimGPtv9u5QonCWzpEhlvJ98SCHb4SgKDHVc=; b=KjgXCWRqzLtxqtRGkyFp1OT/ckSaASJ6feu6CqLLa/He/M07ri4tWczTjjwiLGB/oL fBxPi/o4LQGx/QIoE78VYtEJfqMze/+zX9ga8bu2VUSWCUtQ1VjNQKlGwy4UbI1zkYZ4 HoIPfLQJfZZ78yjiLNTCBwZfLr28L3+buKbY8vl0ZS8JlmGLD3pXDeMBof8TO2sZWyze JrUYR1C+CknKMyFkiVWM+yXST235jYdvNZpbclvhHgQZM5J0bT05/nWqAv8DdaQOt84U 5iOw4ZAYGXFh8SyAR6orNaqVxy8fRA+tvc51ybgY2Ic1+/zO1o429sdhGwwq6y6+V9c3 IUrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760369987; x=1760974787; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=l8l5v6qiimGPtv9u5QonCWzpEhlvJ98SCHb4SgKDHVc=; b=vKeEj96+i/zn7Ooxi3kvGY8Nxhz1VdA54l2qYglAPtpdj5n77+kPvfzyiIOm0qprA0 yx/wL+8/AIll1He9Gys+OFpa8fYYIn7AuhenexC/eUYCQh19QlwTZ/51FlAs05kbPAII kPHIOrk1uolwY2vMkioGK4pEHrU+6h5V9wj7pQ3H+gVCf9x7QzDDZQBh2gGwbTKj2jL+ mMFyyWILxVxpds6RFu1afjafqHQVz8wbZnGKjwhBGHTcinY2ru/QkK3CHx6YBKdfqNs1 m4jlkRFpAHU3ld4gQfJA5JpnIrGB+bN7BhV6dH7qbI2uYnui0VNAHUm/88TNTP8qWksX C2ow== X-Forwarded-Encrypted: i=1; AJvYcCUfXWL0EGCaYBZRIxnmD195By2L23hTQi2EH4hXU+G3XuWCQdpiJeGmtAq3TpBQzcKeo069VTJYkAKi0+4=@vger.kernel.org X-Gm-Message-State: AOJu0YzfQJ8KXE24TF+MlHjqsxI9K0xjwTvmsI1A3DD8TIoVcgJIzrHP V3C3cwmjzCC49ei/HadLyyElsca03OA46wXpjIqKSfpqQ2/IrTx5UBp4DYpr6qdorCVzxFYs9O1 sS0JurJN47WAJLONTwA== X-Google-Smtp-Source: AGHT+IH1j8tUfipQWeFaA8XhmoFYMLY/hNVnlYfVWyuGOekLQXj/Amrxq8GIzS8vIR8WKDj6T3Cvmmf/SjVMboU= X-Received: from wrmp8.prod.google.com ([2002:adf:e608:0:b0:426:d630:53cb]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:adf:e18a:0:b0:426:d54e:81a4 with SMTP id ffacd0b85a97d-426d54e81b9mr6525079f8f.56.1760369987644; Mon, 13 Oct 2025 08:39:47 -0700 (PDT) Date: Mon, 13 Oct 2025 15:39:09 +0000 In-Reply-To: <20251013153918.2206045-1-sidnayyar@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251013153918.2206045-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.740.g6adb054d12-goog Message-ID: <20251013153918.2206045-2-sidnayyar@google.com> Subject: [PATCH v2 01/10] define kernel symbol flags From: Siddharth Nayyar To: petr.pavlu@suse.com Cc: arnd@arndb.de, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, mcgrof@kernel.org, nathan@kernel.org, nicolas.schier@linux.dev, samitolvanen@google.com, sidnayyar@google.com, maennich@google.com, gprocida@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Symbol flags is an enumeration used to represent flags as a bitset, for example a flag to tell if a symbols GPL only. Signed-off-by: Siddharth Nayyar Reviewed-by: Petr Pavlu --- include/linux/module_symbol.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/module_symbol.h b/include/linux/module_symbol.h index 77c9895b9ddb..574609aced99 100644 --- a/include/linux/module_symbol.h +++ b/include/linux/module_symbol.h @@ -2,6 +2,11 @@ #ifndef _LINUX_MODULE_SYMBOL_H #define _LINUX_MODULE_SYMBOL_H =20 +/* Kernel symbol flags bitset. */ +enum ksym_flags { + KSYM_FLAG_GPL_ONLY =3D 1 << 0, +}; + /* This ignores the intensely annoying "mapping symbols" found in ELF file= s. */ static inline bool is_mapping_symbol(const char *str) { --=20 2.51.0.740.g6adb054d12-goog From nobody Fri Dec 19 15:34:28 2025 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86F10311956 for ; Mon, 13 Oct 2025 15:39:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369992; cv=none; b=q83IIrmfW50PvPbxNhnwolDEUTYXCmdZquHGuEteix4ZM0N5SLNO4biminSK60yQgIHBdYrvh6RZilvKGuSOqE2Q84f2so2GnNE+hRkwmUPYpOyG9S5QmXxDMHMnxLsNuHwNoZmC14CgHXGF31Lah30mBQyqjpscHISL+iTk3Vg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369992; c=relaxed/simple; bh=Yif0tpvEVYMz/HHDWBkZZeP1JAtd0/nIT+vjnx/3i0s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jBnY6RL2CMDCmvlsckTRNToizednIgVIxhQXsPU7/DQUJs8FJhhBXGtn1env42eCQGvGWx3IROiL4X0Bsa87nUTIwgJ06rYngBss9StU/khm2TOs+EO/NLRXm2LEUZOruqkLGK87ajcCxcKzC5EyNQWo/tI4YAmJGEYN1TqIkoc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=JpKq9IXz; arc=none smtp.client-ip=209.85.218.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JpKq9IXz" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-b3c72638b5dso642638766b.3 for ; Mon, 13 Oct 2025 08:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760369989; x=1760974789; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=IjM8d244naCxzVfKtaINlZql2XGUpipFpM5gsitgK2A=; b=JpKq9IXzk38cNBC/fA7lYEgDxwtPgLsT0lLDax9AVeIl5xbvB7S1zLd6x3KMWwRDGe IVvbSZPchTG9ZvltWJCynYwRAIMbsXSnjy/+daHa+R1et3JyCm9TsB6B81SP7KgDo0dD 99HYeBA5Pm7jO3m4atQx1DraZlNXzOdaAqwTkmqw2QlBnCaiJNBM4BxYat2O+29Yt4LR 4xk08xBUksMPlctojrnE1FxVah7nM/VT3n9AaEbLfb9xgm78aHm3zoGiK85+PcU3zKJn 6N5Ckr3K3wl5jUszdD5dwia3ZQuV/ZEfJ6OIeqW4qtlRNLe9qm3GnMpA04MNZPCCZOJK /P+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760369989; x=1760974789; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IjM8d244naCxzVfKtaINlZql2XGUpipFpM5gsitgK2A=; b=ORzPrPaFEtG0AY0XXYhHne4eK92Q1oJicBf+/twPiZ7SBywo97nthXfrpR/wISVbQm IYQQEU6SPFRpLlPEDqHUXzjcguTtxsUc9lpNjHNkJRoQIsmIhmQRw0lFhQ/5tWhwF53R zy4qKh7zveqozUlMViwaS0FgufkJ8exZxSRCG6M87mkJjDzlxPBFUlVQtm3oOye4BjvJ bKzjWRFFaxntk9JKvK7FIEZoHCvZd78E+Xcp8wwYmw/Ka/QA27MXbkrJZB1tHQfQwqJc plbeVfADDRhH1mAv8atmwUfABfXCLW/Mv2pxGx/M3ZoNqO2jC9SWBwJeWIStT1s5sgKp ZK5A== X-Forwarded-Encrypted: i=1; AJvYcCXTXGE0scJc3WeoKDajG+0DNzgfYMN6IXGkQIyLw2D+v3xr9PUYdAwGvArwdC9+S+PQ8tf9buIMdCPEauw=@vger.kernel.org X-Gm-Message-State: AOJu0Yyi1IZ6c1B8dsn6baR2DQtBYz3HsVjFS7X8TnU9plAIDwXwRuyS QmNGFRgAWnCjQLWpg2dhN4Te5uZDU5pi4OGo+RcXjaAd3EbIPmHDOISJlS8qgm0B8WOMGQpL4Pz 2lgRn/051jLBxSMB57g== X-Google-Smtp-Source: AGHT+IGiQtyP/1ptL42LsvljMNhOg+y+bM7AeQigA9x43JIE9KmSCt7yX9mzDsBi3XU7e8y5ilB7RsBmmAFdHxQ= X-Received: from ejrp11.prod.google.com ([2002:a17:906:6a8b:b0:b2b:e1ea:68ee]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:3e8c:b0:b46:cc3b:65fd with SMTP id a640c23a62f3a-b50aa99e1ddmr2177629766b.29.1760369988766; Mon, 13 Oct 2025 08:39:48 -0700 (PDT) Date: Mon, 13 Oct 2025 15:39:10 +0000 In-Reply-To: <20251013153918.2206045-1-sidnayyar@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251013153918.2206045-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.740.g6adb054d12-goog Message-ID: <20251013153918.2206045-3-sidnayyar@google.com> Subject: [PATCH v2 02/10] linker: add kflagstab section to vmlinux and modules From: Siddharth Nayyar To: petr.pavlu@suse.com Cc: arnd@arndb.de, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, mcgrof@kernel.org, nathan@kernel.org, nicolas.schier@linux.dev, samitolvanen@google.com, sidnayyar@google.com, maennich@google.com, gprocida@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This section will contain read-only kernel symbol flag values in the form of a 8-bit bitset. Signed-off-by: Siddharth Nayyar Reviewed-by: Petr Pavlu --- include/asm-generic/vmlinux.lds.h | 7 +++++++ scripts/module.lds.S | 1 + 2 files changed, 8 insertions(+) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index ae2d2359b79e..310e2de56211 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -518,6 +518,13 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPEL= LER_CLANG) __stop___kcrctab_gpl =3D .; \ } \ \ + /* Kernel symbol flags table */ \ + __kflagstab : AT(ADDR(__kflagstab) - LOAD_OFFSET) { \ + __start___kflagstab =3D .; \ + KEEP(*(SORT(___kflagstab+*))) \ + __stop___kflagstab =3D .; \ + } \ + \ /* Kernel symbol table: strings */ \ __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \ *(__ksymtab_strings) \ diff --git a/scripts/module.lds.S b/scripts/module.lds.S index ee79c41059f3..9a8a3b6d1569 100644 --- a/scripts/module.lds.S +++ b/scripts/module.lds.S @@ -23,6 +23,7 @@ SECTIONS { __ksymtab_gpl 0 : ALIGN(8) { *(SORT(___ksymtab_gpl+*)) } __kcrctab 0 : ALIGN(4) { *(SORT(___kcrctab+*)) } __kcrctab_gpl 0 : ALIGN(4) { *(SORT(___kcrctab_gpl+*)) } + __kflagstab 0 : ALIGN(1) { *(SORT(___kflagstab+*)) } =20 .ctors 0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) } .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) } --=20 2.51.0.740.g6adb054d12-goog From nobody Fri Dec 19 15:34:28 2025 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57D12311969 for ; Mon, 13 Oct 2025 15:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369993; cv=none; b=kfQumLU0T6Hg+8NnYzKK1CXEUN06L1xsNh1IIgNP8yH1M6DiuyfvbET41bkfvnibSfrhvpWeQa2yoXM4WgycBAZ/hqPgze8r0MEHlOIaUtFOq58HFylN4fOz4lsPmeAB2910RLZPkGz7iDh9ZegTEaUgszoqNbTFtBqFdeWaUlI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369993; c=relaxed/simple; bh=am6eR0+LUPty8s6xAM1cP/GUuFeuZfjlS3+RH+AoatY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=H19+XSWOr0G0koBVRhCU7kuhFI4Ng9rALZuqmfFjzdFVkUx28ww2/5UZNjP2y8JiqqCZQ1Gf8cfYqvQaMG6e2oOCyygjWwcHFu9dmFHXmAb36TJF6UgKq0neDVuEJSIvl/VJJY9Llsf7ij45MWBKSLJKrvu80Sh+IOnXMoZR3/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=abrZf60f; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="abrZf60f" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-46e473e577eso30176255e9.0 for ; Mon, 13 Oct 2025 08:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760369990; x=1760974790; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=1Myo1tBFgG2jkTnheFNaxzL0Ia+2mIIh3L6V96Qq92Y=; b=abrZf60fPhxOTc2Vhl9s9sQXRqj5FhOaPrvHNDKhWOXMyaZGIgBNDsbne/6ifcZkJD skf5hkz4IiKihRc00v5PjAnY1CKQVMIMBY17SMaK+uUl6g3D+dlq1jJVR58F014rqyU6 wXJzrE4o2DYu4S3D9vR2Q304EJJIMPdDU0hnKRNR7Jyn5GoAtCQ3m4EPaIfGYUiy/yhi dLt5oP3DRfUEjJcva6F8n4SODpPU/AJzG460ytQohq2ZG91VGCaQaCEnpaNK8qmPxds5 YjzaeEB8pTBLoOYjSp6VnpxLwGyoarS9SVajS5Dak3nnZo0JJUu0IhsJvT6YsR5OfPNh s1Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760369990; x=1760974790; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1Myo1tBFgG2jkTnheFNaxzL0Ia+2mIIh3L6V96Qq92Y=; b=HEjaLNplaar7gQZcWqzdxOzhYH516phH28SRX3UQ0siHgzFwpILwGr7NT68QCrOBUR jWMK2BRCSNRIZ/9eJsW6LNbU40cxMiuRd3CHOEUZKg9hskfgytFhC23RW1aleE+dPM/d hKdONM2n0BQUyz+nKnhzR9v4BBNMqQmfFj9ox06RaWpD6s+hKlr8OJYVXWdaOQ0Qpv8Q 9RsF/UxgUx+468g86I2akLeE3RGVYD9MXLRfdqZ0rSlla870X9L4otqQBtOVy/xZsOtC gs00VoBZVLV+fVdhfHewSWhb/pvTg3DYQ8sw/MQAzxuKeVbcgJeh3xgzCPnyjGqrhbzK 2Jhw== X-Forwarded-Encrypted: i=1; AJvYcCUEv+TbMLlbvY6/0NC1q6O4wD5SmPvX8YQx5LcGKUbsMr25dvlkaK1kzHN91Yv3rA3KRlqD6hPZqKokFhA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy8lEqzVxBfN+2HK2uF12TuDpMzmU+Gmy1T1QwBeD6AwCxzjSYM 042rgN0MMvOjyH3Ut1lf2RLPkzhf9CuG42xaXsc0vFmx4JIEhW7DQsxm5uIyhGsrvrPmhsLx9mQ wl0UgfnA9hAipph2gFA== X-Google-Smtp-Source: AGHT+IE5k2WNSHbbxjeh2VOaTDuZYIuyr+f8VRPTxapGvluVBHAsbTnBwim1QiDvl7TYkeZOfgF/UT+SPZHk5uk= X-Received: from wmcn15.prod.google.com ([2002:a05:600c:c0cf:b0:46e:32e6:eb8f]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1d1a:b0:46e:4a78:dea9 with SMTP id 5b1f17b1804b1-46fa9af17d4mr148931395e9.17.1760369989707; Mon, 13 Oct 2025 08:39:49 -0700 (PDT) Date: Mon, 13 Oct 2025 15:39:11 +0000 In-Reply-To: <20251013153918.2206045-1-sidnayyar@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251013153918.2206045-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.740.g6adb054d12-goog Message-ID: <20251013153918.2206045-4-sidnayyar@google.com> Subject: [PATCH v2 03/10] modpost: create entries for kflagstab From: Siddharth Nayyar To: petr.pavlu@suse.com Cc: arnd@arndb.de, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, mcgrof@kernel.org, nathan@kernel.org, nicolas.schier@linux.dev, samitolvanen@google.com, sidnayyar@google.com, maennich@google.com, gprocida@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Siddharth Nayyar Reviewed-by: Petr Pavlu --- include/linux/export-internal.h | 7 +++++++ scripts/mod/modpost.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/export-internal.h b/include/linux/export-interna= l.h index d445705ac13c..4123c7592404 100644 --- a/include/linux/export-internal.h +++ b/include/linux/export-internal.h @@ -69,4 +69,11 @@ ".long " #crc "\n" \ ".previous" "\n") =20 +#define SYMBOL_FLAGS(sym, flags) \ + asm(" .section \"___kflagstab+" #sym "\",\"a\"" "\n" \ + "__flags_" #sym ":" "\n" \ + " .byte " #flags "\n" \ + " .previous" "\n" \ + ) + #endif /* __LINUX_EXPORT_INTERNAL_H__ */ diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 5ca7c268294e..f5ce7aeed52d 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -244,6 +244,11 @@ static struct symbol *alloc_symbol(const char *name) return s; } =20 +static uint8_t get_symbol_flags(const struct symbol *sym) +{ + return sym->is_gpl_only ? KSYM_FLAG_GPL_ONLY : 0; +} + /* For the hash of exported symbols */ static void hash_add_symbol(struct symbol *sym) { @@ -1865,6 +1870,9 @@ static void add_exported_symbols(struct buffer *buf, = struct module *mod) buf_printf(buf, "KSYMTAB_%s(%s, \"%s\", \"%s\");\n", sym->is_func ? "FUNC" : "DATA", sym->name, sym->is_gpl_only ? "_gpl" : "", sym->namespace); + + buf_printf(buf, "SYMBOL_FLAGS(%s, 0x%02x);\n", + sym->name, get_symbol_flags(sym)); } =20 if (!modversions) --=20 2.51.0.740.g6adb054d12-goog From nobody Fri Dec 19 15:34:28 2025 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A5C631197A for ; Mon, 13 Oct 2025 15:39:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369994; cv=none; b=dByeA/z8G8fnAnkkKa5bSB1s0nvYq52PqTLusMMJ4twvmvrHA5yImg2zEaMfhJU+OBweq9ljUxEAmYoxXWcIjcSq7l+ltzWAboUoOL5pgjTIWx7OUWyfXD4e0LZ/8fiTIbUZ9fslr+yYXDQvFQGUwCQ9JV7ll+LlNDvgslGMeX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369994; c=relaxed/simple; bh=dfr6XRob40CPKAWcqan5eteUxA+ytUveF2Ud2J29B08=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mBV/ypRHwfymUT/xlKf9sqvGMOOQ549ivKei39qH5ycAh1prXQm/DZHlEqnOyiNzYwbgScQ2VqemMIhPkS9SYW3Dp1h3ofWsXmL0jJKvs80bcLgiLNuQ/YL3PVuQtZkLm6A1Ownsb5s2dozMttm0HWjOyeEZchvmRm17M/up78k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bYyODbIN; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bYyODbIN" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-46e36f9c651so29351555e9.3 for ; Mon, 13 Oct 2025 08:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760369990; x=1760974790; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=X313eGs97I2iWdqADzIwqZMEwq+XwpBGENiqEW2tqII=; b=bYyODbINI5+TiUYjPGv1mSgGUX7y8/KdS7sSYn0a18qSl5H98BFRq4K6t6/bn0l7um QuWAf2aC0QmZTzAeDDekBVP4cmClpqRnAmbn2Llypd6bbQ56Fb+LhwZxDOhnzob4sNGb 1zpLoOHUu1as4qUqQAxfbXzkazdFAuTV7q2c9CsD1buocckghojqormYtoMM8P3TNI28 DjPTtGqS+AjAVIR+5T77MWW0SiByQaJxp8gjY5jX+k0+aNFjKux6WChZHeqnpHVY2XaC icF1+1ngA9zHjqEmwkSUjcELAXxsWtlggTEdQvp9OrXxiBzmpW7X9vKnx8Ukzgh9ByHz ek/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760369990; x=1760974790; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=X313eGs97I2iWdqADzIwqZMEwq+XwpBGENiqEW2tqII=; b=a/cYxKIz9e/ASiaHjF7e+UYfM1YHwobCslO6kKrHSvNHQVTfrzWQ0mH+1gpwxgjUmU AZSTKacZ1DcjHBTFhUcgXUjR6VhyVmVCHXSqgkIWdF17QqCvcOfNRwmIesu6IeqTkKkr n9I8eDdgCoIvkrH/P0TVcgwXOV9MfVVyCgqAqt/qW/lhV5l0qugCv+UuZ9mJhkHxOReb Ma1wxe1hjGCwi2GubHEf+Xzky+c/0cFv9aRhw+7V+HLCCIz+EBfSL624t6Bkdvr8TjTY 41fddqX8CLBFbR2GA7h1VnVSIv6PYLAHj6lG4OTx4Gx6bXCJaGUZoffK42m9h4Cr+JF2 be1w== X-Forwarded-Encrypted: i=1; AJvYcCWj5d6DtQ6lZr7g/izjyGs4MrIcpvsWka5fFfb66cUW65OsoZf+nKo8YNTUkOjuXf66tmLPVUooTkGV3js=@vger.kernel.org X-Gm-Message-State: AOJu0YxRVqF/jZcQ/766fOB9BeJEcllMX7y7+SazrCUkLWVQj/CgswEh ikM8CSvcRHTDJLlFCBOc8oVDoNrf7XVrgTpb99aMyb67bIISqGlIb5n3PAXqLLsw9bS4CbT/3y6 n3WlijTgW2ivWetCV0A== X-Google-Smtp-Source: AGHT+IF1OUtaJZbznzCIqJxNUxLFx37pVHVCwzTbAWrYjRCpog3arVCAEs4KerdChcXAgLggL/JaQE+k6VXD5b4= X-Received: from wmlu17.prod.google.com ([2002:a05:600c:2111:b0:46e:2eb4:38d]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:8b42:b0:45d:e6b6:55fe with SMTP id 5b1f17b1804b1-46fa9b16607mr165506645e9.34.1760369990483; Mon, 13 Oct 2025 08:39:50 -0700 (PDT) Date: Mon, 13 Oct 2025 15:39:12 +0000 In-Reply-To: <20251013153918.2206045-1-sidnayyar@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251013153918.2206045-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.740.g6adb054d12-goog Message-ID: <20251013153918.2206045-5-sidnayyar@google.com> Subject: [PATCH v2 04/10] module loader: use kflagstab instead of *_gpl sections From: Siddharth Nayyar To: petr.pavlu@suse.com Cc: arnd@arndb.de, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, mcgrof@kernel.org, nathan@kernel.org, nicolas.schier@linux.dev, samitolvanen@google.com, sidnayyar@google.com, maennich@google.com, gprocida@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Read __kflagstab section for vmlinux and modules to determine whether kernel symbols are GPL only. Signed-off-by: Siddharth Nayyar Reviewed-by: Petr Pavlu --- include/linux/module.h | 1 + kernel/module/internal.h | 1 + kernel/module/main.c | 55 +++++++++++++++++++++------------------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 3319a5269d28..9ba6ce433ac3 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -415,6 +415,7 @@ struct module { /* Exported symbols */ const struct kernel_symbol *syms; const u32 *crcs; + const u8 *flagstab; unsigned int num_syms; =20 #ifdef CONFIG_ARCH_USES_CFI_TRAPS diff --git a/kernel/module/internal.h b/kernel/module/internal.h index 618202578b42..69b84510e097 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -57,6 +57,7 @@ extern const struct kernel_symbol __start___ksymtab_gpl[]; extern const struct kernel_symbol __stop___ksymtab_gpl[]; extern const u32 __start___kcrctab[]; extern const u32 __start___kcrctab_gpl[]; +extern const u8 __start___kflagstab[]; =20 #define KMOD_PATH_LEN 256 extern char modprobe_path[]; diff --git a/kernel/module/main.c b/kernel/module/main.c index c66b26184936..4197af526087 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -87,7 +88,7 @@ struct mod_tree_root mod_tree __cacheline_aligned =3D { struct symsearch { const struct kernel_symbol *start, *stop; const u32 *crcs; - enum mod_license license; + const u8 *flagstab; }; =20 /* @@ -364,19 +365,21 @@ static bool find_exported_symbol_in_section(const str= uct symsearch *syms, struct find_symbol_arg *fsa) { struct kernel_symbol *sym; - - if (!fsa->gplok && syms->license =3D=3D GPL_ONLY) - return false; + u8 sym_flags; =20 sym =3D bsearch(fsa->name, syms->start, syms->stop - syms->start, sizeof(struct kernel_symbol), cmp_name); if (!sym) return false; =20 + sym_flags =3D *(syms->flagstab + (sym - syms->start)); + if (!fsa->gplok && (sym_flags & KSYM_FLAG_GPL_ONLY)) + return false; + fsa->owner =3D owner; fsa->crc =3D symversion(syms->crcs, sym - syms->start); fsa->sym =3D sym; - fsa->license =3D syms->license; + fsa->license =3D (sym_flags & KSYM_FLAG_GPL_ONLY) ? GPL_ONLY : NOT_GPL_ON= LY; =20 return true; } @@ -387,36 +390,31 @@ static bool find_exported_symbol_in_section(const str= uct symsearch *syms, */ bool find_symbol(struct find_symbol_arg *fsa) { - static const struct symsearch arr[] =3D { - { __start___ksymtab, __stop___ksymtab, __start___kcrctab, - NOT_GPL_ONLY }, - { __start___ksymtab_gpl, __stop___ksymtab_gpl, - __start___kcrctab_gpl, - GPL_ONLY }, + const struct symsearch syms =3D { + .start =3D __start___ksymtab, + .stop =3D __stop___ksymtab, + .crcs =3D __start___kcrctab, + .flagstab =3D __start___kflagstab, }; struct module *mod; - unsigned int i; =20 - for (i =3D 0; i < ARRAY_SIZE(arr); i++) - if (find_exported_symbol_in_section(&arr[i], NULL, fsa)) - return true; + if (find_exported_symbol_in_section(&syms, NULL, fsa)) + return true; =20 list_for_each_entry_rcu(mod, &modules, list, lockdep_is_held(&module_mutex)) { - struct symsearch arr[] =3D { - { mod->syms, mod->syms + mod->num_syms, mod->crcs, - NOT_GPL_ONLY }, - { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms, - mod->gpl_crcs, - GPL_ONLY }, + const struct symsearch syms =3D { + .start =3D mod->syms, + .stop =3D mod->syms + mod->num_syms, + .crcs =3D mod->crcs, + .flagstab =3D mod->flagstab, }; =20 if (mod->state =3D=3D MODULE_STATE_UNFORMED) continue; =20 - for (i =3D 0; i < ARRAY_SIZE(arr); i++) - if (find_exported_symbol_in_section(&arr[i], mod, fsa)) - return true; + if (find_exported_symbol_in_section(&syms, mod, fsa)) + return true; } =20 pr_debug("Failed to find symbol %s\n", fsa->name); @@ -2607,6 +2605,7 @@ static int find_module_sections(struct module *mod, s= truct load_info *info) sizeof(*mod->gpl_syms), &mod->num_gpl_syms); mod->gpl_crcs =3D section_addr(info, "__kcrctab_gpl"); + mod->flagstab =3D section_addr(info, "__kflagstab"); =20 #ifdef CONFIG_CONSTRUCTORS mod->ctors =3D section_objs(info, ".ctors", @@ -2810,8 +2809,12 @@ static int move_module(struct module *mod, struct lo= ad_info *info) return ret; } =20 -static int check_export_symbol_versions(struct module *mod) +static int check_export_symbol_sections(struct module *mod) { + if (mod->num_syms && !mod->flagstab) { + pr_err("%s: no flags for exported symbols\n", mod->name); + return -ENOEXEC; + } #ifdef CONFIG_MODVERSIONS if ((mod->num_syms && !mod->crcs) || (mod->num_gpl_syms && !mod->gpl_crcs)) { @@ -3427,7 +3430,7 @@ static int load_module(struct load_info *info, const = char __user *uargs, if (err) goto free_unload; =20 - err =3D check_export_symbol_versions(mod); + err =3D check_export_symbol_sections(mod); if (err) goto free_unload; =20 --=20 2.51.0.740.g6adb054d12-goog From nobody Fri Dec 19 15:34:28 2025 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A54D311C2D for ; Mon, 13 Oct 2025 15:39:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369995; cv=none; b=kSM6KFPoz5txVCXm5ikOKIE570p8TG5COQsQbu5F6ZO7lK0ytRi94YcZaztFCeTiZKba/QOkC0Jd+JqGhS0i5sMh7cjyte6X7Cy5l/tmvyrBozM31EPv/CJk7wjdSM5TmLO+v1KLfB8SdR8WzhE47Lp1Sjf5gv05mvMDna+a27k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369995; c=relaxed/simple; bh=fDM6kg3PMSfYuYByY6oqdA9ZDhOomL/usVMge98nAI8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mV5gFGOB5spJPShz9yzWVt+Ri0yPVAY5KVzKZnFEOWimBODhN8isRzwDVC2XypaDF7Rg7ds1VnX5M+x7mXfzWFxSok9wYuOAqdHdzxlRB6oQf+0dEHpjMVyUhwH9DI0+3gIcjYnWPxxlkKsdP9YmfF0Elz0GO4mis4/0Tvz0dZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rEuKg6E6; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rEuKg6E6" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-3ecdf7b5c46so2063993f8f.2 for ; Mon, 13 Oct 2025 08:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760369991; x=1760974791; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LLIMysTR71S/0o+W4A3DXR+AhBZbEvctBTcDuVNaPrw=; b=rEuKg6E6xRTEhj4pvTGndHEOsGa541HwYGEMeNSiahe8xyt9HdQtOxbM/wLguGzfHw lbrEV0QW/HkVblNVjqGDdBNJEv15rEQAYLgodGw6xBFQdP+ilJhHa0lo/9aa3Pu2I522 mMco7EARXC2YgdxxcW9O3CKMom1yo9+NS+awMA6uDGEOmK5/nkVfB+jLMTmyrj6OgBlI ghCI0d08+ud70oNV88fISMXlZAzUUYkdhCAtxpPqJ0owxCpsVagtnsacRfQGX9TFELZJ 1OmEK2JzEDwrPhWB0Yj40N3eouXIWrUptrTLQ9+fWt/Q5UxZqPyqmK+PAoWGgO9cBfe3 nzRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760369991; x=1760974791; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LLIMysTR71S/0o+W4A3DXR+AhBZbEvctBTcDuVNaPrw=; b=RtBQmtMlxNJGxhHXcfgH0lD6iARVZ5tm39jR2yYGwi5zDSn97M3qlQEft7vnWpsBef XW9ji0T7QgYnM5c5FB2JH4SiuIp/GJCTBODL6qIx2gWyLwR3yagffDTlEoIhfc4qKROK VfaMMq0zFVzVWH+SxsC/uaWgN2iCAERiazdJcQgiAhFKJCmlwmeSD710PmhOWNIO715w lSLxnHhr1CtSrS7831NE4UDFICi5a8rEAHztvTjiVwzLoAOjbu7t5Cw5vfMbH5pxWx+Y i6jQIEgb+HSCmdRXGF94Hk1r4T4F1y2uVtyP4n09+Y1kDwrYHEbJQyGJ3b227dNXR6NA xzKw== X-Forwarded-Encrypted: i=1; AJvYcCXzQVwJB+WiSxghtQUZY1CZbuYKI9n5zN+KNO9ypvntR/Yh4QrgFWbyis9Zrd90VUz7GFHDLwqM5/+qrYc=@vger.kernel.org X-Gm-Message-State: AOJu0YwFJh3kSAIVlJ/GzLFrXWWCe2ylbRrJxwDzEbzhJAVh44hicGcn 2CbA9Qd2N070tJYj1azx3WwEZrrAriblRrdQUDulorzXjEc7enyZAJ0St6tR2Ctdqt7Aj7ovuch h/5Dueb8W7dSb98H6sQ== X-Google-Smtp-Source: AGHT+IFP4hNwTNRL33nbMqqEWJZ6dS2HryYYTX8R63ntqFIn3FAoAX0EvUWPA8ISlAngJYPDX/qIYNcJsWpCB6o= X-Received: from wmcn2.prod.google.com ([2002:a05:600c:c0c2:b0:45f:28dd:87d9]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:6304:b0:46f:b42e:e39c with SMTP id 5b1f17b1804b1-46fb42ee509mr93409275e9.41.1760369991432; Mon, 13 Oct 2025 08:39:51 -0700 (PDT) Date: Mon, 13 Oct 2025 15:39:13 +0000 In-Reply-To: <20251013153918.2206045-1-sidnayyar@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251013153918.2206045-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.740.g6adb054d12-goog Message-ID: <20251013153918.2206045-6-sidnayyar@google.com> Subject: [PATCH v2 05/10] modpost: put all exported symbols in ksymtab section From: Siddharth Nayyar To: petr.pavlu@suse.com Cc: arnd@arndb.de, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, mcgrof@kernel.org, nathan@kernel.org, nicolas.schier@linux.dev, samitolvanen@google.com, sidnayyar@google.com, maennich@google.com, gprocida@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since the modules loader determines whether an exported symbol is GPL only from the kflagstab section data, modpost can put all symbols in the regular ksymtab and stop using the *_gpl versions of the ksymtab and kcrctab. Signed-off-by: Siddharth Nayyar Reviewed-by: Petr Pavlu --- include/linux/export-internal.h | 21 +++++++++++---------- scripts/mod/modpost.c | 8 ++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/linux/export-internal.h b/include/linux/export-interna= l.h index 4123c7592404..726054614752 100644 --- a/include/linux/export-internal.h +++ b/include/linux/export-internal.h @@ -37,14 +37,14 @@ * section flag requires it. Use '%progbits' instead of '@progbits' since = the * former apparently works on all arches according to the binutils source. */ -#define __KSYMTAB(name, sym, sec, ns) \ +#define __KSYMTAB(name, sym, ns) \ asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1" "\n" \ "__kstrtab_" #name ":" "\n" \ " .asciz \"" #name "\"" "\n" \ "__kstrtabns_" #name ":" "\n" \ " .asciz \"" ns "\"" "\n" \ " .previous" "\n" \ - " .section \"___ksymtab" sec "+" #name "\", \"a\"" "\n" \ + " .section \"___ksymtab+" #name "\", \"a\"" "\n" \ __KSYM_ALIGN "\n" \ "__ksymtab_" #name ":" "\n" \ __KSYM_REF(sym) "\n" \ @@ -59,15 +59,16 @@ #define KSYM_FUNC(name) name #endif =20 -#define KSYMTAB_FUNC(name, sec, ns) __KSYMTAB(name, KSYM_FUNC(name), sec, = ns) -#define KSYMTAB_DATA(name, sec, ns) __KSYMTAB(name, name, sec, ns) +#define KSYMTAB_FUNC(name, ns) __KSYMTAB(name, KSYM_FUNC(name), ns) +#define KSYMTAB_DATA(name, ns) __KSYMTAB(name, name, ns) =20 -#define SYMBOL_CRC(sym, crc, sec) \ - asm(".section \"___kcrctab" sec "+" #sym "\",\"a\"" "\n" \ - ".balign 4" "\n" \ - "__crc_" #sym ":" "\n" \ - ".long " #crc "\n" \ - ".previous" "\n") +#define SYMBOL_CRC(sym, crc) \ + asm(" .section \"___kcrctab+" #sym "\",\"a\"" "\n" \ + " .balign 4" "\n" \ + "__crc_" #sym ":" "\n" \ + " .long " #crc "\n" \ + " .previous" "\n" \ + ) =20 #define SYMBOL_FLAGS(sym, flags) \ asm(" .section \"___kflagstab+" #sym "\",\"a\"" "\n" \ diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f5ce7aeed52d..8936db84779b 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1867,9 +1867,9 @@ static void add_exported_symbols(struct buffer *buf, = struct module *mod) if (trim_unused_exports && !sym->used) continue; =20 - buf_printf(buf, "KSYMTAB_%s(%s, \"%s\", \"%s\");\n", + buf_printf(buf, "KSYMTAB_%s(%s, \"%s\");\n", sym->is_func ? "FUNC" : "DATA", sym->name, - sym->is_gpl_only ? "_gpl" : "", sym->namespace); + sym->namespace); =20 buf_printf(buf, "SYMBOL_FLAGS(%s, 0x%02x);\n", sym->name, get_symbol_flags(sym)); @@ -1890,8 +1890,8 @@ static void add_exported_symbols(struct buffer *buf, = struct module *mod) sym->name, mod->name, mod->is_vmlinux ? "" : ".ko", sym->name); =20 - buf_printf(buf, "SYMBOL_CRC(%s, 0x%08x, \"%s\");\n", - sym->name, sym->crc, sym->is_gpl_only ? "_gpl" : ""); + buf_printf(buf, "SYMBOL_CRC(%s, 0x%08x);\n", + sym->name, sym->crc); } } =20 --=20 2.51.0.740.g6adb054d12-goog From nobody Fri Dec 19 15:34:28 2025 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36AD031BCA3 for ; Mon, 13 Oct 2025 15:39:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369996; cv=none; b=I6Z+Wdf7KnzhLDqA4WVkiy8nUI1lLdWv20HlsbLVmHxLJeOBsWoSS/W/nv8eQ8V9I8U9bmMgLTc77zbfvzzKJOZ1pVHaUhEB2bSWA87sqIoBh8Dp93qIYexhMKLPWofC74V3r8QnF+7D1PBm1kZzLtfUNg9oJ3imBsEtSQP3Ng8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369996; c=relaxed/simple; bh=RLWrJA6e0o1fvEZPXCTEkfPrFrwKqhIpIw4wVbO6co8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=oc56c8cZXTMAsyqjtYu5WawLV9kmIGCQkmygC3B7W/mBPT7v7argSpXDRK+DAxlsw+Dv4E8NBFU2N8f3lP1N6Jm+85oRdNi4U6h4IGXzH1aSn9xUmHZzIP+yCoE+UttOXJ+RzFeg+Sg/qeLBvYMEmKuDx0aeaBlHoxVRUjJnl+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SjQIS3Ul; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SjQIS3Ul" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-46e4335fa87so30540515e9.0 for ; Mon, 13 Oct 2025 08:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760369992; x=1760974792; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=a+g1ys0MMb9WULZqvnNzuABkcTm+/NGxqiHjvVRRSBI=; b=SjQIS3Ul7/PrB8Pe97ZCMHCNseoYl5UvPNI27D7c+HJ3hHzFY/1b1sPpHkwcN1XhHe 6DelFYo3MAXKB58aIWz3RUmtaaS+HItuauZJsaFqfA6wrhInQZlXQQaC6HZhqsLg0wN1 WOD8e03pvhHhZ8Q/LAI3nwJMuK1UR5lfkiQy+jw7G6JYF5M7oMlKxvd6vtH3YHkydxss +MO3pRmjlRar8/4u0YEI/IuELW5qoCB/DK0Re6ihFlxMo7N9/ekX8tcqKxF3DmAgpPJr WDZmLzLITaOVQtQ1ohxPoJAY50Ou27HMkBcl1+AHivBqcKByMT4vwA53HR1mrGRGSsXL LoKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760369992; x=1760974792; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=a+g1ys0MMb9WULZqvnNzuABkcTm+/NGxqiHjvVRRSBI=; b=sIqmDlynf0K3dQLqEwFV9lI6HinqgqTSvtE7ucjWHnXNzUgRA+NVVBvUl3mvs2i+GN QWCNOWvpfsj2ZD4R43RE9yVbblPbAUgDGrpxA+6doVhlV3pl0MX+jUpjVx7GgqN5MZlY H/2BKuxO4WhDnUDtg+nRjHVeT1m4dS2Z8uNP+2BND+QkzZwmSvW+RUOcowmztKOwePnM e1G2b9uVlKZELS3ELOrF6lq49+OzOLSAXFPA3Y2L5iFmDeA19EH/bMRZEpzwbb74i2zL jniG37BPOTwdhtOB9Fpgc4Yqjc0573vsvO5/HkIwn2f5fRNtoLVxZGDQzy17aiwskeSN 9e2A== X-Forwarded-Encrypted: i=1; AJvYcCU/yOH6GYZu9G3+hB6i20g5fXedSaM/QF1C+NboJe1s8FZwYfHlK4dHfGlGVVq2Bon4E4dpyERExyYzVNM=@vger.kernel.org X-Gm-Message-State: AOJu0YyQ4S7vBOHHjQlrK7S93M2ugYSBDClItJtwlXhD0eQGM+YwkAa3 7Lf5JdluY/AhhBUeMotVy3tePanF1s5PGhaLEMysozZLfRpx+H7eh/X+KRmGdJ1RaQQNTQ7C2w9 axZHDB3OFZ34uZutx9Q== X-Google-Smtp-Source: AGHT+IGLaf0ASghwkahJRWS3hPq7oT6ve24L37x4B6OnXmFbgLy02R9Qw5r8wqjyhj+HwGR3CdmVAm9wSPmh24g= X-Received: from wmbgx15.prod.google.com ([2002:a05:600c:858f:b0:46f:b153:bfb7]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:c4ab:b0:46e:46c8:edac with SMTP id 5b1f17b1804b1-46fce364066mr11500775e9.11.1760369992506; Mon, 13 Oct 2025 08:39:52 -0700 (PDT) Date: Mon, 13 Oct 2025 15:39:14 +0000 In-Reply-To: <20251013153918.2206045-1-sidnayyar@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251013153918.2206045-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.740.g6adb054d12-goog Message-ID: <20251013153918.2206045-7-sidnayyar@google.com> Subject: [PATCH v2 06/10] module loader: remove references of *_gpl sections From: Siddharth Nayyar To: petr.pavlu@suse.com Cc: arnd@arndb.de, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, mcgrof@kernel.org, nathan@kernel.org, nicolas.schier@linux.dev, samitolvanen@google.com, sidnayyar@google.com, maennich@google.com, gprocida@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The *_gpl section are not being used populated by modpost anymore. Hence the module loader doesn't need to find and process these sections in modules. Signed-off-by: Siddharth Nayyar Reviewed-by: Petr Pavlu --- include/linux/module.h | 3 --- kernel/module/internal.h | 3 --- kernel/module/main.c | 47 ++++++++++++++++------------------------ 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 9ba6ce433ac3..1a9c41318e22 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -431,9 +431,6 @@ struct module { unsigned int num_kp; =20 /* GPL-only exported symbols. */ - unsigned int num_gpl_syms; - const struct kernel_symbol *gpl_syms; - const u32 *gpl_crcs; bool using_gplonly_symbols; =20 #ifdef CONFIG_MODULE_SIG diff --git a/kernel/module/internal.h b/kernel/module/internal.h index 69b84510e097..061161cc79d9 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -53,10 +53,7 @@ extern const size_t modinfo_attrs_count; /* Provided by the linker */ extern const struct kernel_symbol __start___ksymtab[]; extern const struct kernel_symbol __stop___ksymtab[]; -extern const struct kernel_symbol __start___ksymtab_gpl[]; -extern const struct kernel_symbol __stop___ksymtab_gpl[]; extern const u32 __start___kcrctab[]; -extern const u32 __start___kcrctab_gpl[]; extern const u8 __start___kflagstab[]; =20 #define KMOD_PATH_LEN 256 diff --git a/kernel/module/main.c b/kernel/module/main.c index 4197af526087..f5f9872dc070 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -1464,29 +1464,18 @@ EXPORT_SYMBOL_GPL(__symbol_get); */ static int verify_exported_symbols(struct module *mod) { - unsigned int i; const struct kernel_symbol *s; - struct { - const struct kernel_symbol *sym; - unsigned int num; - } arr[] =3D { - { mod->syms, mod->num_syms }, - { mod->gpl_syms, mod->num_gpl_syms }, - }; - - for (i =3D 0; i < ARRAY_SIZE(arr); i++) { - for (s =3D arr[i].sym; s < arr[i].sym + arr[i].num; s++) { - struct find_symbol_arg fsa =3D { - .name =3D kernel_symbol_name(s), - .gplok =3D true, - }; - if (find_symbol(&fsa)) { - pr_err("%s: exports duplicate symbol %s" - " (owned by %s)\n", - mod->name, kernel_symbol_name(s), - module_name(fsa.owner)); - return -ENOEXEC; - } + for (s =3D mod->syms; s < mod->syms + mod->num_syms; s++) { + struct find_symbol_arg fsa =3D { + .name =3D kernel_symbol_name(s), + .gplok =3D true, + }; + if (find_symbol(&fsa)) { + pr_err("%s: exports duplicate symbol %s" + " (owned by %s)\n", + mod->name, kernel_symbol_name(s), + module_name(fsa.owner)); + return -ENOEXEC; } } return 0; @@ -2601,12 +2590,15 @@ static int find_module_sections(struct module *mod,= struct load_info *info) mod->syms =3D section_objs(info, "__ksymtab", sizeof(*mod->syms), &mod->num_syms); mod->crcs =3D section_addr(info, "__kcrctab"); - mod->gpl_syms =3D section_objs(info, "__ksymtab_gpl", - sizeof(*mod->gpl_syms), - &mod->num_gpl_syms); - mod->gpl_crcs =3D section_addr(info, "__kcrctab_gpl"); mod->flagstab =3D section_addr(info, "__kflagstab"); =20 + if (section_addr(info, "__ksymtab_gpl")) + pr_warn("%s: ignoring obsolete section __ksymtab_gpl\n", + mod->name); + if (section_addr(info, "__kcrctab_gpl")) + pr_warn("%s: ignoring obsolete section __kcrctab_gpl\n", + mod->name); + #ifdef CONFIG_CONSTRUCTORS mod->ctors =3D section_objs(info, ".ctors", sizeof(*mod->ctors), &mod->num_ctors); @@ -2816,8 +2808,7 @@ static int check_export_symbol_sections(struct module= *mod) return -ENOEXEC; } #ifdef CONFIG_MODVERSIONS - if ((mod->num_syms && !mod->crcs) || - (mod->num_gpl_syms && !mod->gpl_crcs)) { + if (mod->num_syms && !mod->crcs) { return try_to_force_load(mod, "no versions for exported symbols"); } --=20 2.51.0.740.g6adb054d12-goog From nobody Fri Dec 19 15:34:28 2025 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45F6A31197B for ; Mon, 13 Oct 2025 15:39:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369997; cv=none; b=RoVI+YWH3kHRDeRKD4oKzcLTwQlhyeaFKjZFZHR293nbEUjy3fXPOiRoK4VP4G79MSwHqfEPReZz78K1LQymCAmWEkkDDKi76sqp36qkxLyoEIpQmBQmTAil3gsJbi99BON0A73Xcs/x6ewpIy5ATBsa2HodPY9KqeTEOEpvEkQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369997; c=relaxed/simple; bh=lFWAd47m9WYWwYOwfmcdqTMftDRqoXt8LOsJmWA7WTg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=q8jkMXdBPdivaAN3YqBwdwOtO5vzwf/BSuo3SCIUpTzsEBZ/rvek3yZkOqwPokwcNfXbQW9TVc+s+ghF7JHDlN2LHyrXzrVO2AUMDsqqeq6D5I+tvOxqBeSNHbZ3n/sY4yln4aP5QUMhhc3OXXYQDznwyZrBOa4ptnYKEQ+Rzpg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=g/vvyxhD; arc=none smtp.client-ip=209.85.208.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="g/vvyxhD" Received: by mail-ed1-f74.google.com with SMTP id 4fb4d7f45d1cf-634ad8328fdso5626191a12.0 for ; Mon, 13 Oct 2025 08:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760369994; x=1760974794; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eG/97FcPJjq5NmEgRW4PArfa7yqTL2l/aJZCar+bosQ=; b=g/vvyxhDWnZku3wjYliqv0l8G9npqfzcF2S6oS2yQXUlDgFHAm+aQIhFRdE81DobVe 82bridSCQqMFxhTArZ7ov59YaC6gs7uaBF7ZpbaHY92fGzYK+6ErQD2/MCO3/KLyxEcw tI9OAIjFSBtiRIDaKfCsHj41lE3N9ZMUJimdl/RSH+pfoP2WYZMFw41AuXhMQwF4jLyU NV+78TGIv7ZtlLhksz+nHFdnPuhVYy3BOcFLRqXBFxRGJoGV8NCGVbEwR6qK2+SUn2rn 8/XVBVSXR9wDdcKu7MDHseR6at+mn9UtJOeoCts29dXPTtcJM/9WHuOZFIUPMcKLKqHD oaVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760369994; x=1760974794; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eG/97FcPJjq5NmEgRW4PArfa7yqTL2l/aJZCar+bosQ=; b=id743haNjJiC2LsvoO2Jue/zNB01daff5eLz3b7aJvmSP7pWGK84rHKvNYvW39Pc0F Ydqh/htsbDmmkwrFVANjcf15muNNsU7NlAtFj4AbyXpOof1/1zITqhvg6yxLYdBmAYjT gjlCfJrhtYnbQbn0wJSGCtRi8oM5t2l04vWBVszLkifK3ScU3s42QEFoB2ouZEwWPPCz Fi6LfH1x335AI7FO5Wo/EzbX3YMyDd4FHsZRJJZdVyYibSVCpdGiYWPBxwm03xKBsAPc RxZgHGao4eVj1xgV1yI+HdRJ935d/8GtJ/ia6NRXoObnmgrYtj7DXvA9fVT3CF1GPA+0 oM0w== X-Forwarded-Encrypted: i=1; AJvYcCVi68nvfyAsidd/XD7AeIS0KwTB07mv4N2VnIICkj8auEvMjHeUdCcAozXRxW0kr1d+98Xw6NM1g67si+0=@vger.kernel.org X-Gm-Message-State: AOJu0YwAE4oLg/dAQHt3PoyAOlPbQtVLveLjmp1qF7vkhWUfSm8zgoEj gyw0v9DzYHLN9/6jl6jVRfbQB1FeFzuZG1oBLOaE99gBsu/HOgVdnK8OAdav0GBwP4iInW/G9fn KPp0vsRcqizddVRDJRQ== X-Google-Smtp-Source: AGHT+IHM78g7/9ceK5BgemHYhfAGssyyk28SSEXehcoYdtwkhhg6hYVEul09QjzOoJajkOTlNWCkbmyfjJw/coM= X-Received: from edbm27.prod.google.com ([2002:a50:999b:0:b0:634:9afe:3dc1]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:aa7:cd43:0:b0:636:7b44:f793 with SMTP id 4fb4d7f45d1cf-639d5c76f3amr14705335a12.36.1760369993704; Mon, 13 Oct 2025 08:39:53 -0700 (PDT) Date: Mon, 13 Oct 2025 15:39:15 +0000 In-Reply-To: <20251013153918.2206045-1-sidnayyar@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251013153918.2206045-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.740.g6adb054d12-goog Message-ID: <20251013153918.2206045-8-sidnayyar@google.com> Subject: [PATCH v2 07/10] linker: remove *_gpl sections from vmlinux and modules From: Siddharth Nayyar To: petr.pavlu@suse.com Cc: arnd@arndb.de, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, mcgrof@kernel.org, nathan@kernel.org, nicolas.schier@linux.dev, samitolvanen@google.com, sidnayyar@google.com, maennich@google.com, gprocida@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" These sections are not used anymore and can be removed from vmlinux and modules. Signed-off-by: Siddharth Nayyar Reviewed-by: Petr Pavlu --- include/asm-generic/vmlinux.lds.h | 18 ++---------------- scripts/module.lds.S | 2 -- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 310e2de56211..6490b93d23b1 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -490,34 +490,20 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPE= LLER_CLANG) \ PRINTK_INDEX \ \ - /* Kernel symbol table: Normal symbols */ \ + /* Kernel symbol table */ \ __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \ __start___ksymtab =3D .; \ KEEP(*(SORT(___ksymtab+*))) \ __stop___ksymtab =3D .; \ } \ \ - /* Kernel symbol table: GPL-only symbols */ \ - __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \ - __start___ksymtab_gpl =3D .; \ - KEEP(*(SORT(___ksymtab_gpl+*))) \ - __stop___ksymtab_gpl =3D .; \ - } \ - \ - /* Kernel symbol table: Normal symbols */ \ + /* Kernel symbol CRC table */ \ __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \ __start___kcrctab =3D .; \ KEEP(*(SORT(___kcrctab+*))) \ __stop___kcrctab =3D .; \ } \ \ - /* Kernel symbol table: GPL-only symbols */ \ - __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \ - __start___kcrctab_gpl =3D .; \ - KEEP(*(SORT(___kcrctab_gpl+*))) \ - __stop___kcrctab_gpl =3D .; \ - } \ - \ /* Kernel symbol flags table */ \ __kflagstab : AT(ADDR(__kflagstab) - LOAD_OFFSET) { \ __start___kflagstab =3D .; \ diff --git a/scripts/module.lds.S b/scripts/module.lds.S index 9a8a3b6d1569..1841a43d8771 100644 --- a/scripts/module.lds.S +++ b/scripts/module.lds.S @@ -20,9 +20,7 @@ SECTIONS { } =20 __ksymtab 0 : ALIGN(8) { *(SORT(___ksymtab+*)) } - __ksymtab_gpl 0 : ALIGN(8) { *(SORT(___ksymtab_gpl+*)) } __kcrctab 0 : ALIGN(4) { *(SORT(___kcrctab+*)) } - __kcrctab_gpl 0 : ALIGN(4) { *(SORT(___kcrctab_gpl+*)) } __kflagstab 0 : ALIGN(1) { *(SORT(___kflagstab+*)) } =20 .ctors 0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) } --=20 2.51.0.740.g6adb054d12-goog From nobody Fri Dec 19 15:34:28 2025 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7179131CA4E for ; Mon, 13 Oct 2025 15:39:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369998; cv=none; b=J+OPsi/01vy7BSJCxMhm9hlRNSHrieroc94xVdcxox/TOYSszvKR5EVSzLgwOwHW9ZhUR5bK+dC7fsbq/mML/BEaJgxRfFTgSksrHwD8Tir+d4BdgXofHjZw3d7CW/pJWOJ2cJTEdbRZCZ6RQs3jffgL2zYdyyIUOeCbExq+3OM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369998; c=relaxed/simple; bh=fZiA1VUJ/o59/ps5AdQY0hmjgLVHeNv1xGnN2udifhI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=t5cwKeXHtFoY6QN5gXrEb9LEbHPUmYLMJjseGTZE4/PxhzpCYIAzuxXRNUErQpPcZFIHZ52B1C6U7+Ixx9DDFWKIdSDZt1tzEnELM4s9gvu6rbQRzcNypMzHNF6SWwH1YF4+JJq0UhegqYZx+L8oVjzOgDOZnBqjIJb3fpTNETw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KqYlAWzX; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KqYlAWzX" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-4256fae4b46so3004077f8f.0 for ; Mon, 13 Oct 2025 08:39:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760369995; x=1760974795; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=IKbWNapgsR6VEWEFu85lrkRceG4RpO+nq/TjDXD68V4=; b=KqYlAWzX85zYfeDq7wptaCvLfbQlYdR0+LOh8IKo0pFeFf5R/HUE/+Lyb34Vy/NQvW QLo/baTG0PMvYDH7fgHioXvddXmBiRhNopJqeUEc44ARxbdqBpgiEUavY07D9aQ0gEB/ UOlCetT9NbcL9/2419sQy8tvv4oq9+xGdWg9db+tgsPxBl5cgR3TmZ41eH8cdqJ1OOk+ pW8Ix+jSB3d9wCo9pWoLOGvTBn+4A0uvdJg+zEnJUNbmdJ3UVl3PrpJVIU8zkL6X6/AP J5x2WeEPpmxEcce1s2/ebK12+3Y6tgsDWjNcNvrBohFVGY7j5tS9kBDTtgVVfLuz4S0x Gjiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760369995; x=1760974795; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IKbWNapgsR6VEWEFu85lrkRceG4RpO+nq/TjDXD68V4=; b=QPMpTozMzDKLuUiBdoiOWqB9q5QgyRGQE+LN3UU9UNB5+Vp1K/eJzRDG0d5yvXoCb+ KUOOecZber+OJFn3DxcKHl9hPoR/20GmAtWhYYItdTt2qJ5vPHhGEYOtVXKBuAkJMuij nVpfRd3UX/Y+jN4P1CPRvlnUjRBmGwDdNATMinhlun2EBySFkkWKNtMPS/Cvq8dp5UQh mZ55Sma8GuzUbZMBCPVs++8u4g65Y3TC9H77gFx4eHsNGbWq3zmIDmPwGAB2EVxq6HsX BheCiNRh6F1Qy6crs9UxmVTW+jVJON61Q/lv6Bz2v04uKpgpO0ubcWBCWdXunIjEjlHD tkXA== X-Forwarded-Encrypted: i=1; AJvYcCUQLiqTwJhAZu/DPLdfvg31Tb+IpPiquecepxDQvtURt4X+TyzV2U6viOl2ciPPh2EVjpNd62HVDNq2n/0=@vger.kernel.org X-Gm-Message-State: AOJu0YzWhoKVymcn+zqKaz2fwC7gzpSLaZ5c6TWjhc5peUakodVhVkG6 OeLW/Df64WVhfMwZDY6MR3pGZ/ITb0pVoZ+yoJBrPuNOV2TScqp4Bd+ggrzNYLiM2LuqukV/CpN c77YaVvI5FMJs+CZraw== X-Google-Smtp-Source: AGHT+IGp+ZsF3D3bWIYgeYXV3HNMy4q84TyGQUuNRX9+df1SaWGYGQu8plkyY8YMsQnmYsyopCUPAzi7vnd9SmE= X-Received: from wrbfi8.prod.google.com ([2002:a05:6000:4408:b0:405:9111:bac4]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:24ca:b0:3ea:15cd:ac3b with SMTP id ffacd0b85a97d-4266e7e15eemr11989551f8f.30.1760369994784; Mon, 13 Oct 2025 08:39:54 -0700 (PDT) Date: Mon, 13 Oct 2025 15:39:16 +0000 In-Reply-To: <20251013153918.2206045-1-sidnayyar@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251013153918.2206045-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.740.g6adb054d12-goog Message-ID: <20251013153918.2206045-9-sidnayyar@google.com> Subject: [PATCH v2 08/10] remove references to *_gpl sections in documentation From: Siddharth Nayyar To: petr.pavlu@suse.com Cc: arnd@arndb.de, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, mcgrof@kernel.org, nathan@kernel.org, nicolas.schier@linux.dev, samitolvanen@google.com, sidnayyar@google.com, maennich@google.com, gprocida@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Siddharth Nayyar Reviewed-by: Petr Pavlu --- Documentation/kbuild/modules.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/module= s.rst index d0703605bfa4..b3a26a36ee17 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -426,11 +426,12 @@ Symbols From the Kernel (vmlinux + modules) Version Information Formats --------------------------- =20 - Exported symbols have information stored in __ksymtab or __ksymtab_gpl - sections. Symbol names and namespaces are stored in __ksymtab_strings, - using a format similar to the string table used for ELF. If - CONFIG_MODVERSIONS is enabled, the CRCs corresponding to exported - symbols will be added to the __kcrctab or __kcrctab_gpl. + Exported symbols have information stored in the __ksymtab and + __kflagstab sections. Symbol names and namespaces are stored in + __ksymtab_strings section, using a format similar to the string + table used for ELF. If CONFIG_MODVERSIONS is enabled, the CRCs + corresponding to exported symbols will be added to the + __kcrctab section. =20 If CONFIG_BASIC_MODVERSIONS is enabled (default with CONFIG_MODVERSIONS), imported symbols will have their symbol name and --=20 2.51.0.740.g6adb054d12-goog From nobody Fri Dec 19 15:34:28 2025 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5169D31CA78 for ; Mon, 13 Oct 2025 15:39:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760370000; cv=none; b=T6XrxDUULFmG1yYHCAHxNONs0smqogPO/e8AXlhKq3CwBNIraklV8u67lIgbDcCN66mNuYxONVq6eIjAjtf4eZJeCmi9zmqpxgtcjCAUBJKm05cweaCPwpbBx6GRw369CXT+DgFPOFIokrrmLRXdGlbpdqWDMxlqiKBOnUKRaOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760370000; c=relaxed/simple; bh=bdfeOJ1CSPp//SYUVDBBQsYQyaNxDAAd/0lEE35bEzg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hVilBo+PaNeAGq5pLRfT4JpunmjwvGymqOEaXH129WgXdVb6D7v5z/VH346Ug6Mk1wAB8tByTfUW83Z4eUncUxMHK7WA68emJq2K+M9qFH6ToLiftLjZeW2punvXUlrGfjUanx6/x2lq0hbuUiIrJhlnOq0o7F/YWssiaFDjNLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EoGaZkvb; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EoGaZkvb" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-46e377d8c80so15889745e9.3 for ; Mon, 13 Oct 2025 08:39:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760369996; x=1760974796; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=kwQoFRjsq01KVdK43Vv6ynyDB+DHrQ33po0r+B72Arc=; b=EoGaZkvbAHoVLP/1Qqz3QEWC9Bu6buB2FzlNyVguEOY2Of1OKSUH08OO9ugDWHSdMT zThb95JjRQ8T1cZp85fi/vLMC5Kjd3xVu55ZkQsYe86hhAWauuDojqwr88z+OUHrnngp cLAdKHSOgPkmA7nSrT9tX8g51Kw0Sctqof7CaWYNcZn3vTJV+CJ/A6e3DbsFdT6C5Hvs WfzK1XR2OYdYGRSGkcMco6c898jlxJv2H7xSGxahwP/mZmfWWqJw3tOaQxg4dnJuzXR7 Qnw+/ztls/FttKZe5vqeYU8nNQgSoXKiT2N4Y+ePjMdcjDvkRtT+l+jjuufcRkODTQdU QRkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760369996; x=1760974796; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kwQoFRjsq01KVdK43Vv6ynyDB+DHrQ33po0r+B72Arc=; b=in4MTXFBw7qpnddwOewschezukaVqA7mWVwMZ5Yn0BhGz6mrB52HyMjRh02BHL+DWm 565ou8SxU0Bn+3xEagl5q1qXpXGxxDt+6miPs+pZfGL7m0NveTIg3kN4W2vV00xPxd5w wpEkIW5gPKXK7MCdLP/vQI84tw+iexSNCIQfOFkgl3OwXWBn4Kj/7cIO65JzEE1zIUr4 K9OPSTpvPcT8CyMBZ/PO7Cs3HFGPcePT4Dwn+TnTnk73uvi2CveinTl1lGHmQiX+MWoM kPgVC3a1DKasDLS3OCatQmPLvKfRnyWyE6a1ibunJqmOnxR9Z+tNT1rD2l2QrP0ZfL2H Thlg== X-Forwarded-Encrypted: i=1; AJvYcCXTT79oLNDmChjrXaPuqR33Fbufn/dv4poiVOimDYVxYUy/EFfGDCF1MxsYi6Hn58qQJzMgq5rAOQm4UW0=@vger.kernel.org X-Gm-Message-State: AOJu0YxDP31+nQeedRPL+KzUBGfaW/cGvVHZxBwLgxHCDfFSLu9WOw84 riHwfZAi76J0SSv/hZx3izGY8CbFwbZx09wSAfQbQV/60ZjdJlHJjxbdiAavQgCTyvtAOcRVwd1 t527Kr+wvkTPp70e6KA== X-Google-Smtp-Source: AGHT+IGVlYoiHkeXsTQFrvn9kgZVTgCWcB8oIqtDdxIvtExFOS98aaxHP9f4wr11J0Rsb8Np2hM9BT88Mo6nEpA= X-Received: from wman12.prod.google.com ([2002:a05:600c:6c4c:b0:46e:6740:21ac]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:8586:b0:46e:37a7:48d1 with SMTP id 5b1f17b1804b1-46fab89b7abmr122964145e9.34.1760369995668; Mon, 13 Oct 2025 08:39:55 -0700 (PDT) Date: Mon, 13 Oct 2025 15:39:17 +0000 In-Reply-To: <20251013153918.2206045-1-sidnayyar@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251013153918.2206045-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.740.g6adb054d12-goog Message-ID: <20251013153918.2206045-10-sidnayyar@google.com> Subject: [PATCH v2 09/10] modpost: add symbol import protection flag to kflagstab From: Siddharth Nayyar To: petr.pavlu@suse.com Cc: arnd@arndb.de, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, mcgrof@kernel.org, nathan@kernel.org, nicolas.schier@linux.dev, samitolvanen@google.com, sidnayyar@google.com, maennich@google.com, gprocida@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the unused exports whitelist is provided, the symbol protection bit is set for symbols not present in the unused exports whitelist. The flag will be used in the following commit to prevent unsigned modules from the using symbols other than those explicitly declared by the such modules ahead of time. Signed-off-by: Siddharth Nayyar Reviewed-by: Petr Pavlu --- include/linux/module_symbol.h | 1 + scripts/mod/modpost.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/linux/module_symbol.h b/include/linux/module_symbol.h index 574609aced99..1d0414da4c7c 100644 --- a/include/linux/module_symbol.h +++ b/include/linux/module_symbol.h @@ -5,6 +5,7 @@ /* Kernel symbol flags bitset. */ enum ksym_flags { KSYM_FLAG_GPL_ONLY =3D 1 << 0, + KSYM_FLAG_PROTECTED =3D 1 << 1, }; =20 /* This ignores the intensely annoying "mapping symbols" found in ELF file= s. */ diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 8936db84779b..8d360bab50d6 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -61,6 +61,9 @@ static bool extra_warn; bool target_is_big_endian; bool host_is_big_endian; =20 +/* Are symbols protected against being used by unsigned modules? */ +static bool default_symbol_protected_status; + /* * Cut off the warnings when there are too many. This typically occurs when * vmlinux is missing. ('make modules' without building vmlinux.) @@ -225,6 +228,7 @@ struct symbol { bool is_func; bool is_gpl_only; /* exported by EXPORT_SYMBOL_GPL */ bool used; /* there exists a user of this symbol */ + bool protected; /* this symbol cannot be used by unsigned modules */ char name[]; }; =20 @@ -246,7 +250,8 @@ static struct symbol *alloc_symbol(const char *name) =20 static uint8_t get_symbol_flags(const struct symbol *sym) { - return sym->is_gpl_only ? KSYM_FLAG_GPL_ONLY : 0; + return (sym->is_gpl_only ? KSYM_FLAG_GPL_ONLY : 0) | + (sym->protected ? KSYM_FLAG_PROTECTED : 0); } =20 /* For the hash of exported symbols */ @@ -370,6 +375,7 @@ static struct symbol *sym_add_exported(const char *name= , struct module *mod, s->namespace =3D xstrdup(namespace); list_add_tail(&s->list, &mod->exported_symbols); hash_add_symbol(s); + s->protected =3D default_symbol_protected_status; =20 return s; } @@ -1785,8 +1791,10 @@ static void handle_white_list_exports(const char *wh= ite_list) while ((name =3D strsep(&p, "\n"))) { struct symbol *sym =3D find_symbol(name); =20 - if (sym) + if (sym) { sym->used =3D true; + sym->protected =3D false; + } } =20 free(buf); @@ -2294,6 +2302,7 @@ int main(int argc, char **argv) break; case 'u': unused_exports_white_list =3D optarg; + default_symbol_protected_status =3D true; break; case 'W': extra_warn =3D true; --=20 2.51.0.740.g6adb054d12-goog From nobody Fri Dec 19 15:34:28 2025 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 343B631C595 for ; Mon, 13 Oct 2025 15:39:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760370000; cv=none; b=qktFaw3NugOfAnwLJ3NybX80JoD+2feU/qKm9sCy05ohMDKmUEe98tIcyRDaV+FSAG9ypWiyNeXt4AjVUdHwx/F9/wAEYfAvePoXaUyv0CMIzIgH9/mYxm2jrB9uqnWQFZyzAh1Tyd27xZRSiUs+is0Sn34NxOt9dCWVBD5zBcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760370000; c=relaxed/simple; bh=qWYTuEu4IG9GCT7DjS/hH5Ft/AQYcQO5Boog+C14wCc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=W9VbNlJgKMTKOK9lJbTmnw73baz1/+At/XOMHjxrBRXGnbSjo2n/jukM0UZd5WnXoqyFA/m35MQ6hs6JRlICffPyOkuqXwsTOj6urDm4E/QCucJts13wbvggLPAZjS75ndmmWbxVpO6LZjxcMXnQVtsmXdNdT5qKZVtYXT9NkKU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=wSTb07DZ; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wSTb07DZ" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-3f42b54d159so4768122f8f.2 for ; Mon, 13 Oct 2025 08:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760369996; x=1760974796; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=EWqoEOZl6L4UgifcuVH8Vvw1RztpD/4r7yVFa1CMC6A=; b=wSTb07DZc1jMbUWpnaVe7yVdz6j3xUJ1419LXaEz6dFZd5WxEEo12pnpzqy8Gcu2VE XZcCAkEBdNgt7PN5jszViZ9yhurTzR/wZkbmmSVUUMhIHXyMP7kNp4EvuCSkwUzxSnJI +woNVO2taJvhNZQWQmZyGDGqQzy/5Pvcb2e96ieSn38Ch879Un/jMx4LaFvA7Vs9Bw8E yM4XJxOUZCMGfMk6X/BZo1aurOlcCKQdP6h/HSMzHi+WU943VQUFMX5WLEoO9/T00A6g 82s7KTgl7q4Fttk5O7713NbiGLvPLNOIxGQt8qMpZtPF2bx/H0m8AiJ3fxjRVjomy/8D r/RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760369996; x=1760974796; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EWqoEOZl6L4UgifcuVH8Vvw1RztpD/4r7yVFa1CMC6A=; b=AVokfYnc7Eva7Y6DKvoKnzUdm6du6QSPojalfdRJ5T5DZL/2c74xwR/MH4PcgoUTWw EbQvGRVFXuRRDcHg25KBK+BnO1lpLySJlPGYv742EDgypFaTh9MDTwr2QZCeDb9vwR1v TdSd+SOd5GOCuKJr+UXBldz7icAFaGMVGeVNbJRjtdMeBJKqeCTKQm7p+T8md849XSoT jP0ntMv66KzJmLTRmaTcPZWvNJF6FG80mIyilqlfjW7C4uE+07t8J3f43HzWRGafA6nB 8w4x1DAlxspc4Sa3q3Q0nw9ixySgti3dkEv04l9Eyf6WEWirNBwsPl/ryj+sKDy4dc/8 DmQA== X-Forwarded-Encrypted: i=1; AJvYcCXZo0cWQPkzUs13GZYA09jqUnl8xZhF+y+Lh7ntE0fdd4tS7LQIALmc4R2WSgXwVAvdIoM3k1KN7PSNMLI=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8WULBf3pu27os8Kbn1M7S5vpFnAHXR7dOylh5Rayqf0B2r8/s J4+kuMbHDEbJgGbIbYUI9mN3Lt3wRxFzMzC0pD1qX3miiyehspjmWAdE3s78RcdYXc3hGUI8Mah XQvVxX4+WMEwnWVCjkA== X-Google-Smtp-Source: AGHT+IHLek4r1lwro3GQIO4ppkzexXFiEHQSVL/Za4DDoRCAzgIf53fcpusHRbOINss/Tpngpku8rgJ4Go3IiS4= X-Received: from wrpk16.prod.google.com ([2002:adf:f5d0:0:b0:3fc:7d28:6438]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:4901:b0:426:d51c:4d71 with SMTP id ffacd0b85a97d-426d51c4e7emr6015254f8f.8.1760369996504; Mon, 13 Oct 2025 08:39:56 -0700 (PDT) Date: Mon, 13 Oct 2025 15:39:18 +0000 In-Reply-To: <20251013153918.2206045-1-sidnayyar@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251013153918.2206045-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.740.g6adb054d12-goog Message-ID: <20251013153918.2206045-11-sidnayyar@google.com> Subject: [PATCH v2 10/10] module loader: enforce symbol import protection From: Siddharth Nayyar To: petr.pavlu@suse.com Cc: arnd@arndb.de, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, mcgrof@kernel.org, nathan@kernel.org, nicolas.schier@linux.dev, samitolvanen@google.com, sidnayyar@google.com, maennich@google.com, gprocida@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The module loader will reject unsigned modules from loading if such a module attempts to import a symbol which has the import protection bit set in the kflagstab entry for the symbol. Signed-off-by: Siddharth Nayyar Reviewed-by: Petr Pavlu --- kernel/module/internal.h | 1 + kernel/module/main.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/kernel/module/internal.h b/kernel/module/internal.h index 061161cc79d9..98faaf8900aa 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -108,6 +108,7 @@ struct find_symbol_arg { const u32 *crc; const struct kernel_symbol *sym; enum mod_license license; + bool is_protected; }; =20 /* modules using other modules */ diff --git a/kernel/module/main.c b/kernel/module/main.c index f5f9872dc070..c27df62a68f5 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -380,6 +380,7 @@ static bool find_exported_symbol_in_section(const struc= t symsearch *syms, fsa->crc =3D symversion(syms->crcs, sym - syms->start); fsa->sym =3D sym; fsa->license =3D (sym_flags & KSYM_FLAG_GPL_ONLY) ? GPL_ONLY : NOT_GPL_ON= LY; + fsa->is_protected =3D sym_flags & KSYM_FLAG_PROTECTED; =20 return true; } @@ -1267,6 +1268,13 @@ static const struct kernel_symbol *resolve_symbol(st= ruct module *mod, goto getname; } =20 + if (fsa.is_protected && !mod->sig_ok) { + pr_warn("%s: Cannot use protected symbol %s\n", + mod->name, name); + fsa.sym =3D ERR_PTR(-EACCES); + goto getname; + } + err =3D ref_module(mod, fsa.owner); if (err) { fsa.sym =3D ERR_PTR(err); @@ -1550,7 +1558,7 @@ static int simplify_symbols(struct module *mod, const= struct load_info *info) break; =20 ret =3D PTR_ERR(ksym) ?: -ENOENT; - pr_warn("%s: Unknown symbol %s (err %d)\n", + pr_warn("%s: Unresolved symbol %s (err %d)\n", mod->name, name, ret); break; =20 --=20 2.51.0.740.g6adb054d12-goog