Commit d393e5d1 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

flock: Don't assume device maj/min numbers are byte long

Igor reported the following file lock

 | (00.003139) lockinfo: 4:POSIX ADVISORY WRITE 46567 b6:5f0b1:524702 0 EOF
 | (00.003154) lockinfo: 5:POSIX ADVISORY WRITE 46559 b6:5f0b1:524661 0 EOF
 | (00.003172) lockinfo: 6:POSIX ADVISORY WRITE 46543 b6:5f0b1:524326 0 0
 | (00.003188) lockinfo: 7:POSIX ADVISORY WRITE 46543 b6:5f0b1:524367 0 EOF

where device maj number is pretty big and parsing failed.
Fix it removing field width.
Reported-by: 's avatarIgor Sukhih <igor@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ebb4a1bf
...@@ -1077,19 +1077,19 @@ static int parse_file_lock_buf(char *buf, struct file_lock *fl, ...@@ -1077,19 +1077,19 @@ static int parse_file_lock_buf(char *buf, struct file_lock *fl,
int num; int num;
if (is_blocked) { if (is_blocked) {
num = sscanf(buf, "%lld: -> %s %s %s %d %02x:%02x:%ld %lld %s", num = sscanf(buf, "%lld: -> %s %s %s %d %x:%x:%ld %lld %s",
&fl->fl_id, fl->fl_flag, fl->fl_type, fl->fl_option, &fl->fl_id, fl->fl_flag, fl->fl_type, fl->fl_option,
&fl->fl_owner, &fl->maj, &fl->min, &fl->i_no, &fl->fl_owner, &fl->maj, &fl->min, &fl->i_no,
&fl->start, fl->end); &fl->start, fl->end);
} else { } else {
num = sscanf(buf, "%lld:%s %s %s %d %02x:%02x:%ld %lld %s", num = sscanf(buf, "%lld:%s %s %s %d %x:%x:%ld %lld %s",
&fl->fl_id, fl->fl_flag, fl->fl_type, fl->fl_option, &fl->fl_id, fl->fl_flag, fl->fl_type, fl->fl_option,
&fl->fl_owner, &fl->maj, &fl->min, &fl->i_no, &fl->fl_owner, &fl->maj, &fl->min, &fl->i_no,
&fl->start, fl->end); &fl->start, fl->end);
} }
if (num < 10) { if (num < 10) {
pr_perror("Invalid file lock info: %s", buf); pr_err("Invalid file lock info (%d): %s", num, buf);
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment