[CRIU] [PATCH] files: check fd flags after restore
Stanislav Kinsburskiу
skinsbursky at odin.com
Tue Dec 15 03:59:41 PST 2015
15 дек. 2015 г. 12:50 PM пользователь Pavel Emelyanov <xemul at parallels.com> написал:
>
> On 12/15/2015 02:37 PM, Stanislav Kinsburskiу wrote:
> >
> > 15 дек. 2015 г. 12:31 PM пользователь Pavel Emelyanov <xemul at parallels.com> написал:
> >>
> >> On 12/14/2015 06:19 PM, Stanislav Kinsburskiy wrote:
> >>> System call sys_fcntl() in _some_ kernels can silently drop some flags during
> >>> set and return success code.
> >>
> >> What are these flags?
> >>
> >
> > O_DIRECT and O_SYNC. Feature of openvz kernel.
>
> OK, don't we break restore on those kernels with this patch then?
>
I think, the question is incorrect.
The restore is already broken on openvz kernels. This patch just highlights it and break restore phase.
On upstream kernels it doesn't break anything.
Except of migration of packetized pipes, which is not merged yet. But here the kernel have to be fixed.
> >>> This patch adds double check, that all the fd flags were really set.
> >>>
> >>> Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
> >>> ---
> >>> files.c | 11 +++++++++++
> >>> 1 file changed, 11 insertions(+)
> >>>
> >>> diff --git a/files.c b/files.c
> >>> index a27667d..751a9a9 100644
> >>> --- a/files.c
> >>> +++ b/files.c
> >>> @@ -741,6 +741,17 @@ int set_fd_flags(int fd, int flags)
> >>> ret = fcntl(fd, F_SETFL, flags);
> >>> if (ret < 0)
> >>> goto err;
> >>> +
> >>> + /* Let's check, that now actual flags contains those we need */
> >>> + ret = fcntl(fd, F_GETFL, 0);
> >>> + if (ret < 0)
> >>> + goto err;
> >>> +
> >>> + if (ret != flags) {
> >>> + pr_err("fcntl call on fd %d (flags %#o) succeeded, "
> >>> + "but some flags were dropped: %#o\n", fd, flags, ret);
> >>> + return -1;
> >>> + }
> >>> return 0;
> >>>
> >>> err:
> >>>
> >>> _______________________________________________
> >>> CRIU mailing list
> >>> CRIU at openvz.org
> >>> https://lists.openvz.org/mailman/listinfo/criu
> >>> .
> >>>
> >>
>
More information about the CRIU
mailing list