Re: epoll may leak events on dup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sargun Dhillon <sargun@xxxxxxxxx> wrote:
> On Sun, Oct 31, 2021 at 07:39:23AM +0000, Eric Wong wrote:
> > CRIU?  Checkpoint/Restore In Userspace?
> > Sargun Dhillon <sargun@xxxxxxxxx> wrote:
> > 
> Right, in CRIU, epoll is restored by manually cloning the FDs to the
> right spot, and re-installing the events into epoll. This requires:
> 0. Getting the original epoll FD
> 1. Fetching / recreating the original FD
> 2. dup2'ing it to right spot (and avoiding overwriting the original epoll FD)
> 3. EPOLL_CTL_ADD'ing the FD back in.

OK, am I understanding it's something like:

	int tmp_fd = epoll_create1(...);
	if (tmp_fd != orig_epfd) {
		dup2(tmp_fd, orig_epfd);
		close(tmp_fd);
	}

	for (/* loop over original FDs: */) {
		tmp_fd = socket(...);
		if (tmpfd != orig_sfd) {
			dup2(tmp_fd, orig_sfd);
			close(tmp_fd);
		}
		epoll_ctl(orig_epfd, EPOLL_CTL_ADD, orig_sfd, ...);
	}

Is that close to what CRIU is doing?
In no place does tmp_fd end up in the epoll rbtree, there.
Everything is keyed w/ orig_sfd and it's underlying file.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux