[CRIU] [PATCH 2/3] criu: fetch kdat.has_loginuid value on C/R

Dmitry Safonov dsafonov at odin.com
Thu Dec 24 02:44:45 PST 2015


On 12/24/2015 01:28 PM, Pavel Emelyanov wrote:
> On 12/23/2015 04:47 PM, Dmitry Safonov wrote:
>> Dump/Restore loginuid value only when kdat.has_loginuid set.
>>
>> Signed-off-by: Dmitry Safonov <dsafonov at odin.com>
>> ---
>>   cr-dump.c    | 24 ++++++++++++++----------
>>   cr-restore.c |  3 ++-
>>   2 files changed, 16 insertions(+), 11 deletions(-)
>>
>> diff --git a/cr-dump.c b/cr-dump.c
>> index fabf20a..8f7f505 100644
>> --- a/cr-dump.c
>> +++ b/cr-dump.c
>> @@ -327,17 +327,21 @@ static int dump_pid_misc(pid_t pid, TaskCoreEntry *tc)
>>   {
>>   	int ret;
>>   
>> -	pr_info("dumping /proc/%d/{oom_score_adj,loginuid}\n", pid);
>> +	if (kdat.has_loginuid) {
>> +		pr_info("dumping /proc/%d/{oom_score_adj,loginuid}\n", pid);
> Only loginuid, oom_score_adj is dumped eve w/o kdat.has_loginuid.
Maybe delete this info, or split it by two?
>
>>   
>> -	tc->has_loginuid = true;
>> -	tc->loginuid = parse_pid_loginuid(pid, &ret);
>> -	tc->loginuid = userns_uid(tc->loginuid);
>> -	/*
>> -	 * loginuid dumping is critical, as if not correctly
>> -	 * restored, you may loss ability to login via SSH to CT
>> -	 */
>> -	if (ret < 0)
>> -		return ret;
>> +		tc->has_loginuid = true;
>> +		tc->loginuid = parse_pid_loginuid(pid, &ret);
>> +		tc->loginuid = userns_uid(tc->loginuid);
>> +		/*
>> +		 * loginuid dumping is critical, as if not correctly
>> +		 * restored, you may loss ability to login via SSH to CT
>> +		 */
>> +		if (ret < 0)
>> +			return ret;
>> +	} else {
>> +		tc->has_loginuid = false;
>> +	}
>>   
>>   	tc->oom_score_adj = parse_pid_oom_score_adj(pid, &ret);
>>   	/*
>> diff --git a/cr-restore.c b/cr-restore.c
>> index 52d70a9..7941290 100644
>> --- a/cr-restore.c
>> +++ b/cr-restore.c
>> @@ -865,7 +865,8 @@ static int prepare_proc_misc(pid_t pid, TaskCoreEntry *tc)
>>   	int ret;
>>   
>>   	/* loginuid value is critical to restore */
>> -	if (tc->has_loginuid && tc->loginuid != INVALID_UID) {
>> +	if (kdat.has_loginuid && tc->has_loginuid &&
>> +			tc->loginuid != INVALID_UID) {
> Presumably it's not all, the prepare_userns_hook should also check kdat, shouldn't it?
You right, sorry for that inattention.
>
>>   		ret = prepare_loginuid(tc->loginuid);
>>   		if (ret < 0)
>>   			return ret;
>>


-- 
Regards,
Dmitry Safonov



More information about the CRIU mailing list