[CRIU] [PATCH] File lock status may be empty

Nicolas Viennot Nicolas.Viennot at twosigma.com
Fri Sep 6 22:28:33 MSK 2019


The lock status string may be empty. This can happen when the owner of
the lock is outside of our PID namespace. See the kernel function
fs/locks.c:lock_get_status() when fl_pid == 0.

Signed-off-by: Nicolas Viennot <nviennot at twosigma.com>
---
 criu/proc_parse.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index 0e8b6f20..749dfa40 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -1669,17 +1669,21 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type, void *arg)
 		if (fdinfo_field(str, "lock")) {
 			struct file_lock *fl;
 			struct fdinfo_common *fdinfo = arg;
+			char *flock_buf = str+6;
 
 			if (type != FD_TYPES__UND)
 				continue;
 
+			if (flock_buf[0] == '\0')
+				continue;
+
 			fl = alloc_file_lock();
 			if (!fl) {
 				pr_perror("Alloc file lock failed!");
 				goto out;
 			}
 
-			if (parse_file_lock_buf(str + 6, fl, 0)) {
+			if (parse_file_lock_buf(flock_buf, fl, 0)) {
 				xfree(fl);
 				goto parse_err;
 			}
-- 
2.19.1




More information about the CRIU mailing list