Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D79F2C1788 for ; Fri, 20 Feb 2026 08:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771577023; cv=none; b=JBx9QvMX/T84FXnIYQKUT3IemhIaTJGxDNROcle3zWJJwkzk290p6lzsYpLDIHtedZ0Vf2ZdsdLVYkjOm/HddFEG4XQhtlEVULUwDYJWaM2nC9GDT3sBsS5lKuxDsKe8xd3twHSFJ8GS7jsoii9nrLfB0lPp9l4qR8lQf2fh8CQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771577023; c=relaxed/simple; bh=uibJCDU21LOfe74/m1+PQf1uDx4pPIW7eQn+SHK5qSg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=agw2qYLZ788x/eoB0j6psQP5o/D34h9cGzNMZpNCyqXpb9zUq1u+9sjO7uBk1ZZ1drmpSNWD35cbVexHB+uzepbjin+Lrsrdhm9ZqbnRVsV3Mwg8HKGcMWE5CikTgYLDA/CGpTmOX6gU7qwxMB+VdfYcs8e+PRelk+aWf6z8W90= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GHSavYwB; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GHSavYwB" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2a871c8b171so11436785ad.3 for ; Fri, 20 Feb 2026 00:43:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771577021; x=1772181821; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qO2PxxzQfOEeSvBvTUAwrdOV1cPvLc1kKprU8EjanXk=; b=GHSavYwBPgNIew7c0/qa1Dq6xd8SVLXGh6C20UQ5P8zwU7vg8FQdvr0LASVCx313k0 7W+KduWY7e8PSbFQ+uORfpcxFfLQCEoxDEzZRNH6EWnRBp3WrGx6h1IxT+kNEd4/K1Zy cohqXs1FXGErQxwqU93auNUWhPmEdChRlW1EDHjALHiodWQh9eEL4FbiR/WXwQ7TG66/ bDQy9c6z42FAQ8p4YRVeCRKOpq4a8mL9hLes5BuARL+KLVI/d7nEaVJ07FdhgIAZA2Tr 9JZCRU603aJTs4pyYs4usvEb4wTipGuLjRTLEyCI1a8gTZ2zZ5jjnu0wSfFDRz7FEJqZ akuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771577021; x=1772181821; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qO2PxxzQfOEeSvBvTUAwrdOV1cPvLc1kKprU8EjanXk=; b=FC1TZ/YlJ5LFpw6VojIQmSRzgrZfYwvUWpJn6dCbl3P/IoLeZ/SjGKriRPS+EdAdHQ AwYTHFSOkBto4gAKBofQGFT7E/D+8Vb8nu0Xgx7/TRnl1MYM5mbROYDAOPR6C9QMtg7+ pSAh+FfNVSHD1vSrGrBvSd7Cu1NsaZGcPLvBwAKSWfaRYNMvf0xueDVJVta492APaqxg NyILmFg31nFLH13JdXpLRKZ/mWTs6CDhxnxKRxOYnDPg/gJiCNDKbhTYUmemWyMvgY8E Cx6JSCdEw/ibg/9/iKeHaJH3XgiaaKTmzsrZ4ErS0pguYBKQhT6+tXAspeNjGqsoIIfQ hZ3A== X-Forwarded-Encrypted: i=1; AJvYcCVCYCLg46UsQGAtDkD58iv9FBCi6smMFBPQaVj9eG7jBAJFN5GRhxia+rkw18IgwpoqhuYIbi0=@vger.kernel.org X-Gm-Message-State: AOJu0YyeWx4uxMPOy0G9UuLtjZwZxPG7NLD5ButAMGEqCMGJ3flmGU4b xFRGtXY9OenvCc6Vg64S48607NqgXuAUOduVVQdJWRZjYdGDgrNSLgsmdb7WEuSq X-Gm-Gg: AZuq6aIZd/g23UfejP8cCie06irvTfe8yoE0ycJ3WGyYcIBHjWW8h7mS6gHEK1l2SHJ QyB05/BrbFoWob9Uc4BBGIvwdKQJ24HDBRRDffabT+Rj+M2u2TUhftgMZ6U3hCgma5X51hVfP4y AY8Wo3PR7zL1kMOpfhKVpyW0g2XAi1vLuyPRE93JREbCY2mEk7VAVC+MvzNkDudV+xRAQ6Te7op LSt3RSHrc7n8YxxUDbqMvRdvA8hIVawXGQq1A6xpZecvimBcWCn05NeInk8Z6D+jHNmGSHDjme5 iZOCPi99hp4tGy/STWyHsnFi87oSBbu/V6czutCw9c2KrEzNtqkYSXuZQ54dcXTZrqjqi/mVZZi hmQqd1o/v2jI+rxH88aDz2A+39JVryXSWLOk3t/POL/0YECvdijZSrWXy4lXe5T4TxJGTuRsOqi JQ4DBnuejY5tnm3HhFcns8z1NNAVe+sHAhy6UBdw== X-Received: by 2002:a17:902:f683:b0:2aa:ea3d:a37b with SMTP id d9443c01a7336-2ad50e763b1mr67775945ad.2.1771577020921; Fri, 20 Feb 2026 00:43:40 -0800 (PST) Received: from localhost.localdomain ([119.204.109.83]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ad1a9d624esm185489455ad.49.2026.02.20.00.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Feb 2026 00:43:40 -0800 (PST) From: James Kim To: linux-kernel@vger.kernel.org Cc: mporter@kernel.crashing.org, alex.bou9@gmail.com, stable@vger.kernel.org, gregkh@linuxfoundation.org, James Kim Subject: [PATCH] rapidio: mport_cdev: fix sequential UAF in dma_req_free() Date: Fri, 20 Feb 2026 17:36:22 +0900 Message-Id: <20260220083621.3512086-1-james010kim@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit dma_req_free() drops the mapping reference under buf_mutex and then dereferences req->map again to unlock the mutex. If kref_put() drops the last reference, mport_release_mapping() frees the mapping, and the subsequent mutex_unlock() dereferences a freed object. This is a sequential (non-racy) use-after-free. Fix this by caching map and md before kref_put() and using the cached md for mutex unlocking. Fixes: 4b0986a36 ("rapidio: add mport character device support") Cc: stable@vger.kernel.org Signed-off-by: James Kim --- drivers/rapidio/devices/rio_mport_cdev.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) Resending to the proper list(s), no changes since the original submission. diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c index 7df466e22282..5fb6ec439028 100644 --- a/drivers/rapidio/devices/rio_mport_cdev.c +++ b/drivers/rapidio/devices/rio_mport_cdev.c @@ -582,9 +582,14 @@ static void dma_req_free(struct kref *ref) } if (req->map) { - mutex_lock(&req->map->md->buf_mutex); - kref_put(&req->map->ref, mport_release_mapping); - mutex_unlock(&req->map->md->buf_mutex); + struct rio_mport_mapping *map = req->map; + struct mport_dev *md = map->md; + + mutex_lock(&md->buf_mutex); + kref_put(&map->ref, mport_release_mapping); + mutex_unlock(&md->buf_mutex); + + req->map = NULL; } kref_put(&priv->dma_ref, mport_release_dma); -- 2.25.1