From nobody Mon Jul 31 12:26:17 2023 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 4RDyCz590zz4q5FP; Mon, 31 Jul 2023 12:26:19 +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 4RDyCH1Gkcz3y14; Mon, 31 Jul 2023 12:26:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690806379; 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=PnMuEWabpDFbKhZDwqfzrv7MV7Bpd4+4DE87qr3nLZQ=; b=i2c1+cNkh6axaDDE2MKYVbNHSLvK1WQ/HrvTaHthEa3A4xACcHXSfprl8h0f6+mieJ7Sia adZcw0nXxt0ne3iXdP5sf7nknWn7PBQeRHxF2caicK5/S4GVZcVMqETWzcSsFAGkMLxWlF 0DKTCbxSVfAAab38wPWqY8/fqJFLC7ihYkz802wgc60uWuk3no4hWDS2DQ/TMgdm04MS54 Z/IPZyxJh76nyDRlzfi1eRq5j9NNwIloFy1BlCBNoL2XuSxZja8ZveF8CBLjAW1Cbj+vJL CmTRTpissNEGbuNE+gAuRhylmkWWDWfQUaL4GWjbo1ESvAVAZ5bKPI/Djfbrpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690806379; 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=PnMuEWabpDFbKhZDwqfzrv7MV7Bpd4+4DE87qr3nLZQ=; b=wpVRoLUMRCFkhxbb/fNThq77rXpE1ZYuINMVeIZjQKlbuhopZ/XTsgSLkrSOZzDmEpqZWz 3IJu2WSEyNTBrGmYlkAtlggyRTrdU0bhrjHKZvFMOrL+HugVsTcKOf4ina1W/K+KKr34bN q44YORRC4S8Ely6C16SqSR4RZzRV3MppTrrscXYhl3bkRGngPiZOXzSKhV8kAc3qiRWvOC VAgtHF5dqAgz/BnbPOhS8luqjuL8LK2C1aw2F7McxipWSkiMJ3u6t6HJxTrHeHI7vE3sR6 b6lHr4buPd4sMSlI0kawoDaL+ihpJ8sFpStkOcKKqOmpAX61DStg06E26Xq/Hg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690806379; a=rsa-sha256; cv=none; b=HXIhHu+ocfHWG4BJPrwEKIcEq/INGoz6EVVvHL9ilUmGelam0P3SdWt3X4psKWbma5z1iL gFx50GX0cqYt+XCBT3MJdsYbmWGVdctT9wRunyeHOh6JlvjApj+u2zrTBw7FLSZ9RMKjdo tozWE3zRy9yjQtUr6LP1WB6gJ9Jj1SY/Qo2s0jnz578f7WwCweKwgGLm/hbiebejhl8Is9 GzQrAQwqy/whJ9nAQTp4CsYj1UUlBWnPjZGnVA+UvSd/BeVYLdzgmDx9zX8RNFwDkVME25 ek4v0YdcHMQJgPQKD03naHNMlg3L+Otj/8Tsw+WBapy5M3GdsRK6nOQXonCv2g== 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 4RDyCF6TWyzwHk; Mon, 31 Jul 2023 12:26:17 +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 36VCQHjD043795; Mon, 31 Jul 2023 12:26:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36VCQHxC043794; Mon, 31 Jul 2023 12:26:17 GMT (envelope-from git) Date: Mon, 31 Jul 2023 12:26:17 GMT Message-Id: <202307311226.36VCQHxC043794@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: eff0170df142 - stable/13 - ena: Fix driver unload crash 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: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: eff0170df142f973d684e2180beca744a1a88e8c Auto-Submitted: auto-generated The branch stable/13 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=eff0170df142f973d684e2180beca744a1a88e8c commit eff0170df142f973d684e2180beca744a1a88e8c Author: Arthur Kiyanovski AuthorDate: 2023-05-21 12:31:54 +0000 Commit: Marcin Wojtas CommitDate: 2023-07-31 12:23:42 +0000 ena: Fix driver unload crash When ena_detach is called, we first call ether_ifdetach(), which destroys internal addresses of ifp. One such address is ifp->if_addr->ifa_addr. Then during ena_destroy_device(), if_link_state_change() is called, eventually trying to access ifp->if_addr->ifa_addr->sa_family. This causes an access to garbage memory and crashes the kernel. Ticket [1] was opened to the FreeBSD community to add null check in the code of if_link_state_change(). A fix was submitted in commit [2], however it was noted that it is our driver's responsibilty to not call if_link_state_change() after calling ether_ifdetach(). This commit makes sure if_link_state_change() is not called after ether_ifdetach(). [1]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270813 [2]: https://reviews.freebsd.org/D39614 Fixes: 32f63fa7f975 ("Split ENA reset routine into restore and destroy stages") MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit c59a5fbd8a2ef68ed0842cbb1df4450edd654129) --- sys/dev/ena/ena.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index a974a20638b9..d787bb5f9493 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -3292,7 +3292,8 @@ ena_destroy_device(struct ena_adapter *adapter, bool graceful) if (!ENA_FLAG_ISSET(ENA_FLAG_DEVICE_RUNNING, adapter)) return; - if_link_state_change(ifp, LINK_STATE_DOWN); + if (!graceful) + if_link_state_change(ifp, LINK_STATE_DOWN); ENA_TIMER_DRAIN(adapter);