Patch "misc: mic: scif: Fix error handling path" has been added to the 5.9-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

    misc: mic: scif: Fix error handling path

to the 5.9-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:
     misc-mic-scif-fix-error-handling-path.patch
and it can be found in the queue-5.9 subdirectory.

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



commit 0b2db552f35c6af2f6ddec1bf45aef95555c2221
Author: Souptick Joarder <jrdr.linux@xxxxxxxxx>
Date:   Sun Sep 20 08:21:35 2020 +0530

    misc: mic: scif: Fix error handling path
    
    [ Upstream commit a81072a9c0ae734b7889929b0bc070fe3f353f0e ]
    
    Inside __scif_pin_pages(), when map_flags != SCIF_MAP_KERNEL it
    will call pin_user_pages_fast() to map nr_pages. However,
    pin_user_pages_fast() might fail with a return value -ERRNO.
    
    The return value is stored in pinned_pages->nr_pages. which in
    turn is passed to unpin_user_pages(), which expects
    pinned_pages->nr_pages >=0, else disaster.
    
    Fix this by assigning pinned_pages->nr_pages to 0 if
    pin_user_pages_fast() returns -ERRNO.
    
    Fixes: ba612aa8b487 ("misc: mic: SCIF memory registration and unregistration")
    Cc: John Hubbard <jhubbard@xxxxxxxxxx>
    Cc: Ira Weiny <ira.weiny@xxxxxxxxx>
    Cc: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Reviewed-by: John Hubbard <jhubbard@xxxxxxxxxx>
    Signed-off-by: Souptick Joarder <jrdr.linux@xxxxxxxxx>
    Link: https://lore.kernel.org/r/1600570295-29546-1-git-send-email-jrdr.linux@xxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/misc/mic/scif/scif_rma.c b/drivers/misc/mic/scif/scif_rma.c
index 2da3b474f4863..18fb9d8b8a4b5 100644
--- a/drivers/misc/mic/scif/scif_rma.c
+++ b/drivers/misc/mic/scif/scif_rma.c
@@ -1392,6 +1392,8 @@ int __scif_pin_pages(void *addr, size_t len, int *out_prot,
 				(prot & SCIF_PROT_WRITE) ? FOLL_WRITE : 0,
 				pinned_pages->pages);
 		if (nr_pages != pinned_pages->nr_pages) {
+			if (pinned_pages->nr_pages < 0)
+				pinned_pages->nr_pages = 0;
 			if (try_upgrade) {
 				if (ulimit)
 					__scif_dec_pinned_vm_lock(mm, nr_pages);
@@ -1408,7 +1410,6 @@ int __scif_pin_pages(void *addr, size_t len, int *out_prot,
 
 	if (pinned_pages->nr_pages < nr_pages) {
 		err = -EFAULT;
-		pinned_pages->nr_pages = nr_pages;
 		goto dec_pinned;
 	}
 
@@ -1421,7 +1422,6 @@ int __scif_pin_pages(void *addr, size_t len, int *out_prot,
 		__scif_dec_pinned_vm_lock(mm, nr_pages);
 	/* Something went wrong! Rollback */
 error_unmap:
-	pinned_pages->nr_pages = nr_pages;
 	scif_destroy_pinned_pages(pinned_pages);
 	*pages = NULL;
 	dev_dbg(scif_info.mdev.this_device,



[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