All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] mmap15: don't fail if mmap returns EINVAL
@ 2014-08-22  6:45 Jan Stancek
  2014-08-22  8:05 ` Wanlong Gao
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2014-08-22  6:45 UTC (permalink / raw)
  To: ltp-list

Older kernels (2.6.32) on ppc64 return EINVAL instead of ENOMEM.

Man page says:
"EINVAL We don’t like addr, length, or offset (e.g., they are too large,
or not aligned on a page boundary).", which suggests that both
ENOMEM and EINVAL should be considered.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/mmap/mmap15.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/mmap/mmap15.c b/testcases/kernel/syscalls/mmap/mmap15.c
index 49dbba4..f1fc267 100644
--- a/testcases/kernel/syscalls/mmap/mmap15.c
+++ b/testcases/kernel/syscalls/mmap/mmap15.c
@@ -80,10 +80,10 @@ int main(int ac, char **av)
 			continue;
 		}
 
-		if (errno != ENOMEM) {
+		if (errno != ENOMEM && errno != EINVAL) {
 			tst_resm(TFAIL | TERRNO, "mmap into high region "
 				 "failed unexpectedly - expect "
-				 "errno=ENOMEM, got");
+				 "errno=ENOMEM/EINVAL, got");
 		} else {
 			tst_resm(TPASS | TERRNO, "mmap into high region "
 				 "failed as expected");
-- 
1.7.1


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] mmap15: don't fail if mmap returns EINVAL
  2014-08-22  6:45 [LTP] [PATCH] mmap15: don't fail if mmap returns EINVAL Jan Stancek
@ 2014-08-22  8:05 ` Wanlong Gao
  2014-08-22 13:35   ` Stanislav Kholmanskikh
  0 siblings, 1 reply; 5+ messages in thread
From: Wanlong Gao @ 2014-08-22  8:05 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp-list

On 08/22/2014 02:45 PM, Jan Stancek wrote:
> Older kernels (2.6.32) on ppc64 return EINVAL instead of ENOMEM.
> 
> Man page says:
> "EINVAL We don’t like addr, length, or offset (e.g., they are too large,
> or not aligned on a page boundary).", which suggests that both
> ENOMEM and EINVAL should be considered.
> 
> Signed-off-by: Jan Stancek <jstancek@redhat.com>

Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

> ---
>  testcases/kernel/syscalls/mmap/mmap15.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/mmap/mmap15.c b/testcases/kernel/syscalls/mmap/mmap15.c
> index 49dbba4..f1fc267 100644
> --- a/testcases/kernel/syscalls/mmap/mmap15.c
> +++ b/testcases/kernel/syscalls/mmap/mmap15.c
> @@ -80,10 +80,10 @@ int main(int ac, char **av)
>  			continue;
>  		}
>  
> -		if (errno != ENOMEM) {
> +		if (errno != ENOMEM && errno != EINVAL) {
>  			tst_resm(TFAIL | TERRNO, "mmap into high region "
>  				 "failed unexpectedly - expect "
> -				 "errno=ENOMEM, got");
> +				 "errno=ENOMEM/EINVAL, got");
>  		} else {
>  			tst_resm(TPASS | TERRNO, "mmap into high region "
>  				 "failed as expected");
> 


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] mmap15: don't fail if mmap returns EINVAL
  2014-08-22  8:05 ` Wanlong Gao
@ 2014-08-22 13:35   ` Stanislav Kholmanskikh
       [not found]     ` <CAE1O6mgqn51jh-ib5vXUL8P2kBuJMbG1Wg6WPFp8y2p6Vp74kQ@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Stanislav Kholmanskikh @ 2014-08-22 13:35 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp-list



On 08/22/2014 12:05 PM, Wanlong Gao wrote:
> On 08/22/2014 02:45 PM, Jan Stancek wrote:
>> Older kernels (2.6.32) on ppc64 return EINVAL instead of ENOMEM.
>>
>> Man page says:
>> "EINVAL We don’t like addr, length, or offset (e.g., they are too large,
>> or not aligned on a page boundary).", which suggests that both
>> ENOMEM and EINVAL should be considered.
>>
>> Signed-off-by: Jan Stancek <jstancek@redhat.com>
>
> Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

Modern sparc64 kernels return EINVAL as well.

Acked-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>


>
>> ---
>>   testcases/kernel/syscalls/mmap/mmap15.c |    4 ++--
>>   1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/mmap/mmap15.c b/testcases/kernel/syscalls/mmap/mmap15.c
>> index 49dbba4..f1fc267 100644
>> --- a/testcases/kernel/syscalls/mmap/mmap15.c
>> +++ b/testcases/kernel/syscalls/mmap/mmap15.c
>> @@ -80,10 +80,10 @@ int main(int ac, char **av)
>>   			continue;
>>   		}
>>
>> -		if (errno != ENOMEM) {
>> +		if (errno != ENOMEM && errno != EINVAL) {
>>   			tst_resm(TFAIL | TERRNO, "mmap into high region "
>>   				 "failed unexpectedly - expect "
>> -				 "errno=ENOMEM, got");
>> +				 "errno=ENOMEM/EINVAL, got");

Maybe add this ENOMEM/EINVAL in the comment few stings above:
/* Attempt to mmap into highmem addr, should get ENOMEM */

?

Thanks.

>>   		} else {
>>   			tst_resm(TPASS | TERRNO, "mmap into high region "
>>   				 "failed as expected");
>>
>
>
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
>

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] mmap15: don't fail if mmap returns EINVAL
       [not found]     ` <CAE1O6mgqn51jh-ib5vXUL8P2kBuJMbG1Wg6WPFp8y2p6Vp74kQ@mail.gmail.com>
@ 2014-08-25 11:07       ` chrubis
       [not found]         ` <1721706552.12305163.1408967269010.JavaMail.zimbra@redhat.com>
  0 siblings, 1 reply; 5+ messages in thread
From: chrubis @ 2014-08-25 11:07 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp-list

Hi!
If I remember right it's POSIX requirement to return ENOMEM in this case
and EINVAL sometimes slips in into kernel arch specific memory
management code.

Citing POSIX:

[ENOMEM]
	MAP_FIXED was specified, and the range [addr,addr+len) exceeds that
	allowed for the address space of a process;

So if the testcase fails, it's a bug albeit a minor one.

What we should do depends on how strict we are. I would personaly change
the testcase to have specific failure message for EINVAL, ideally
pointing to this discussion on mailing list archive. But if all the rest
of you consider this minor enough to be ignored we can proceed with the
original patch as well.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] mmap15: don't fail if mmap returns EINVAL
       [not found]         ` <1721706552.12305163.1408967269010.JavaMail.zimbra@redhat.com>
@ 2014-08-25 12:05           ` chrubis
  0 siblings, 0 replies; 5+ messages in thread
From: chrubis @ 2014-08-25 12:05 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp-list, Li Wang

Hi!
> > If I remember right it's POSIX requirement to return ENOMEM in this case
> > and EINVAL sometimes slips in into kernel arch specific memory
> > management code.
> > 
> > Citing POSIX:
> > 
> > [ENOMEM]
> > 	MAP_FIXED was specified, and the range [addr,addr+len) exceeds that
> > 	allowed for the address space of a process;
> > 
> 
> It also says:
> 
> [EINVAL]
>   The addr argument (if MAP_FIXED was specified) or off is not a multiple
>   of the page size as returned by sysconf(), or is considered invalid by
>   the implementation.
> 
> "addr" used in testcase (HIGH_ADDR) is large enough for implementation to
> reject it without even looking at len and range it would occupy.
> Wouldn't this fit the EINVAL description too?

My view on this is that you have to take the more specific errors into
consideration first otherwise there is no need to define them in the
first place and you can return the most generic errors in all applicable
cases.

But given that interpreting POSIX is like interpreting religious texts
(POSIX it cryptic, POSIX contains logical errors and people tend to
 quarrel about smallest things) I'm open to any reasonable solution we
 can all agree on (so we can move on to more important things to test).

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-25 12:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-22  6:45 [LTP] [PATCH] mmap15: don't fail if mmap returns EINVAL Jan Stancek
2014-08-22  8:05 ` Wanlong Gao
2014-08-22 13:35   ` Stanislav Kholmanskikh
     [not found]     ` <CAE1O6mgqn51jh-ib5vXUL8P2kBuJMbG1Wg6WPFp8y2p6Vp74kQ@mail.gmail.com>
2014-08-25 11:07       ` chrubis
     [not found]         ` <1721706552.12305163.1408967269010.JavaMail.zimbra@redhat.com>
2014-08-25 12:05           ` chrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.