This is a note to let you know that I've just added the patch titled Fix a potential infinite loop in extract_user_to_sg() to the 6.8-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: fix-a-potential-infinite-loop-in-extract_user_to_sg.patch and it can be found in the queue-6.8 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit b45a6e74ab1ab31963a31505a74153ae8c2aea5c Author: David Howells <dhowells@xxxxxxxxxx> Date: Thu Apr 25 09:39:32 2024 +0100 Fix a potential infinite loop in extract_user_to_sg() [ Upstream commit 6a30653b604aaad1bf0f2e74b068ceb8b6fc7aea ] Fix extract_user_to_sg() so that it will break out of the loop if iov_iter_extract_pages() returns 0 rather than looping around forever. [Note that I've included two fixes lines as the function got moved to a different file and renamed] Fixes: 85dd2c8ff368 ("netfs: Add a function to extract a UBUF or IOVEC into a BVEC iterator") Fixes: f5f82cd18732 ("Move netfs_extract_iter_to_sg() to lib/scatterlist.c") Signed-off-by: David Howells <dhowells@xxxxxxxxxx> cc: Jeff Layton <jlayton@xxxxxxxxxx> cc: Steve French <sfrench@xxxxxxxxx> cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> cc: netfs@xxxxxxxxxxxxxxx Link: https://lore.kernel.org/r/1967121.1714034372@xxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/lib/scatterlist.c b/lib/scatterlist.c index 68b45c82c37a6..7bc2220fea805 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -1124,7 +1124,7 @@ static ssize_t extract_user_to_sg(struct iov_iter *iter, do { res = iov_iter_extract_pages(iter, &pages, maxsize, sg_max, extraction_flags, &off); - if (res < 0) + if (res <= 0) goto failed; len = res;