[CRIU] [PATCH 4/8] lazy-pages: handle_requests: fix return value propagation

Mike Rapoport rppt at linux.vnet.ibm.com
Mon Apr 16 19:59:00 MSK 2018


When we return from epoll_run_rfds with positive return value it means that
event handling loop was interrupted because the event should be handled
outside of that loop. Is always the case with UFFD_EVENT_FORK.

It may happen that the event occurred after we've completed the memory
transfer and we are on the way to successful return from the
handle_requests() function, but instead of returning 0 we will return the
positive value we've got from epoll_run_rfds.

Explicitly assigning return value of complete_forks() fixes this issue.

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/uffd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/criu/uffd.c b/criu/uffd.c
index 55de798..0343f93 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -1150,8 +1150,9 @@ static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds)
 		if (ret < 0)
 			goto out;
 		if (ret > 0) {
-			if (complete_forks(epollfd, &events, &nr_fds))
-				return -1;
+			ret = complete_forks(epollfd, &events, &nr_fds);
+			if (ret)
+				goto out;
 			if (!restore_finished)
 				continue;
 		}
-- 
2.7.4



More information about the CRIU mailing list