FAILED: patch "[PATCH] iommufd: Propagate allocation failure in" failed to apply to 6.18-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 489e63dd120bad52eba63f5506c214750cd5bc75
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026071652-safeguard-secluding-f2b1@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 489e63dd120bad52eba63f5506c214750cd5bc75 Mon Sep 17 00:00:00 2001
From: Nicolin Chen <[email protected]>
Date: Mon, 1 Jun 2026 13:42:34 -0700
Subject: [PATCH] iommufd: Propagate allocation failure in
iommufd_veventq_deliver_fetch()
When the kzalloc_obj() fails in iommufd_veventq_deliver_fetch(), it returns NULL, falsely advertising to userspace that the queue is empty.
Propagate the -ENOMEM properly to the caller.
drivers/iommu/iommufd/eventq.c +9 -1
@@ -264,8 +264,10 @@ iommufd_veventq_deliver_fetch(struct iommufd_veventq *veventq)/* Make a copy of the lost_events_header for copy_to_user */ if (next == &veventq->lost_events_header) { vevent =kzalloc_obj (*vevent,GFP_ATOMIC ); -if (!vevent) +if (!vevent) { + vevent =ERR_PTR (-ENOMEM ); goto out_unlock; + } }list_del (&next->node);if (vevent)
@@ -315,6 +317,12 @@ static ssize_t iommufd_veventq_fops_read(struct file *filep, char __user *buf,return -EINVAL ;while ((cur =iommufd_veventq_deliver_fetch (veventq))) { +if (IS_ERR (cur)) { +if (done ==0 ) + rc =PTR_ERR (cur); +break ; + } +/* Validate the remaining bytes against the header size */ if (done >= count ||sizeof (*hdr) > count - done) {iommufd_veventq_deliver_restore (veventq, cur);
Sasha Levin
maintainerPATCH 1/1 iommufd: Propagate allocation failure in iommufd_veventq_deliver_fetch()
From: Nicolin Chen <[email protected]>
[ Upstream commit 489e63dd120bad52eba63f5506c214750cd5bc75 ]
When the kzalloc_obj() fails in iommufd_veventq_deliver_fetch(), it returns NULL, falsely advertising to userspace that the queue is empty.
Propagate the -ENOMEM properly to the caller.
--- drivers/iommu/iommufd/eventq.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/iommu/iommufd/eventq.c +9 -1
@@ -272,8 +272,10 @@ iommufd_veventq_deliver_fetch(struct iommufd_veventq *veventq)/* Make a copy of the lost_events_header for copy_to_user */ if (next == &veventq->lost_events_header) { vevent =kzalloc (sizeof (*vevent),GFP_ATOMIC ); -if (!vevent) +if (!vevent) { + vevent =ERR_PTR (-ENOMEM ); goto out_unlock; + } }list_del (&next->node);if (vevent)
@@ -323,6 +325,12 @@ static ssize_t iommufd_veventq_fops_read(struct file *filep, char __user *buf,return -EINVAL ;while ((cur =iommufd_veventq_deliver_fetch (veventq))) { +if (IS_ERR (cur)) { +if (done ==0 ) + rc =PTR_ERR (cur); +break ; + } +/* Validate the remaining bytes against the header size */ if (done >= count ||sizeof (*hdr) > count - done) {iommufd_veventq_deliver_restore (veventq, cur);
Signature · 1 line
2.53.0