Patch "IB/uverbs: Fix to consider event queue closing also upon non-blocking mode" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    IB/uverbs: Fix to consider event queue closing also upon non-blocking mode

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ib-uverbs-fix-to-consider-event-queue-closing-also-u.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit be9922b072e467c066d159a335a32f7fe09b0c65
Author: Yishai Hadas <yishaih@xxxxxxxxxx>
Date:   Mon Jun 5 13:33:25 2023 +0300

    IB/uverbs: Fix to consider event queue closing also upon non-blocking mode
    
    [ Upstream commit 62fab312fa1683e812e605db20d4f22de3e3fb2f ]
    
    Fix ib_uverbs_event_read() to consider event queue closing also upon
    non-blocking mode.
    
    Once the queue is closed (e.g. hot-plug flow) all the existing events
    are cleaned-up as part of ib_uverbs_free_event_queue().
    
    An application that uses the non-blocking FD mode should get -EIO in
    that case to let it knows that the device was removed already.
    
    Otherwise, it can loose the indication that the device was removed and
    won't recover.
    
    As part of that, refactor the code to have a single flow with regards to
    'is_closed' for both blocking and non-blocking modes.
    
    Fixes: 14e23bd6d221 ("RDMA/core: Fix locking in ib_uverbs_event_read")
    Reviewed-by: Maor Gottlieb <maorg@xxxxxxxxxx>
    Signed-off-by: Yishai Hadas <yishaih@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/97b00116a1e1e13f8dc4ec38a5ea81cf8c030210.1685960567.git.leon@xxxxxxxxxx
    Signed-off-by: Leon Romanovsky <leon@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index adb08c3fc085a..e5fd43162b768 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -230,8 +230,12 @@ static ssize_t ib_uverbs_event_read(struct ib_uverbs_event_queue *ev_queue,
 	spin_lock_irq(&ev_queue->lock);
 
 	while (list_empty(&ev_queue->event_list)) {
-		spin_unlock_irq(&ev_queue->lock);
+		if (ev_queue->is_closed) {
+			spin_unlock_irq(&ev_queue->lock);
+			return -EIO;
+		}
 
+		spin_unlock_irq(&ev_queue->lock);
 		if (filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
@@ -241,12 +245,6 @@ static ssize_t ib_uverbs_event_read(struct ib_uverbs_event_queue *ev_queue,
 			return -ERESTARTSYS;
 
 		spin_lock_irq(&ev_queue->lock);
-
-		/* If device was disassociated and no event exists set an error */
-		if (list_empty(&ev_queue->event_list) && ev_queue->is_closed) {
-			spin_unlock_irq(&ev_queue->lock);
-			return -EIO;
-		}
 	}
 
 	event = list_entry(ev_queue->event_list.next, struct ib_uverbs_event, list);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux