From nobody Tue Apr 09 04:11:16 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VDCFK5nKRz5GXgx; Tue, 9 Apr 2024 04:11:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VDCFK0K3Lz40YM; Tue, 9 Apr 2024 04:11:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712635877; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vk8ja3fYgqpmVLnVaOeorTUHcGvwb606df1TwKLPMUg=; b=ViVUMU5LKIoR0TnnFNDV5/jllO/Bvacj7tlRdOojt9uze4hkDdR/GMDW6gZevGgCl1gQ7p uNcySZdU6J6d/moekdpW8At3UNyhKubKyaGDDcyqyJ5ighDEywqbKNPyhkjY77hfuDWk9e A8BxEvR5N3+NQP0Avf8rdxav/rKX8D36skkXp8TQsvwSpXYmddpxeMpQuWC5VepDbHSMnF 9BX4e/oftjpePeed9mmjj9anVuTwraVkYy6O+0mxXSbfk7TB+vVzR2kkvxq6jfGmElI9aJ qiRPB+iYrlX54TrAH/ysmGrlE3l2uSJ4SCzxyrZNAzHzlRdFMTLLT7TKeP9JIw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712635877; a=rsa-sha256; cv=none; b=AD/imKtoKVxlBTae4JPKH5LGaZjnAG7lcRdWyH+2XM+pzxtc+bK/2joRH2E/vBkUrGhdr1 84n4Rs9kXbMkR3PWkLEl5QcKglxSmOPsNL+zI14l/KeghWuf5Oce/ifEEUa9M++kd86oZp FJOtZi0CvydcbWJenFfilJiguTV9bMJXchZWdJUrcQgmWUSxlrCyjm97Dm3Y1HFyjy/Aqs iXYsx64por6/wtjbv8PrPHKOxhVyru5zMcXJ6YN4Tw0JRB8P78WZVyV1V9gc0PG0yBF78D mYZHhcKZgrX3c7wzDd9g6upZYwZz7oeRcO6edhJQP6mzSop4MoMu5xNnKsIPAQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712635877; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vk8ja3fYgqpmVLnVaOeorTUHcGvwb606df1TwKLPMUg=; b=jzsLqpnxbEJUW4o99qcwmrlyhUS5I7GGa9osZRw7mzAwiFnlVoO02KnTpYClcDpwhfyYhU T0s8fWBkKvlXM9w728A9L1U5NtMpOnkw1j/aDvI+k0FyHPOJF8WkjUmA0+RSnEjOANGG5m PLLdS4MOXmAakjd4aFTGYC7x9Cr7OKafEIGVCke5QAzYPdwqULSUzjZ7HpQtbXxfcmYdcv dXnVnZHhMV39Hu8VP+sohKWjJNT1r6gueVzNYkYZsGd63awagvcszz6B/7qJqgByLs/AS/ 8/Gi7UZq9w5B73habZN+WhZwewa0XB0pXGUFqJEKeKX79F1r1eL55oHxkyvnYQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VDCFJ72QVzfck; Tue, 9 Apr 2024 04:11:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4394BGfn033283; Tue, 9 Apr 2024 04:11:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4394BGTU033280; Tue, 9 Apr 2024 04:11:16 GMT (envelope-from git) Date: Tue, 9 Apr 2024 04:11:16 GMT Message-Id: <202404090411.4394BGTU033280@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: 7da45efb0921 - stable/14 - kern linker: Do not touch userrefs of the kernel file List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 7da45efb0921e9937353992226f34b25ae197545 Auto-Submitted: auto-generated The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=7da45efb0921e9937353992226f34b25ae197545 commit 7da45efb0921e9937353992226f34b25ae197545 Author: Zhenlei Huang AuthorDate: 2024-03-26 08:47:02 +0000 Commit: Zhenlei Huang CommitDate: 2024-04-09 04:10:25 +0000 kern linker: Do not touch userrefs of the kernel file A nonzero `userrefs` of a linker file indicates that the file, either loaded from kldload(2) or preloaded, can be unloaded via kldunload(2). As for the kernel file, it can be unloaded by the loader but should not be after initialization. This change fixes regression from d9ce8a41eac9 which incidentally increases `userrefs` of the kernel file. Reviewed by: dfr, dab, jhb Fixes: d9ce8a41eac9 kern_linker: Handle module-loading failures in preloaded .ko files MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D42530 (cherry picked from commit 39450eba8e6cd5b83def724481127b58ecc1fcc1) --- sys/kern/kern_linker.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index 69c746fe376d..c9e31437c7c6 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -1786,6 +1786,9 @@ linker_preload_finish(void *arg) sx_xlock(&kld_sx); TAILQ_FOREACH_SAFE(lf, &linker_files, link, nlf) { + if (lf == linker_kernel_file) + continue; + /* * If all of the modules in this file failed to load, unload * the file and return an error of ENOEXEC. (Parity with