From nobody Fri Oct 3 14:29:29 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 8C98F30FF21 for ; Fri, 29 Aug 2025 10:54:32 +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=1756464874; cv=none; b=DZB9xav5BsEgbwAvSsMQO6SVzS2fV0FcsNWLBNht5sAdIpQ76qgYEoUdVggSm+qtuGwZqGYQVp1eHYIbScLYFNqXgCRQ2F0pWNiBVGFhJmmanOFsTKbKJMidc9W28SMbpYLxRH0fx2yz0PbzniwPzD39VHUmurGWRQPUXn3EN2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756464874; c=relaxed/simple; bh=o00iDb5UYdIfCyM60Ae3j8Plc64XIahNETckMuCAzEc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Evh9RgnDFWH/m8iVNeqT6Mlzk7hXIDvpKq35K11SfsTVFjIwU9GDxUFhz1GRMxzIRo804xQCLXXyO9n011L2yxDDGt0PrlDXqanc/zTLlCpJEJ76evDu00QErLEf35xHDxAjAVOKSV7oR6gNomjJPBQLcXq4Z63KtfKoXg3pV80= 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=HlZ28ScE; 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="HlZ28ScE" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-afe81959e5cso191995566b.1 for ; Fri, 29 Aug 2025 03:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756464871; x=1757069671; 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=jzTerVh/nCBDl27Owgk/DKlFx8Mn2cN/NIkEjSaweuQ=; b=HlZ28ScEhlTJqsqRcihNvC+4ZcY6FG7G31PA5SpYEqdHwPtySmu/4g2Y5cFAbrpoBJ 6dTm1S2tUnqTLjlEEUOLh/cIqXfpKtWXIsdBGxz11dJOtPQ0XDf43DLkIYAoQD3vnvDJ WVmrJG5FTo51FDWy57DIqvUocUGNKbk/oB8Csn+elsCNJjxXpwTVsjsfqmzdwYJFAjNZ CSvjjmSXEnKePujyZbTqgD2vcrqA1dp0g0VigdPzpIrkl2DQfmiXJhdPMZyoPfWtisL4 smMKGg3bjvP1rppjnOhd0RDxetBcnO4JMNdVRY1Uip6jMJaD+/7z6xq5m/Mb+zbyCGLh FIKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756464871; x=1757069671; 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=jzTerVh/nCBDl27Owgk/DKlFx8Mn2cN/NIkEjSaweuQ=; b=tQSrcvcmg+mcuy7dfSmVFOa1o3kSS+vkymUgf6Y0A7RP2ImH3vjo4yJZ+VpbeF9C70 zvI2GWbjQ+oLOSgis76n+H4Gjq0jw17EJRB1uqkuTI+NLa6kCZN153OwuhPJv/hZkXyn l2+VTqZnYkeYfg71FrhIJN+Zl2xAGbN5I5iO7b3T48VvQ7SjGVW8mUKmntOGshZ4vb8d S9GlzRaTiIE9vTK4lXRi3liZ9GJRmbFyZRHpJdmbkczmu4v1aNBLwfAC0FCcAk7tHJjM Q5kADPf53EOhdJNNhXtJvMMJstpMMGwmeQ4ClgYwUjv9IpuXJpFlmeKyyIIJgPkSSsSR atBg== X-Forwarded-Encrypted: i=1; AJvYcCV3e75V24U4giyp87i+R7EzM2THSneRDUx2xVpLeGQcu/6qmqvUHS4V4jnQYgeNojRe86aJaswzcTMOPO0=@vger.kernel.org X-Gm-Message-State: AOJu0YyijGzZVHgHcELzoTPtcZv0lQkpZ4icztujhRfg2LeiYAiy91Hb Gt8SuLjzFKmplKk7G6eyBNE9L6zhNJDhLzhc9ovy1lxYwcpvF5SX+u4W1EGZdB8R8rlEUbeluwB 861Wl5cO7PwoqAsSmug== X-Google-Smtp-Source: AGHT+IFTtQCdjV7sfltO3GmOq7hzjj4vCpIsNY9YQpuWWop+sd3pviuI1QGFkyDeMWAuOScrxjcHr9lkftkQ/q0= X-Received: from ejcrx18.prod.google.com ([2002:a17:906:8e12:b0:afe:944f:fea5]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:968c:b0:afd:d9e4:51e7 with SMTP id a640c23a62f3a-afe296bceabmr2540214466b.63.1756464870885; Fri, 29 Aug 2025 03:54:30 -0700 (PDT) Date: Fri, 29 Aug 2025 10:54:09 +0000 In-Reply-To: <20250829105418.3053274-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: <20250829105418.3053274-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog Message-ID: <20250829105418.3053274-2-sidnayyar@google.com> Subject: [PATCH 01/10] define kernel symbol flags From: Siddharth Nayyar To: Nathan Chancellor , Luis Chamberlain , Sami Tolvanen Cc: Nicolas Schier , Petr Pavlu , Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Siddharth Nayyar 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 --- 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.338.gd7d06c2dae-goog From nobody Fri Oct 3 14:29:29 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 6AD323101D4 for ; Fri, 29 Aug 2025 10:54:33 +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=1756464875; cv=none; b=Z3iPrGntfAvDPiP9bYIhm/0aTSc4rVyQCKbnCYBsrtcSuPV5jLttlaDNRiohRDwMZ8qdTKCWRve0u1rShzdSf4Qz4ikPh3cfywYjQ18yLEOZSSzkJux40u2T/LSjFZA2jyqBGj0+pi7lelfLzi8zKZjvTWuE89HmZEOxCLWsHpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756464875; c=relaxed/simple; bh=gRovmQuH2UtNnwZvSmPpczaZbZGecSis3mfrjkbqTIk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mZQ/wzpT0fshrEnsncBshUPhSXCDJZ0mM4LO47Z9W/eGBnv4wCRwJHAVDRemZ0x0fEn68drdNB/6Mt9E+dCXPw8f5e3Pi/48RlT25DOOrD+/UBwRl0P12YLZWcUeJtPvyKNVlNDLlo95jq/MghWaGjsqDmJ2cmTSV5EJ3XzAjZI= 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=egosu7hm; 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="egosu7hm" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-3ce059e3d42so1038457f8f.2 for ; Fri, 29 Aug 2025 03:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756464872; x=1757069672; 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=7yM7j7Qx57ly8fS8GyHAmsOp7RH5RV9aoVcQOsSKjdc=; b=egosu7hmyxvPwJ8yxFHf9s6LTXlunyphHUgjwkl/WqvuFVy+ZAy172Q/h1LwYJuUfQ +IEy2/iCLXDpRczFsa3iOgUX2bjpgP3k9ZYUbwL9IuXDwjV5NFdRcJRutKYAoci4UmR8 A3nEvXzuYc3/bQ+5KI7Q2X+yLstsfypqB6TFjryM3EV4DWow7y/pAaohOzzOYZOiX9oA 448Ds4bMsuyXLhDxnqp3YDHRu+ZgLcAAGXvCz+v6oPF+3dtEgCrANDZ6bNnXaihoMmVG 5QIxQ8wi36kWStSGdAYx7TVy2ZzwRpxVKk3MN8ouJLhOYVU4kPM0i1C+8ty39NqF/QpD ywaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756464872; x=1757069672; 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=7yM7j7Qx57ly8fS8GyHAmsOp7RH5RV9aoVcQOsSKjdc=; b=Vi8adTualE+EI0alN524MzQ67PXJ4D6H3gCTLPa2+5N88lSKyH5HyOsvzsc7EV15Ro 4aMRfARAC4KAvomZBjdcnzYMFDOSyBhSg1C/Hj1+Qa1WYxMnRqhK7hj9PsOiHatIqWoR cVEsJV5XL1LEgpfJgZdzFrAse9P0RyOypPOhW80+/guAQZBFTGkuZCCp2qFT9fZxYzje Y4FlJ1ntlQgRIIw3ift78J0egT1eMKEwZUYC8NWb5GyombMwGW1w0uFOP+nJ0hP2qRQG lIL8rsleB791BXkp4wS3Fs64pyqNzJMTTd8L2raSZ/V7161r8hHuVJ1WzIRK2QtgM5KA gZPg== X-Forwarded-Encrypted: i=1; AJvYcCXjOMZDXBBr2GFGx1MhzaJZtCmoP3NbdHU3jXTDy8d09k8cwEgPab6AaRYJ6MT+1RTc6PMbe5Z139CKcVo=@vger.kernel.org X-Gm-Message-State: AOJu0YxtH8ymLg7VN8ISFfnE48XKXhbtJIvLKyy2rrDy0CZiLMj/6FIi DBG+FTKs3YoSygrWjVgqAbqSFOl82jpth9wQQJFDbOmhfXtE6sp4LPIhh2voeer6GV08M0YNkCh g/gmsDLn5IIWKi9xk6A== X-Google-Smtp-Source: AGHT+IHwqLzW8AsFBaut7VXJETAMa4EmJuYMwngEAyyui2jcQSConTi2ueB/MSNCerNr9v8EE1wUOpLQRN2mL6k= X-Received: from wmsp29.prod.google.com ([2002:a05:600c:1d9d:b0:458:bea8:57ef]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2406:b0:3d0:affe:ed6f with SMTP id ffacd0b85a97d-3d0affef412mr1214056f8f.57.1756464871870; Fri, 29 Aug 2025 03:54:31 -0700 (PDT) Date: Fri, 29 Aug 2025 10:54:10 +0000 In-Reply-To: <20250829105418.3053274-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: <20250829105418.3053274-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog Message-ID: <20250829105418.3053274-3-sidnayyar@google.com> Subject: [PATCH 02/10] linker: add kflagstab section to vmlinux and modules From: Siddharth Nayyar To: Nathan Chancellor , Luis Chamberlain , Sami Tolvanen Cc: Nicolas Schier , Petr Pavlu , Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Siddharth Nayyar 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 --- 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.338.gd7d06c2dae-goog From nobody Fri Oct 3 14:29:29 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 927CC310658 for ; Fri, 29 Aug 2025 10:54:34 +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=1756464876; cv=none; b=FCkEY8yGpuMlzy3cUf2sTpbXAAFFrLDdreRGFU4kYUeVwH0BejrA2GJLWs3TrhL2uYqEJpC9jwzUtl1sTJmpN5za3qpi5f9tSzhYQ67Xb22R5NDKKh9bJ4pJKxUvJc0ZDLEB7XDfWtR+LhFwNHbX1iF802tcXqf4UAnb0l2fMXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756464876; c=relaxed/simple; bh=HAvzKytnoUkJmif830vACBYuc4i5mIbg0Ge6+UpzfJU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=G4IiRC83aLVwtFhmaEA7k//p+yAD1ORg7xkgQRQlQONzr3pOq8cKAvVDsAFzTPjki03qNEqqAsc85x1bL7HetiEoNi48akWe8fpn7ZPfo3YWDMZjkEPIbfDY3f6bhEFo7ddz3XeerFyKDL9BfqfYhOjxp0XbtOvlslE8/VwRuU4= 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=NNcZnBe/; 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="NNcZnBe/" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-3cca50781ddso899944f8f.2 for ; Fri, 29 Aug 2025 03:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756464873; x=1757069673; 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=IzWK5ktBAXMKEip0pMwXuQ+LMz45Er37x59lYOQDEQc=; b=NNcZnBe/m8THClDDboyth+1POb+d4nTnlTAYnz/UCSNQT8VoTRSdNghLRH9vCMEyX7 ujrYO8V4HlwthPPiCPoKTbU3aRuyilet+FtT/qn6W9sW6lV6DfpZlbLeVtiAx0mymGIM yq820heCzdiThkwz3EbrlFF+s1Hkh0Ro8+utYuhYYjXPyeFu1fE4GgfoBv1hVn+kkb3G GKHKPjwAc/11gD7rofTCC2OWADXg3hobs7RbJfllxA+enEezkal2/6fVQNyqyhb7nuLu aQ5D9OFihNR67hQDqvsbffLsHIzge+CHSGxU4Qz+0g7VLYdEt1nedzmPJ5DEDafROUWn 79IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756464873; x=1757069673; 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=IzWK5ktBAXMKEip0pMwXuQ+LMz45Er37x59lYOQDEQc=; b=FjmbGr1+INffPImD6KlVkxkqUV3mewS69ylb2a7pV8WVPq5atg+159yaB0meZQJz5s r3RJJTJoR6PANOTuOa2wjXgIvmxneuHs24V9KaPCOEVg0nC8KZBp2fR4q2frHPwwn9Ci 5aNl1o2AkHw3joCwMOQzGby62RBsaBcM2qDtO2lYadrLg4jJ+vJHqnSTy35cP0PnUSSS RpGGwWQdh/9os20s6umh6UYK8UD1f7DrM8jrCYO6oq51CR3BW1jH3CgCpVKo47iMNvF2 TxYZ9QjilHDHDc9uQysh6P+1gXLlxC6BCxN2GyhJOIyfwC9y+OEiGa9xDGbbAwjT99Ke vf5A== X-Forwarded-Encrypted: i=1; AJvYcCUVJdHDj5iauu2KB4oXIXKtiAWEPN2VyqGP01WA93Ex68rvSGuf8S7NB6ZS9fy+rE54+Uv22mNuCTgNUa4=@vger.kernel.org X-Gm-Message-State: AOJu0YzSocAgny5fj6WZZHcQ3L20UsN3j0CECGf93lveyWr9cQ/GyqCc Jn+HGV1JhEMhfcTPQAFyRep9q/NwlZ3JC2/IEaYgJ3BVFhfeeBtSukJLsfXeYpCOVhA65uaot3Y gsz6YbQAfPOpV7tItsw== X-Google-Smtp-Source: AGHT+IGnly/av0KHtbsEt0YxJt41btV3bsiIzWd21FF8oQs3ujT3eSzg5vuOKzY8Bw/eXCf7KCDZaZBKghFBcok= X-Received: from wmbdw13.prod.google.com ([2002:a05:600c:638d:b0:45b:8079:102c]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:21c8:b0:3c9:39f3:7af9 with SMTP id ffacd0b85a97d-3c939f37eadmr7626880f8f.9.1756464872992; Fri, 29 Aug 2025 03:54:32 -0700 (PDT) Date: Fri, 29 Aug 2025 10:54:11 +0000 In-Reply-To: <20250829105418.3053274-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: <20250829105418.3053274-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog Message-ID: <20250829105418.3053274-4-sidnayyar@google.com> Subject: [PATCH 03/10] modpost: create entries for kflagstab From: Siddharth Nayyar To: Nathan Chancellor , Luis Chamberlain , Sami Tolvanen Cc: Nicolas Schier , Petr Pavlu , Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Siddharth Nayyar Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Siddharth Nayyar --- 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.338.gd7d06c2dae-goog From nobody Fri Oct 3 14:29:29 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 464B831159A for ; Fri, 29 Aug 2025 10:54:35 +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=1756464877; cv=none; b=fE5VSEr6++jbc56u9+8qN5sWFJZf68ACjQ8xYeurg46fZKvaTQZ5L5NXrvVFeYn6LvhVmGOSH97D8aI/owu2EYMYM+PCuuqS59hUPdJdIbS8u83e+x5KAACRlHAINIl1m5zL9m0aB41uX19sJhVTPkdO2QbLonH2nXchPo3Rl84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756464877; c=relaxed/simple; bh=XdwddMlnNDe/bejk9AlmOKSmzkod84XNORyHGHdp5tQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UZCsRz8IpjDIMGZ9ky0Xqjtltk+94yVVBO1oag7OVJfWeFW5GCOYHLdqDM3uCTmhY0w440ssoPPv0tkIp50LziuuukQuhvo4fd1LdsAkYgI5qLQ82eZ1VJVUKdJyvXFA61oo1SMriVfD5CKJqzTeV7W9+hti/IPiwaIh1DRFHhU= 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=FVQZPi02; 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="FVQZPi02" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-45a1b0511b3so11380825e9.1 for ; Fri, 29 Aug 2025 03:54:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756464874; x=1757069674; 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=BZkdXrnu4rlNqr6nvqy7s2PHRCwIZIrYjOI0uDxkuo0=; b=FVQZPi02OrLY+h9w6d9mz/U2t/rLyG+ylXdwMosWOMbdcZ+D8FuWI9/iOm+E+BfE7s iddbFq8vl0Dd6aWZp6PWGhlltRGX8NCZFYRF0SQmvwYYCdljU851Lq82h8UwsIasU7H9 Xcyk3OJ1YlFJz++Gvev1cW9vzt52jsBv479Uki5WORzgUn0l2m6t3KkQAY3FcTrE9+qz w6JALXp8GB+LYZtcY+PwDp8c0jdVr70w5Saz33Jwde5yc34NZKNnFS6H5JEc9g3acN8c rNPGftRRi+fdCNF7w8KW6Mb2tC5qSxOZNIP3mLMcyHcUwWxbMlL9pw4pISElY5Wkddt3 aa9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756464874; x=1757069674; 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=BZkdXrnu4rlNqr6nvqy7s2PHRCwIZIrYjOI0uDxkuo0=; b=SUpJnm8PRTiEqMXRiVvmwbf9nan3TeTQR35m828gyDyJc1k6bGhHsT71rLz1DiTOgz q4pGFz0cG3v1+qOdJyey9WtcbfxAsoOBXG6IC7AknvGeMbjCHez1JNUQZasnFeLnprm6 9XM4+UBhE9vrL/YhFs4gN5zMR+sVVDxaJtoBMTTRZg0jxlD8NQuoTpkx+gxvF0Oc1GIw 1yR620eMQH9jYgt17GsBnQKU3laUrp7CKvBWRsYPGVXmI/rrfUGaCztd4r11xD5i3nmr A5EI19rpxVy+mX5jqLg9o5oIEif/loSqhr/M1KF8kcmnZzRey1rtGyyMRh5128rJIpjh Hz+A== X-Forwarded-Encrypted: i=1; AJvYcCVmVvJobrji0pTJCBqR5MA2/QGWd5LiqzKpl5PITbvPhc2tB6TQ29roV9YOPAjQ1ruWp+BDHL68XncVVr0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4+vwBlK8YjVGtHR4j20kMeWAq7vo3R5CcbUUBjirbwpQBejgd u4Qh0GM+WOy3TIFSWhDpbTZfb+s1BsTktXUiyQpoopbGcQenWvwHX5mjIR4p16GQWJvCSL2LgvN xEvFizsMSY3nObxaZCw== X-Google-Smtp-Source: AGHT+IETLQhhj0TWH9cTHkmUejWaasllcxIG4MgQGiEsNA2+oYnEukedB/VKaaNhilCldwAcOXfj5vhFRG0qg14= X-Received: from wmbee21.prod.google.com ([2002:a05:600c:6415:b0:459:dd4e:4446]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:19d4:b0:45b:6365:794e with SMTP id 5b1f17b1804b1-45b70ee5db1mr92752335e9.24.1756464873773; Fri, 29 Aug 2025 03:54:33 -0700 (PDT) Date: Fri, 29 Aug 2025 10:54:12 +0000 In-Reply-To: <20250829105418.3053274-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: <20250829105418.3053274-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog Message-ID: <20250829105418.3053274-5-sidnayyar@google.com> Subject: [PATCH 04/10] module loader: use kflagstab instead of *_gpl sections From: Siddharth Nayyar To: Nathan Chancellor , Luis Chamberlain , Sami Tolvanen Cc: Nicolas Schier , Petr Pavlu , Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Siddharth Nayyar 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 --- include/linux/module.h | 1 + kernel/module/internal.h | 1 + kernel/module/main.c | 47 ++++++++++++++++++++-------------------- 3 files changed, 25 insertions(+), 24 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..400d59a7f44b 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", --=20 2.51.0.338.gd7d06c2dae-goog From nobody Fri Oct 3 14:29:29 2025 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.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 2BD0A311C30 for ; Fri, 29 Aug 2025 10:54:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756464880; cv=none; b=djY5ljo4ae/P4LOzo6tiC2pkc3cepqnzxyOcmquZyTyWFdYJDGwUPmg6jXOGe/fABYD0H88JebcBy2sVZqDPCUzJ33qxa+C+qaA1xH8rd0DzAv7urmrRWJlL1TJ5IeM5xj0EQLjrlkeQfpMWMwmzANAGA2PpIW+FGoAaWepw5No= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756464880; c=relaxed/simple; bh=zCQKK9m+KKuyKhTLmtwoTILfUCZPd/hNRBlyLkdveFA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=SDYnmAmKeBvl0H7Jd7mxd5lDE01IfP1OLmEGUdT1cQcqf3xs75ZaDCMu6blVJuoh/YTaZu//9mDyfmGDr/BeUZEnamu2lWMH/LAhKA6G+J6+fcrX0F47AmDnCY1uOEbmrBno97iL/9O2AQDOPrjd6My72Pr3uJvwMUYfMF8gs5k= 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=m5n0O6Wt; arc=none smtp.client-ip=209.85.128.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="m5n0O6Wt" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-45a1b0b14daso11897825e9.2 for ; Fri, 29 Aug 2025 03:54:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756464874; x=1757069674; 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=qmPxRzAkCLsUXg26vuwkDnrhDTwJQL7buKLtRL62U1U=; b=m5n0O6WtgFU8lJRL6ltcrvQ0ZkaBnzp3kjOgjRI++TxlWGrLj+bMkP6InbIKodn5Oj L1dBqsJeoZP4O4x8kKxCOQ6wgLZtMI1QGK17oNzfZZYCTX1o3dbSWdx48a2xvaPIfNbB 67DmQXtbgmld3OW2HKadXGFphXa67YCGeHEG5YaKV4Sfmpkhx7/K4ldv9AHv7EABronG cCS5IkeQBkyMqMsXpBc/y3o60gAAsZk+eBEHMui9rGsktuy/Su1nDfO/kI8rr6CxgRvZ yiS/8oLboSdwaZID1zollV9VktPaknCE69J5N0oxBfUgBRQ4MQtzt5YYOvnkUUXYL46+ HzPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756464874; x=1757069674; 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=qmPxRzAkCLsUXg26vuwkDnrhDTwJQL7buKLtRL62U1U=; b=R6cdbKgPnCFlCAGVS7VHeeO75fZtjHI2pCqNxYYH66hBST2nuh/3kkkAm1YIf0XvUE byWqu7+eXW4S0ClfD3+YA0Ass0nkLtyRDBeKQwS4Odyw2bOSQN4dDIqTE2y+XExJO31/ V83xNONHEHl2JgJafkMYmCe8+KoHPWhAmMkIEQZHXxOYWkuhk8P+qzuzYKkPLbPq8/np NjcPclQ20FOXUqSbIObC85y+MYrMLrVTnmjJ0TtxF0apiG5P2QUDrKRdisxcTtXJ1QQs iScDWPAQBMIRLGKNhZW+LaG6ZBL6KE82dYjtY9Vh5oxnXydhqXmwTV+CKXPa9xbJdeY4 /7qw== X-Forwarded-Encrypted: i=1; AJvYcCXWgb/aEUsHHFDSPrhH1uvs1MJo/kl+TKBQX2ZwqLzu2XOEbt7Lo4T4a742OuIwUp1YHEpi8u6eZvzO31w=@vger.kernel.org X-Gm-Message-State: AOJu0YwuJmfgiEmILKm+mliB7JFAusdppToETaP6sjIkiOPGx4uEd18+ R2FkQHHB8BBKEkcojevN1Vs80g3lbYyKSzv1LSt9MAU4E6+qr/faJ30zRnoCtIKXQFbuvMWv2HY 9hff4sC4bU+tkTvocVg== X-Google-Smtp-Source: AGHT+IElRmJCyExdp5sqN3Bq7s04CX81XnHqEMpfJfcSboz7fZGDW9C7V4YwGMPKStkjm9pWTX9m+C+ad9Vw1dk= X-Received: from wmbji5.prod.google.com ([2002:a05:600c:a345:b0:459:7c15:15b9]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:34c8:b0:45b:8067:d8bf with SMTP id 5b1f17b1804b1-45b8067db82mr16690415e9.14.1756464874501; Fri, 29 Aug 2025 03:54:34 -0700 (PDT) Date: Fri, 29 Aug 2025 10:54:13 +0000 In-Reply-To: <20250829105418.3053274-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: <20250829105418.3053274-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog Message-ID: <20250829105418.3053274-6-sidnayyar@google.com> Subject: [PATCH 05/10] modpost: put all exported symbols in ksymtab section From: Siddharth Nayyar To: Nathan Chancellor , Luis Chamberlain , Sami Tolvanen Cc: Nicolas Schier , Petr Pavlu , Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Siddharth Nayyar 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 --- 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.338.gd7d06c2dae-goog From nobody Fri Oct 3 14:29:29 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 DA58D313524 for ; Fri, 29 Aug 2025 10:54:36 +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=1756464881; cv=none; b=qfmu7VWPV4eCdHm6nOSkpcJy1Qm2YxFqRecsBI575LQ4zdXMYDAT+2uvKFoIfOCBaTA6q46N6zar06/vjXoWKo3B2PUn7KS1Uxeu9/x4T7Ewg8EST8d432OuZU0aVfonMvRr6eGP3k0uoSMMjZ7nolEUkEOdDNa6FWAWhVcK1vM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756464881; c=relaxed/simple; bh=yF9Nwmba/jevaBt9hbUSzr8VO0GmzyMKV6WaC+bYVkE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QLu/P+Ri2kzrcaTaCuPO06jnf4tRjOrzxa1ezXZI3i29yHVmHoS8ShImyviUXU29eWknyNI7KmUDiEe8jAC2p/ye6fMKD/IF4MP7NBDAzAjI0pgoF/HCr6+lShWeoqVTCm8xS1SrMnE/hGvpJgr5C4p30Zhfa9BHigLKLPzFFLk= 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=1HL9SLyC; 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="1HL9SLyC" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-3cef6debe96so587186f8f.1 for ; Fri, 29 Aug 2025 03:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756464875; x=1757069675; 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=tl5xVMQDO9rOC+YVNnG9Us77dRWtm4Hbzqq49mGE7X4=; b=1HL9SLyCWtP72z5Frih2DAXSDv2wkd6m/xBbjdqovr6f6NfpVtl2xqyE6rRatrG1Bd wiStsWJ3B6Bd47iz2uAG/W59jWupTtjCRwznH3inMY27Gq9mlAOHVb70vEuppvhkuH6E gK9+4H9/iwOjBzd9HwBzB8+7EkeGBKl0Cj4BkjsaeB1mztPa0ABMAxs28TqF+DXqYb/N z07eHi2BG7ffHGahF7MGkskNPlLlUrGdsaR4yjUkDvkeWR7stT9zrK0vSVC+TW/TnbQN psrQCvQJlxl935z0oidoXB8InHVwOCuixlUU5+YZBrgUuUO4X17Usa2BfShPASXTduQD LFXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756464875; x=1757069675; 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=tl5xVMQDO9rOC+YVNnG9Us77dRWtm4Hbzqq49mGE7X4=; b=iuGB5/VK+fzE2v7r5lWytuX394JlDszyfVnV8iE7mEthKRn0Lates7E7BMJe0brhyl L5E2fwS+bzCAoO+CpJDLKxCidcGYQcTmL/RaxDzeQr5vdhOSfQnHM9odGferODZWdn9V jskwnd6Zm98wqzkHEHI4MRORqsYABx7+SoRE7VKi5DXO7bvxkky/NPwvfs/USSy1ym92 pfe/l3Hk/Z7TP+6IgMcgjX9ku6xDzhU7oJYWVgKCekUE2edPKk6TezVUUOr5Av9ZR7vu icdzinuL+OHdfSJSngp9L7VE95srgBlYZQleZ5urdEK3pgZD62LLRj5V9uK8BBFqAPZB D3lg== X-Forwarded-Encrypted: i=1; AJvYcCV68xrP+jXL5i0yyaQHEs9nZR+hFHuu89kjsqoSN+b62mdENY8Ddn+lZtBsgyaWtpWdg9BGK5gusE+pQ44=@vger.kernel.org X-Gm-Message-State: AOJu0YwMAqhAlmq78dEnFUIIlu5KEZBWWdNdIikSqa8axS53J2567exf SR4iHIQF6PjwmPdlj6nL1MBPrXrnFu+dVLnGvIHqU2vhcVwEXehslfiiLUL8bbyHeNBQx5WRScu MjOgPjVbX2yDReqv9Ug== X-Google-Smtp-Source: AGHT+IHBrOSPoi0y2RsxzWW1F4le7Bf1Bk/4RMIS0LXXWN2TETItYHW5HWXVVsxZ+L4PXPSHZLojUsL4tRay638= X-Received: from wmpz22.prod.google.com ([2002:a05:600c:a16:b0:45b:520a:6656]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2582:b0:3cf:a44b:26fd with SMTP id ffacd0b85a97d-3cfa44b2b45mr1213005f8f.8.1756464875293; Fri, 29 Aug 2025 03:54:35 -0700 (PDT) Date: Fri, 29 Aug 2025 10:54:14 +0000 In-Reply-To: <20250829105418.3053274-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: <20250829105418.3053274-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog Message-ID: <20250829105418.3053274-7-sidnayyar@google.com> Subject: [PATCH 06/10] module loader: remove references of *_gpl sections From: Siddharth Nayyar To: Nathan Chancellor , Luis Chamberlain , Sami Tolvanen Cc: Nicolas Schier , Petr Pavlu , Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Siddharth Nayyar 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 --- include/linux/module.h | 3 --- kernel/module/internal.h | 3 --- kernel/module/main.c | 40 ++++++++++++---------------------------- 3 files changed, 12 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 400d59a7f44b..4437c2a451ea 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,10 +2590,6 @@ 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 #ifdef CONFIG_CONSTRUCTORS @@ -2812,8 +2797,7 @@ static int move_module(struct module *mod, struct loa= d_info *info) static int check_export_symbol_versions(struct module *mod) { #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.338.gd7d06c2dae-goog From nobody Fri Oct 3 14:29:29 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 C5E423112A9 for ; Fri, 29 Aug 2025 10:54:37 +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=1756464880; cv=none; b=qabLQ4SaDd3KKpvFeM5c87p0/q3iT9e7Cxg28Jf+0Zldk+DpSpVK7Gu5rmZ0sYxn4hAXoM/7ghEzE94KiHQ9nMOJj6Gdp2WOgKzpsd9weS3Qi91iFDcsDrdmeLNIipSxl69dCB59MNjdu5dc4nQTpz1Bs5TmqQp8+cdSXUnV0SA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756464880; c=relaxed/simple; bh=imJbMT1QRWT0N70p1sPsm04UPKbsXzV1SUOttMAC/bw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EDtFPUTzeeNk4vqPctBhTIoyJidB6ZDVaLjuBJBP2wkWpJ9IBdh2/7et2agTVE378XC7Wv8ORgFurlIU4ZkqGCuUTNFpYsjzapZe0QG3y3y6j2arGCO1S4dB265QYnSQ/31AjF2rG6p4TGONqsCkQV3d5xmveP9as8Ju4LPfMkI= 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=YeOPd/bn; 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="YeOPd/bn" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-3cef6debe96so587198f8f.1 for ; Fri, 29 Aug 2025 03:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756464876; x=1757069676; 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=gRmzACq1z8KPxODlF7nAhbs9Rjd/H78CaV52MZqNfYI=; b=YeOPd/bnNG3aYhywq63bredqrXVjP+5A/WcoxKBikFfc8Ac/efHccCGdRPueDSpW4Z i/TWNhOeX0BKD/7X11X/IE1UZgQTSEH0/i75vRL2/m2NIKNFeWEoj3KHa/okPjxqkekU UKTIkIlN3WUZigGrhzu5byrMC3hqsDoUHahb+Gbo/WiitzNWqYFMG+XLqZ0eJhImro0u kc+iAovY+A/gE6sZROJ9gGnV71pC7Ek8W8l3ELYGUdztByeziJtkfBQhHzkjQmifShnT DUC2ulBHxd58TGHpDi6f/AXwG152tNnlTOfhSQ1+Ii8LwKXHoqqxrAUQx3X9pKpzLCU3 CGBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756464876; x=1757069676; 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=gRmzACq1z8KPxODlF7nAhbs9Rjd/H78CaV52MZqNfYI=; b=eZGTIY3+m8pgZH9P+pFkfkJRBvrugUPkGpT5qgc/JuOsDiXmkt+V5RlaY3y+mBVORD LVGW0JWuwd/vl3c5Y/cMUeDuwztKrN1WyGYVjgDEQksexwrz/DheNnY19CEkTYtT/xok KTdgwGlqDb91UP8VVr7Yh6Io3+yxzHyS0UukwvfTVd/taxIADH6qyKx2m8jz/3JR6Y6C mn86MpKBVh9ajBVQfUKtEPYpcbs8qjMXYFdYumIkmI3A/+8Xpyas359VBsrGTWOCCgNP 4PXwHed+5DSo0mx8N6GG6RvMJK+vFQbf0WHbjJbVdFDClH61WHmTvf8K3Pz8oYCmnwFw nWWQ== X-Forwarded-Encrypted: i=1; AJvYcCX/+PS/K4nc6BkRT9LdVrLSyrE3vHeJKp7LPm3sJkyGQ4P6XMhg2j1FctQ6ggHqGOKnEg7oBadFqfACMSs=@vger.kernel.org X-Gm-Message-State: AOJu0YziTC3DHnPl4CTg0cfjm1T6J8FNIhNO/StsdWNhUsUJiAJ3Goc8 YmZBJuQPcKNCCxQ03nrH/M+S5xD5jBsnlZTlGNQiKTyd+/juwQTaJzlfL8FxibrEKDC8S9VbLsv qoqlwGF9M4StcKNsf4w== X-Google-Smtp-Source: AGHT+IE/FPwm3swQP/F9rqEn9qUM4c1z0MoJ8Gfln+SOie1DHcd6K8k4m5uj+Rt2dtpNsRpFAo5lHoh24WYIjy4= X-Received: from wrbfu1.prod.google.com ([2002:a05:6000:25e1:b0:3ce:f7b7:be8d]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2087:b0:3c7:84b4:e76 with SMTP id ffacd0b85a97d-3c784b41ab7mr17512777f8f.25.1756464876207; Fri, 29 Aug 2025 03:54:36 -0700 (PDT) Date: Fri, 29 Aug 2025 10:54:15 +0000 In-Reply-To: <20250829105418.3053274-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: <20250829105418.3053274-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog Message-ID: <20250829105418.3053274-8-sidnayyar@google.com> Subject: [PATCH 07/10] linker: remove *_gpl sections from vmlinux and modules From: Siddharth Nayyar To: Nathan Chancellor , Luis Chamberlain , Sami Tolvanen Cc: Nicolas Schier , Petr Pavlu , Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Siddharth Nayyar 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 --- 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.338.gd7d06c2dae-goog From nobody Fri Oct 3 14:29:29 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 02EB23148CD for ; Fri, 29 Aug 2025 10:54:38 +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=1756464881; cv=none; b=syJqDjEufa4CNiBOtbWNrY3xPT8d3UtlcCuVgDQ2hbd3Z4ju9vbnoV+o2LWODJjzh7CmQ1yam0MWZRLiVcwWQ7eKR1/tX5vPnFEXTAr/YoZGeSR8j0MHTM7ICV0kC6I2d+gWM5WbPu6ozbBW1bjQJ9o6ABD59Qr1EGC8WhLrq+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756464881; c=relaxed/simple; bh=so0KS5+HKtS7bLgo8wlIBPBrMrd/uZF6z+PZRF+H0bI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=FrjfBbelFg7ptoI5O4TL5JaCxA2I4RgeLhycDas/Cr2CWeeklmlc8vbfIdmwM2rQvYL1Xi8LrFk4F8ejWT4ODn5nK/YoGcDHrfpaxGtFHuKhs0pI3oqm8F34nyztFKW1geePDLmnYAUJ/2+IpTu4hutc2iOVSgevYB+Uag3oyfI= 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=h94eX1K5; 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="h94eX1K5" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-3cf12498799so446585f8f.2 for ; Fri, 29 Aug 2025 03:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756464877; x=1757069677; 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=Q2RLysX4FvFaZxrrpQCtMS5piDnkGHi5CdyrEUjW23Q=; b=h94eX1K5Wxx/ICOyOMU2fJj16skwRe0a9i0pccb0ZMRC/3GLURFA0Aal8HOHLNX2k7 H6YJ478Y3YEpC86P9BvjP4C6l+EPWlc5q6gPOVKdGeB8SNZ9MQUVkuMCTwOjEX0RLPop 3ilypXLnkPuLWkvGkTnssu99nIiFCY1db86yiqoDE3YdcZGdHV4QzBgbsGU/itBis6sg I4+JwUwXjCS7dOhQRpZOAxwX1u1HSLWCi7QI7msNV6oIckQlVZGjToKUCAOIVNMQkXGf mKNje/UtkF5PvsO3sn2a6PF66VjnLsC9nF8mrlXeC3BzG028wQ03HtSjlwHJaDYWruKP TxHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756464877; x=1757069677; 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=Q2RLysX4FvFaZxrrpQCtMS5piDnkGHi5CdyrEUjW23Q=; b=ChHa8Pg6VL52jWxLEYKPD7kbMTdKAea7r8eUkXNRYcLwlr7LHTVBcXkY3FnG43Ggsa blT4QcDPeshnN+vrLvKXDlZnWXQ2jm1l4AZLkSBv2weJhrR6I3cwZcHo6q2k8yqznJ9j LU3p90l8CheM4dC2dnBngkeJfCF/v6xvTd1eseURtwCDYo85uhrlyQKnUN8TzYafVh10 wM9HMYhbXhCEAcPeoVxJ+l48o6QnAvc5jhZ3muUfO2c+XtZ9LUzpfl5jAqcgYM/+zxk5 q8EK0lUgUcUmphLiz0NVhqX4Iy/SMq/fqMliSiNqwmNkqiGWKNO43GOv0i5G/J0unrbl S4ww== X-Forwarded-Encrypted: i=1; AJvYcCXrR2mzMvQG3q4WM/xwSyQa+ib4BXzq9rH7rakLR5eU5jgOBiqRC9ukPrFyICrFryxsYYtQ4oM/RUGq1KA=@vger.kernel.org X-Gm-Message-State: AOJu0Yxwe2V+K6iwXGMgcvOZU+fhtxGOCwllWdySNc69o12fX1HesTEp Wt+gJ1bSPC0Cm2AU8iDstPH4dM45niuEblw0l0zRosRTLCxPvkHZE3pvXSQ/pTK12tAE7ug1stm puDfkNCfz+U+5sRoHzA== X-Google-Smtp-Source: AGHT+IGn0Rpy1dY1XrZvELEcqgT8iGR3jz5ujSyOBLj7FBCWbv3AUGiqUNArS0IwRoFyThmIfPNLn57QEPEFlW0= X-Received: from wrbm25.prod.google.com ([2002:adf:a3d9:0:b0:3b7:76ea:26cd]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a5d:5887:0:b0:3b7:88f5:eaae with SMTP id ffacd0b85a97d-3c5dc542ac7mr20449959f8f.39.1756464877398; Fri, 29 Aug 2025 03:54:37 -0700 (PDT) Date: Fri, 29 Aug 2025 10:54:16 +0000 In-Reply-To: <20250829105418.3053274-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: <20250829105418.3053274-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog Message-ID: <20250829105418.3053274-9-sidnayyar@google.com> Subject: [PATCH 08/10] remove references to *_gpl sections in documentation From: Siddharth Nayyar To: Nathan Chancellor , Luis Chamberlain , Sami Tolvanen Cc: Nicolas Schier , Petr Pavlu , Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Siddharth Nayyar Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Siddharth Nayyar --- Documentation/kbuild/modules.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/module= s.rst index d0703605bfa4..f2022fa2342f 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -426,11 +426,11 @@ 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, + Exported symbols have information stored in the __ksymtab section. + 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 or __kcrctab_gpl. + 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.338.gd7d06c2dae-goog From nobody Fri Oct 3 14:29:29 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 6084F310636 for ; Fri, 29 Aug 2025 10:54:40 +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=1756464882; cv=none; b=jEwGKdM+MOhWRaxpX0f0MudkC1qQwgA3m06FQhJWaJN8h/12XUVD6fFIOmsdM/6aGiMY30/uUs6+rn3ciG/u8JmBAZdFdYLBeqfSGQyThng4nmDcP+2LBtCXYiX2D8l87ekHUO7XYroAnrly212HjknzCFCg9cSHabgzX60mIcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756464882; c=relaxed/simple; bh=F31B1S8lHw87bvdOmxvFQVJauzkbFRHPz4qUM68sjcY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=HG6aRfAc53v4gBYJe4r6zaEAWgRZCeow3KyterneCN1FQ1TBybDC8boqBzNSSDmODIZ3hjsVV6JttZakKkYZmLpxVikGA0xFHeIg7W6Y6q6GLb9f03I9qxujPOfh4VHiveXPplAkiKGQ84yiW+wqtDjBeFdc1zhio0L8UBMpMZ8= 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=cGSIPRlm; 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="cGSIPRlm" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-3c85ac51732so792127f8f.2 for ; Fri, 29 Aug 2025 03:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756464878; x=1757069678; 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=kFTnM3F0cCHrWnaJ2kM4zCxpKLKVf/l5ppuLW/5eUHs=; b=cGSIPRlmktkUNTjZ/Hb8zPD9Z70NI1Y1IeFkMKxT1I/+vQZXpHTvVDep1+6fJwJZ94 3hFfZoOyBH0+0aoisQ6CbKxg3aKESEQ7fiKmgoXSCXXizkA7MIJCXp5O7K7m33ib7kzI PMIrIPtA7JzqbSl/hVHUFhq9pHOttltTROaxkBJAK1br+8VoP0JWglFrhXOomkYe4flM 8/A6XbemSr7s1MZnVHUT4p0pVrRCxtTHx4ZEg+rEb68w/awtxynslrfoCkFHz0bU1O7k G2MNE87S3lX4zW8PSn0sVvE+YnLl5DunH8iqrFl/gFcCmctkuQt8kWx4uEKah8uzP7u9 aC0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756464879; x=1757069679; 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=kFTnM3F0cCHrWnaJ2kM4zCxpKLKVf/l5ppuLW/5eUHs=; b=mN2+oCmQz0Qo5SLSNg3K7i+C5PZ/tl0sMGef/gF0Y4cvczAFxidXBsw1NmzJmnQLLA oNv7Z75xjG9dzlUgv894J6GfoC+wY/GvB2RHIqcm8ISbWpQvs0eZhTtLYvJ+l4FwnsEY 2+9p49FyUHKuOY6MewCGqUxYltIsWthHTQ6QAl5QoZ+I4t0OeBNuVoDsktbTfpz0jwvG p5NYpg7w1RI1vqJYyYNUt8LIv/nexSS3YZDN+W4bTX0gCen9jOyOPmV9sdOUSwcY/4bA Agikw1no26cbS8WgYkaMMmGNb0I7G5LaaeDUVCsYGo3sYizie1AICgVvmTPpH3UOPnVw xefg== X-Forwarded-Encrypted: i=1; AJvYcCWGg7fBNnbmqpwGsLeZA2Zz2RNIdoUDu0XtdTtHqxiUn+TqAvdveF6JSuaH1zUVsOXr2kLPmvlxj6wRNB0=@vger.kernel.org X-Gm-Message-State: AOJu0YxvPQQrZS2qKPs3269u69htX+gi8LnwGwBuzxSUH4yJkmmWY9kl nVOsEibQvxuvMykovEkABk3NOwq3h/PVv2MW9b2IkTebb6VpQZhSEv2yncF2sTzJylrz7lkx6bI Gw70q7nH3vuKCt+1Xyw== X-Google-Smtp-Source: AGHT+IGhXlg73AG74XQ1K/78bczfgGZ6cx/K2NS3Xdv76qWZPKey7zRbs4h7QieTBU1hVrcYOEW0Rwi8beEOsYs= X-Received: from wmbfp6.prod.google.com ([2002:a05:600c:6986:b0:45b:803d:733]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:188d:b0:3ca:c607:ad8a with SMTP id ffacd0b85a97d-3cac607b234mr11307773f8f.57.1756464878576; Fri, 29 Aug 2025 03:54:38 -0700 (PDT) Date: Fri, 29 Aug 2025 10:54:17 +0000 In-Reply-To: <20250829105418.3053274-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: <20250829105418.3053274-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog Message-ID: <20250829105418.3053274-10-sidnayyar@google.com> Subject: [PATCH 09/10] modpost: add symbol import protection flag to kflagstab From: Siddharth Nayyar To: Nathan Chancellor , Luis Chamberlain , Sami Tolvanen Cc: Nicolas Schier , Petr Pavlu , Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Siddharth Nayyar 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 --- include/linux/module_symbol.h | 3 ++- scripts/mod/modpost.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/linux/module_symbol.h b/include/linux/module_symbol.h index 574609aced99..96fe3f4d7424 100644 --- a/include/linux/module_symbol.h +++ b/include/linux/module_symbol.h @@ -3,8 +3,9 @@ #define _LINUX_MODULE_SYMBOL_H =20 /* Kernel symbol flags bitset. */ -enum ksym_flags { +enum symbol_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.338.gd7d06c2dae-goog From nobody Fri Oct 3 14:29:29 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 3DE0D310630 for ; Fri, 29 Aug 2025 10:54:41 +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=1756464883; cv=none; b=rmnjXhM5e3/0za3XKTeNvjr7/ymkUypzRxzEby/BHGbIE2cOIEw0vqimZrxkFKBApb0T8zM1l8VpvgGR5wQUXA4ynhJ7IAMlz0X7IUx70movwSgn28YxBGMxJynvalRvmspciBIXhL+U0Wh9RtiMZnJs0i3xj1A9QQr+c0pTY3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756464883; c=relaxed/simple; bh=dffa0L6234ztRx9C96gKJmKJajvyCWjO/vN19K5vk8I=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OJPWmafjfiAryiPjGFA/ludTYCF3TvX6/FOHLkN/4urrrVXoebAg5161pb8IOD9pNdeYn00LjDKaMQlk/auud1yhI+lKpnDSktMh4xGZF9w7LsbgysyML+KjijhgHMyQY/o7lInBPh7Qw8xxXjeOD1iCUWitRYzMAkF4TuZcyPY= 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=RowSZijb; 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="RowSZijb" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-3c79f0a57ddso1174371f8f.1 for ; Fri, 29 Aug 2025 03:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1756464879; x=1757069679; 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=enXXJwtnX6u3ZFaViBZUrEuTl1Z1GtEQPAAtWrQl1uo=; b=RowSZijbnosPDZitROCFUrCrCmw9+GNPVwsIzaloRPXtrpSy9qj94pOwfGirV9HQtW 6zQepS4zggglD0kzFsQPakFq2ilqXGg0SkPiOVHHNepAPH7fQZtpjSlGuRqjvr8Qex0e FRXZJb+eXk43dTSm2c6rSD46JBTu/4BMJecCH3cylRoY4mUD2yXk8kP4qFaK+iOj+iY+ Ookoj+oQFxeSCvgVfLbL1ApZRr73o4AmXGl/3cjVM3GIXcBKqbSJ/6o/ioeX1H/fJ4E9 /iJccqhkw/h0OzL1yp5bsS4BOsTVoJ+Ml/HuQmZDZmArPRIQi2N3g/LTkUUwtqoPs5qp 3zsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756464879; x=1757069679; 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=enXXJwtnX6u3ZFaViBZUrEuTl1Z1GtEQPAAtWrQl1uo=; b=XWga1mikwSBKTDIkVn9ASiTlC1Limbl4bNPbiNL6b/1T/PeHfGkXnEHJ2rBDwfPI1Z ryRzIiUwKPMYmCDpPXEyZmaHCVdBV/wgSSzPEvgd6oHXoQv0cwg3YvCFk31FyXn2UVrK bgUuwm5PuemQuDNaeB2ynt41u9o3WmxadrmCVIbsFTMzPhxrXWEUYQBgdrcMHUg24KOU OJ2OfDVDX0GwdsI54wkOGKmPqLxr0cuMscNFcMf5WVKvR5FeFL1cF+WghFHJVWzdKA9K 1GooA8zXBUmV38sfK3KtpiUu4JqQSUlEhLldofJTeKz2eQ8sTPmXpqywy1/fjYtC7Z1V k+/A== X-Forwarded-Encrypted: i=1; AJvYcCVbh8Nw/vsal3Q5IxdzTYjF6sWMBGI+BDPWc2ji3ZAHJ27+8opP7EGjWwVrke7lUHGF/pw02oQHjaDM7mI=@vger.kernel.org X-Gm-Message-State: AOJu0YyNtrbWHjNrfay5KobL88pk7nqxs7K0rElhbqf+2dBEEMhD6lH8 N/BDQhKsB03mEKLBSI+U+2vPU127qpW6h12cMqZj+3WOK1mf5P9LlGiobix2eBhYt0MP4R8u89Q kkapRUHxAZHvqNHaDAw== X-Google-Smtp-Source: AGHT+IGg/yFiglPyxsXk2HLgEh4ox4wWOVB+V0V2/cy4dlrL4d8IE17mWIFRoJoeOCGIJ/ix3IDhjY7+D14g08c= X-Received: from wmbjg19.prod.google.com ([2002:a05:600c:a013:b0:459:de2a:4d58]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:40c9:b0:3c9:52db:9f64 with SMTP id ffacd0b85a97d-3c952dba323mr13516384f8f.22.1756464879493; Fri, 29 Aug 2025 03:54:39 -0700 (PDT) Date: Fri, 29 Aug 2025 10:54:18 +0000 In-Reply-To: <20250829105418.3053274-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: <20250829105418.3053274-1-sidnayyar@google.com> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog Message-ID: <20250829105418.3053274-11-sidnayyar@google.com> Subject: [PATCH 10/10] module loader: enforce symbol import protection From: Siddharth Nayyar To: Nathan Chancellor , Luis Chamberlain , Sami Tolvanen Cc: Nicolas Schier , Petr Pavlu , Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Siddharth Nayyar 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 --- kernel/module/internal.h | 1 + kernel/module/main.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) 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 4437c2a451ea..ece074a6ba7b 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; } @@ -1273,6 +1274,11 @@ static const struct kernel_symbol *resolve_symbol(st= ruct module *mod, goto getname; } =20 + if (fsa.is_protected && !mod->sig_ok) { + fsa.sym =3D ERR_PTR(-EACCES); + goto getname; + } + getname: /* We must make copy under the lock if we failed to get ref. */ strscpy(ownername, module_name(fsa.owner), MODULE_NAME_LEN); @@ -1550,8 +1556,12 @@ static int simplify_symbols(struct module *mod, cons= t struct load_info *info) break; =20 ret =3D PTR_ERR(ksym) ?: -ENOENT; - pr_warn("%s: Unknown symbol %s (err %d)\n", - mod->name, name, ret); + if (ret =3D=3D -EACCES) + pr_warn("%s: Protected symbol %s (err %d)\n", + mod->name, name, ret); + else + pr_warn("%s: Unknown symbol %s (err %d)\n", + mod->name, name, ret); break; =20 default: --=20 2.51.0.338.gd7d06c2dae-goog