[CRIU] [PATCH 1/5] files: Fix crossing unused and service fds of shared fd tables

Kirill Tkhai ktkhai at virtuozzo.com
Thu Jun 8 14:33:31 MSK 2017


On 07.06.2017 18:26, Cyrill Gorcunov wrote:
> On Wed, Jun 07, 2017 at 06:15:12PM +0300, Kirill Tkhai wrote:
>> service_fd_id is id of a specific task, while other tasks
>> in shared fd table group may have bigger id numbers.
>> In this case given unused fd intersects with service fds
>> of such tasks. This leads to undefined behaviour. Fix that.
>>
>> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
>> +int service_fd_min_fd(struct pstree_item *item)
>>  {
>> -	return service_fd_rlim_cur - (SERVICE_FD_MAX - 1) - SERVICE_FD_MAX * service_fd_id;
>> +	struct fdt *fdt = rsti(item)->fdt;
>> +	int id = 0;
>> +
>> +	if (fdt)
>> +		id = fdt->nr - 1;
> 
> Why -1 here?

service_fd has numbers from 0 to fdt->nr-1, so we have to take the biggest number,
and it is be the biggest offset. I based on this. Is there wrong assumption?


More information about the CRIU mailing list