[LTP] [PATCH 6/11 v2] mmap/mmap12: Testcase failed for non-root user

Cui Bixuan cuibixuan@huawei.com
Tue Nov 3 09:45:31 CET 2015


On 2015/11/3 16:24, Jan Stancek wrote:
> 
> 
> 
> 
> ----- Original Message -----
>> From: "Cui Bixuan" <cuibixuan@huawei.com>
>> To: "Cyril Hrubis" <chrubis@suse.cz>
>> Cc: "Jan Stancek" <jstancek@redhat.com>, zhuyanpeng@huawei.com, zhanyongming@huawei.com, ltp@lists.linux.it
>> Sent: Tuesday, 3 November, 2015 9:01:22 AM
>> Subject: [LTP] [PATCH 6/11 v2] mmap/mmap12: Testcase failed for non-root user
>>
>> Unprivileged user open /proc/self/pagemap fail so add check for it
>>
>> Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
> 
> Pushed with more verbose commit message and small changes to style.
> 
Thank you for your help.

Cui Bixuan

> Regards,
> Jan
> 
>> ---
>>  testcases/kernel/syscalls/mmap/mmap12.c |   10 ++++++++--
>>  1 files changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/mmap/mmap12.c
>> b/testcases/kernel/syscalls/mmap/mmap12.c
>> index ba8c646..ebc44ae 100644
>> --- a/testcases/kernel/syscalls/mmap/mmap12.c
>> +++ b/testcases/kernel/syscalls/mmap/mmap12.c
>> @@ -108,8 +108,14 @@ static int page_check(void)
>>  	index = (vmstart / page_sz) * sizeof(uint64_t);
>>
>>  	pm = open("/proc/self/pagemap", O_RDONLY);
>> -	if (pm == -1)
>> -		tst_brkm(TFAIL | TERRNO, NULL, "Open dev pagemap failed");
>> +	if (pm == -1) {
>> +		if ((0 != geteuid()) && (errno == EPERM))
>> +			tst_brkm(TCONF | TERRNO, NULL,
>> +				"don't have permission to open dev pagemap");
>> +		else
>> +			tst_brkm(TFAIL | TERRNO, NULL,
>> +				"Open dev pagemap failed");
>> +	}
>>
>>  	offset = lseek(pm, index, SEEK_SET);
>>  	if (offset != index)
>> --
>> 1.6.0.2
>>
> 
> .
> 



More information about the Ltp mailing list