From nobody Tue Mar 26 08:48:13 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 4V3k3L1x4gz5F8hf; Tue, 26 Mar 2024 08:48:14 +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 4V3k3L01MSz4D41; Tue, 26 Mar 2024 08:48:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711442894; 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=DD7vmOaKz2/Ya9kqd/AxHxBU9ieKGoXJWRvqF6795dE=; b=I+S1gc4Rl3tdS4Z1Xle9VGKn8BhPeFlJAEfMugT1mte6K/7McugRTmL87159P2ROYsfpOH /6m674kTdspqkWtPxwQFdGo7Tcz0XtwE9ji+2C006YeTRZvKor232ocfjuHAX+mB7zb71O 6ZEtwR0+nNNMGfvFSZm/fCuVs+ghzbL58Sf/RAquYZ1UnvNKVp2IlOj8cOgfhwtutjdhRB K74qdr8kutcPT2QpwJDi+/wRwoatiHuvBsL0JQgCnYPYCJvLMCiuXuoRLMEedBE7i0dynM rQKCKq3GWZ0V6mzla3L4zSUe6dpoyQ0XWQkwfC+051WaFF8+n4LN06QejBbtAA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1711442894; a=rsa-sha256; cv=none; b=pJrRaIRUeJLVOiVSOqugRpwlh7cG3xcymoFWS4n4r09gGjEEFnP1bRn3TbgI8fOW2dLDn0 V5aCwIc9GW2ZO7AMuuaTnTDrYeEdXgw8KBOLaQT8TKBoNRgCfLIxOEgC/iEx/cHKdaQ0LM oZ2RjOEN1GURgMDOMZnFl7S3KnfCFOURpr3lf9PMJdAYn4uTD2yzVH7DU0BoPbCWwFkHA1 h5ftz0hztDtskDPdxWSZ37uJTXtuvP7QtJdNOyQXhac7ibFmhiBbnSrkPvZqY0IqT0cxMj QJEbl6SiEEjTnSdihRzXpf1hH3JuxFW5DkMIUHg8a8NpHnM+XkJIj18R/iqOLQ== 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=1711442894; 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=DD7vmOaKz2/Ya9kqd/AxHxBU9ieKGoXJWRvqF6795dE=; b=j6kh5KHa6y5jb2XmutGygwi2vZqJm7YoqmAJqXzr/jU3KGZs9iX4dswhKrB+wbFYf8HWly 41S0nMNCEUtV0688AR+Z7yODbtbJGgaJN/V8eWQ982q4EoRKZ3ujz7Bji0A/uLbynP4xbX vRG2Bqy9v2Brmt44DW2r/SUlQk2h0R2Ilb8dofgVk15ofr2Vf/E8YSW7MSjMJ/OKl/gYdZ ofoybJrQleiyPhW9UrQnbGPd1FAwPBFZ9XE0dVX0BlLtRueRB6cQSlCiBd9j7sOEV0Q8NT H6EvpfIBlaORaMOU5ki2tgYjMqpMYRdnKXvxfbRoEyF03dTX6lkmhLtp9x0y1w== 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 4V3k3K6WV8ztVH; Tue, 26 Mar 2024 08:48:13 +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 42Q8mDDt091361; Tue, 26 Mar 2024 08:48:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42Q8mD3M091358; Tue, 26 Mar 2024 08:48:13 GMT (envelope-from git) Date: Tue, 26 Mar 2024 08:48:13 GMT Message-Id: <202403260848.42Q8mD3M091358@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Zhenlei Huang Subject: git: 39450eba8e6c - main - 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/main X-Git-Reftype: branch X-Git-Commit: 39450eba8e6cd5b83def724481127b58ecc1fcc1 Auto-Submitted: auto-generated The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=39450eba8e6cd5b83def724481127b58ecc1fcc1 commit 39450eba8e6cd5b83def724481127b58ecc1fcc1 Author: Zhenlei Huang AuthorDate: 2024-03-26 08:47:02 +0000 Commit: Zhenlei Huang CommitDate: 2024-03-26 08:47:02 +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 --- 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 325dffbfedee..9d3cb9b7bd63 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -1862,6 +1862,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