From nobody Tue Jun 21 09:34:07 2022 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 D44F18773FB; Tue, 21 Jun 2022 09:34:07 +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 4LS1YW5YSLz3FlM; Tue, 21 Jun 2022 09:34:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655804047; 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=u8CbFJERYNEWgdTaU9TWND+r1fq16oU9c/F2UL8Iiqo=; b=VADRJzQS3OrUzruv2EG96Q3Fl+khguUkHdxAUsY/CAQskIfkX3CgDOXmR4ewYc7uJHmto8 S16Wj3VNL+nQPbJFG5y+GfAeppsHEXQ1kK4ibHFnnb3EMXhP9mOGWPk4LZQrOPJj9n9z/n FlXbtZmU/M5K+9jwqHOx0NTSaJq9JnHYDu2wJWN2gMhLc8C5KZBOEUPXPYpJ0ekaUSbQcj 1i5VidYofqa8kdWXurK6fQ/Mxrvr0NIMeuTro6wYYflEBYWrIBprOURwuKoQLhQ8Fp7Euj tRDvzGcwCnKfwGAAOA5GB3AhrBQRJQCKBtyTMdn57zGUktc3iqfQP/brR0xk4g== 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 9FD6375BA; Tue, 21 Jun 2022 09:34:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25L9Y7sf090187; Tue, 21 Jun 2022 09:34:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25L9Y7Gs090186; Tue, 21 Jun 2022 09:34:07 GMT (envelope-from git) Date: Tue, 21 Jun 2022 09:34:07 GMT Message-Id: <202206210934.25L9Y7Gs090186@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 55d183367104 - main - ibcore: Fix sysfs registration error flow 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: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 55d183367104e3efcdaa936f65e4f82303871271 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655804047; 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=u8CbFJERYNEWgdTaU9TWND+r1fq16oU9c/F2UL8Iiqo=; b=wX/8mBnaWrA51dTO1KzN2ap4K465d3GLDeB9fT3AI84poBW3wxZVaMXCsNlLq7ZnE9bWSa erB7iRyO9EI/ZJtvOXOinsedUomgGp3UvFi4p9B3a/WO9EDL3xv4Dk898hUI5Fz80jklAn cEh+0bq4nyy+6aVW2V2rtcwSQuI/ObT2XuRSolFLf50BvqHMf4FDU5OnzIQ31dKwtUvCvG eIwduOToSYX3CGC9sb+Ph7jmouIBzGbSxeWJ4CDI0SHaevEZav9GRL1IY3ZE+2evLZFyO9 H9m1NK5nQ2w3ncBqh6Cjsik7Zy6M1lSistEi4h2Kwq7b5CiXH6FG36SmDTfnvA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655804047; a=rsa-sha256; cv=none; b=E31Jjv0cOxAAPcDN9foeXZU+o3DiDmMxuoU4tfvWMKiaLY5O41CFmhU0pfVpF61IGdoibc uP8Vo7QYIGJt9/p0KRO/GmQLBpsXO9aBqHog9PbBTZmwoSWuXzB+Svz1kOdqOWr2RXsjH6 R/SwP1Aj8rcogjtJStWXPHeOMUNbhhFP41DrLnLeGyMP5iOpuWQ4djVoc05qZFdypRc1Zr j4VZKAg9azNPk4PEXaRE1ksI6XARwe82Fc2QSEAdHLXV58GnqkfqxPKh/R1hKhA95DeqxW jbjpsTGPM0k/iV/IMnsgCsDz8ueOSBxcImxY/14dkQgWBGasb6BSfviLfLvffg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=55d183367104e3efcdaa936f65e4f82303871271 commit 55d183367104e3efcdaa936f65e4f82303871271 Author: Hans Petter Selasky AuthorDate: 2022-06-21 09:07:06 +0000 Commit: Hans Petter Selasky CommitDate: 2022-06-21 09:33:27 +0000 ibcore: Fix sysfs registration error flow The kernel commit cited below restructured ib device management so that the device kobject is initialized in ib_alloc_device. As part of the restructuring, the kobject is now initialized in procedure ib_alloc_device, and is later added to the device hierarchy in the ib_register_device call stack, in procedure ib_device_register_sysfs (which calls device_add). However, in the ib_device_register_sysfs error flow, if an error occurs following the call to device_add, the cleanup procedure device_unregister is called. This call results in the device object being deleted -- which results in various use-after-free crashes. The correct cleanup call is device_del -- which undoes device_add without deleting the device object. The device object will then (correctly) be deleted in the ib_register_device caller's error cleanup flow, when the caller invokes ib_dealloc_device. Linux commit: b312be3d87e4c80872cbea869e569175c5eb0f9a PR: 264472 MFC after: 3 days Sponsored by: NVIDIA Networking --- sys/ofed/drivers/infiniband/core/ib_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/ofed/drivers/infiniband/core/ib_sysfs.c b/sys/ofed/drivers/infiniband/core/ib_sysfs.c index 4cbb69ad899b..63f6c2641b83 100644 --- a/sys/ofed/drivers/infiniband/core/ib_sysfs.c +++ b/sys/ofed/drivers/infiniband/core/ib_sysfs.c @@ -1366,7 +1366,7 @@ err_put: free_port_list_attributes(device); err_unregister: - device_unregister(class_dev); + device_del(class_dev); err: return ret;