From nobody Tue Apr 09 04:14:02 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 4VDCJV6p9dz5GY78; Tue, 9 Apr 2024 04:14:02 +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 4VDCJV6HZ1z41Jq; Tue, 9 Apr 2024 04:14:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712636042; 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=hQurx+N9/l4J2ju8BG6HQWMCbKD83zZk9Qa7W8wlczs=; b=aUPNxqJf1I366TlwPGzGX4LrPBdsUNIajLC9obUpy2AELF8+s4TSEpWf8p9SdvoWB9/xnK dX5scykjiNQ8H1sqbUftgiKrGbRiEFQ4V5LDHYHAOLW2uBANq96pqfE4o28K954ptdCu5L xqgi0XVGkzsRkgwGVX/VCyuHJ5OKCzybK3ZcjzHMxiKk4VzyyDwXc0bPL/rY9hER22QFBu KyeVQiG29yOBd+feqYithmGRECc6n00kzfZIydFk9NdEl+geuyo7oOr+Phmt7JtESuPjHt yjV79HJkEJu8bo1JcV1ozuo+IAWUdiBBYmKELhDVYpOXHAJmuWVsi5eH51MnSg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712636042; a=rsa-sha256; cv=none; b=wHLalVys0Jjo3c6MZfONcXlyWxPMu4eTe39gdgikFzmutrvcktjdCbD42TJ/AuVXH4wXKc yIdfspmMBQ+yTHzvScK3hbrrbMKXrj5CzRqZ2CajsGQngz6S+ZuuLO8kPwPnauKJbnJ4ve qYV/4AnkDxXF7hwcGH2c9QS+XqgCJdznIztPxFcXp6L3uq3whc0/WcCWDwsktvIpw7exlC NWsSNsJusURpyY1FEFd+VU4QkibAatbH1bbIvllo4UllvuSn4Ppnu6fRKwgHEmK9Mp73P9 g3FhnVJWwLNM22ANddkYk9PSUK0ln+srxEAfKsGRH0SlxyzkMpDcXns0xftd1Q== 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=1712636042; 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=hQurx+N9/l4J2ju8BG6HQWMCbKD83zZk9Qa7W8wlczs=; b=EMc1tLKsX5TgI1OSvmX7u+yYdd+WWuRZbumQCvjbQ9h1yEaubZHrAFA8qkNuZ492ES0XH4 bBTfbmNb/7ECobe+lpBrGBtnPkaavXsHvDDrxka8iw+6rly2dskbUbLZiYFMSpo4jkTamH D1pKd7lOTsdglNIAhjE9EPqcgTLQpyOVFM8wboMbLHolypgpUqtxwXWoN4mNhP1dDg8yfw HNMTNu5KVJQg+sepmgx8XO0ihMJmhZMVRURVFaxz8Le3W9wESDctbsB2G2LFdbgCbUaxSH WRsoHwXkACz6LF4lPVfwrGda8oCyV8AJXwhgB1ZtMqsSI71iJUL0rxWAXBD99g== 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 4VDCJV5tz5zg7Z; Tue, 9 Apr 2024 04:14:02 +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 4394E24N039501; Tue, 9 Apr 2024 04:14:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4394E2Mw039498; Tue, 9 Apr 2024 04:14:02 GMT (envelope-from git) Date: Tue, 9 Apr 2024 04:14:02 GMT Message-Id: <202404090414.4394E2Mw039498@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: a2f57656620d - stable/13 - kern linker: Do not unload a module if it has dependants 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/13 X-Git-Reftype: branch X-Git-Commit: a2f57656620d2ffbb8b79789de34a6fc657286d5 Auto-Submitted: auto-generated The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=a2f57656620d2ffbb8b79789de34a6fc657286d5 commit a2f57656620d2ffbb8b79789de34a6fc657286d5 Author: Zhenlei Huang AuthorDate: 2024-03-26 03:55:45 +0000 Commit: Zhenlei Huang CommitDate: 2024-04-09 04:13:08 +0000 kern linker: Do not unload a module if it has dependants Despite the name, linker_file_unload() will drop a reference and return success when the module file has dependants, i.e. it has more than one reference. When user request to unload such modules then the kernel should reject unambiguously and immediately. PR: 274986 Reviewed by: dfr, dab, jhb MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D42527 (cherry picked from commit f43ff3e15c8b4b161ce09c8ab008abc4222db26b) (cherry picked from commit f1994d1eb215a2b7cb644329797dc623ec883120) --- sys/kern/kern_linker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index bc2f477997e0..8f83fc4c474f 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -1207,6 +1207,8 @@ kern_kldunload(struct thread *td, int fileid, int flags) printf("kldunload: attempt to unload file that was" " loaded by the kernel\n"); error = EBUSY; + } else if (lf->refs > 1) { + error = EBUSY; } else { lf->userrefs--; error = linker_file_unload(lf, flags);