From nobody Fri Apr 3 11:10:50 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 275173164D9 for ; Fri, 20 Feb 2026 08:43:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771577023; cv=none; b=qH1uoC7WDssVdqEY9tIpspjYL2TaxcOHVD/Rz3lbP65ZU51B7uV4tJ3U6ZqMGZmITBY3ZS/cAGmjbkSm3R/OCQchObPZ1H6McH5b5N+rfEh4cucXK2LK8aFEcgkv/dyTCjalCMHCthPRBHD2HKGXt5cOLHf6PlSk1vcHpMtVDTI= 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.169 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-f169.google.com with SMTP id d9443c01a7336-2a9296b3926so12606035ad.1 for ; Fri, 20 Feb 2026 00:43:42 -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=UOyUhHXBD7G/30pz+8VueodJinkoe7WuBCmUnYEcdsLKpn5UKJoa4/Y3GMNdWFbPqg bHjoMMjQ6GIepTwz2xbdLz89s/vX3ja6XssC+TJnAdC65DJJZnuwalYM2/DGKsOdR8Z0 QwPq7WH5t+HcYjIFWQybEuRhEPoE7RM/2/ySEZgGDi824cNyR4/cuZa0qSWzsJLtOz8M Ay50MzEi12uDA9BjSOG2RcTRPD6Z1nj28EenhiaRq2moP35D4swpibhj5/at3HUSAEPK noLSs3wOc0bS0bjIwdrGmwo5H+0scn0BJa1KEusKWvkWkrA//KVg2M5VKv0IUvxQHJfd DRnQ== X-Gm-Message-State: AOJu0Yz28Q4avS454RYMjjYJID6Y+khQgt660ButKirrIOKjthUD5Qxb nlyKGEvXnushuVVimMES6yIXGcQs8f/6NNjrdxqlaOSUo9czahorMnYuC1igVd0w X-Gm-Gg: AZuq6aIppsS2duH234roTzTEr0TMDrkcuhLeewOuYjS0Q8Rjbbcbn4Q8Tm5igaCbirT PDyHF4r7epMvNMA6JXUmoP395mbUWz49wjeiNGxGUtG5YQmTn3GQxXaJiaaYOmTKrdH3lCNRFan 21KI3IgKOHvNaVfhkBgn6vKW2GkmWOAWRtKyegbMyZUgzNokzHwI/a8aTYU+CN6sEWMm/5A2OnS bTTokz50/FwSBuMR8ZHyBVQPkWsu6UeYGyGf29NyG/9tWFm4ZKhBs1Q4z4rgtiailw9CdMyZD0Z vPr6ig+InYKXfoY2/3VlB+PzdXXs8IGQOku+3y+BrgH/GilS14iSuwpiZh9+QapDJUulZaBynoF dXkxtc1kXdM1c0olDE+jZ0pl9TwaWOOHNxxB8fOLFlPnkAbQpqzM+zbIyRCA2v/eq/7CONfY5t9 I5fv2DrpccXgbRFbpE30iRFsk7kfcLcGJRBypRcQ== 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/dev= ices/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) } =20 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 =3D req->map; + struct mport_dev *md =3D map->md; + + mutex_lock(&md->buf_mutex); + kref_put(&map->ref, mport_release_mapping); + mutex_unlock(&md->buf_mutex); + + req->map =3D NULL; } =20 kref_put(&priv->dma_ref, mport_release_dma); --=20 2.25.1