* [LTP] [PATCH 1/1] madvise03: let the system select an address for shmat()
@ 2012-08-02 16:53 Simon Xu
2012-08-03 3:46 ` Wanlong Gao
0 siblings, 1 reply; 5+ messages in thread
From: Simon Xu @ 2012-08-02 16:53 UTC (permalink / raw)
To: ltp-list
In certain occasions, 0x22000000 is invalid for shmat() and madvise03 fails:
madvise03 1 TBROK : shmat error
madvise03 2 TBROK : Remaining cases broken
Use `NULL' for shmat() to let the system attach the shared memory segment
at the first available address.
Signed-off-by: Simon Xu <xu.simon@oracle.com>
---
testcases/kernel/syscalls/madvise/madvise03.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/madvise/madvise03.c b/testcases/kernel/syscalls/madvise/madvise03.c
index 2e696e8..fd0bd97 100644
--- a/testcases/kernel/syscalls/madvise/madvise03.c
+++ b/testcases/kernel/syscalls/madvise/madvise03.c
@@ -154,13 +154,13 @@ int main(int argc, char *argv[])
if (shmid1 == -1)
tst_brkm(TBROK, cleanup, "shmget failed");
- /* Attach shared memory segment to 0x22000000 address */
- addr1 = shmat(shmid1, (void *)0x22000000, 0);
+ /* Attach shared memory segment to an address selected by the system */
+ addr1 = shmat(shmid1, NULL, 0);
if (addr1 == (void *) -1)
tst_brkm(TBROK, cleanup, "shmat error");
/* (1) Test case for MADV_REMOVE */
- TEST(madvise((void *)0x22000000, 4096, MADV_REMOVE));
+ TEST(madvise((void *)addr1, 4096, MADV_REMOVE));
check_and_print("MADV_REMOVE");
/* (2) Test case for MADV_DONTFORK */
--
1.7.11.4
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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 1/1] madvise03: let the system select an address for shmat()
2012-08-02 16:53 [LTP] [PATCH 1/1] madvise03: let the system select an address for shmat() Simon Xu
@ 2012-08-03 3:46 ` Wanlong Gao
2012-08-03 6:38 ` Jan Stancek
0 siblings, 1 reply; 5+ messages in thread
From: Wanlong Gao @ 2012-08-03 3:46 UTC (permalink / raw)
To: Simon Xu; +Cc: ltp-list
On 08/03/2012 12:53 AM, Simon Xu wrote:
> In certain occasions, 0x22000000 is invalid for shmat() and madvise03 fails:
>
> madvise03 1 TBROK : shmat error
> madvise03 2 TBROK : Remaining cases broken
>
> Use `NULL' for shmat() to let the system attach the shared memory segment
> at the first available address.
>
> Signed-off-by: Simon Xu <xu.simon@oracle.com>
> ---
> testcases/kernel/syscalls/madvise/madvise03.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/madvise/madvise03.c b/testcases/kernel/syscalls/madvise/madvise03.c
> index 2e696e8..fd0bd97 100644
> --- a/testcases/kernel/syscalls/madvise/madvise03.c
> +++ b/testcases/kernel/syscalls/madvise/madvise03.c
> @@ -154,13 +154,13 @@ int main(int argc, char *argv[])
> if (shmid1 == -1)
> tst_brkm(TBROK, cleanup, "shmget failed");
>
> - /* Attach shared memory segment to 0x22000000 address */
> - addr1 = shmat(shmid1, (void *)0x22000000, 0);
> + /* Attach shared memory segment to an address selected by the system */
> + addr1 = shmat(shmid1, NULL, 0);
> if (addr1 == (void *) -1)
> tst_brkm(TBROK, cleanup, "shmat error");
>
> /* (1) Test case for MADV_REMOVE */
> - TEST(madvise((void *)0x22000000, 4096, MADV_REMOVE));
> + TEST(madvise((void *)addr1, 4096, MADV_REMOVE));
(void *) is not needed now ?
otherwise, looks OK to me.
Thanks,
Wanlong Gao
> check_and_print("MADV_REMOVE");
>
> /* (2) Test case for MADV_DONTFORK */
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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 1/1] madvise03: let the system select an address for shmat()
2012-08-03 3:46 ` Wanlong Gao
@ 2012-08-03 6:38 ` Jan Stancek
2012-08-03 9:21 ` Simon Xu
0 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2012-08-03 6:38 UTC (permalink / raw)
To: gaowanlong; +Cc: ltp-list
----- Original Message -----
> From: "Wanlong Gao" <gaowanlong@cn.fujitsu.com>
> To: "Simon Xu" <xu.simon@oracle.com>
> Cc: ltp-list@lists.sourceforge.net
> Sent: Friday, 3 August, 2012 5:46:31 AM
> Subject: Re: [LTP] [PATCH 1/1] madvise03: let the system select an address for shmat()
>
> On 08/03/2012 12:53 AM, Simon Xu wrote:
> > In certain occasions, 0x22000000 is invalid for shmat() and
> > madvise03 fails:
> >
> > madvise03 1 TBROK : shmat error
> > madvise03 2 TBROK : Remaining cases broken
> >
> > Use `NULL' for shmat() to let the system attach the shared memory
> > segment
> > at the first available address.
> >
> > Signed-off-by: Simon Xu <xu.simon@oracle.com>
> > ---
> > testcases/kernel/syscalls/madvise/madvise03.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/madvise/madvise03.c
> > b/testcases/kernel/syscalls/madvise/madvise03.c
> > index 2e696e8..fd0bd97 100644
> > --- a/testcases/kernel/syscalls/madvise/madvise03.c
> > +++ b/testcases/kernel/syscalls/madvise/madvise03.c
> > @@ -154,13 +154,13 @@ int main(int argc, char *argv[])
> > if (shmid1 == -1)
> > tst_brkm(TBROK, cleanup, "shmget failed");
> >
> > - /* Attach shared memory segment to 0x22000000 address */
> > - addr1 = shmat(shmid1, (void *)0x22000000, 0);
> > + /* Attach shared memory segment to an address selected by the
> > system */
> > + addr1 = shmat(shmid1, NULL, 0);
> > if (addr1 == (void *) -1)
> > tst_brkm(TBROK, cleanup, "shmat error");
> >
> > /* (1) Test case for MADV_REMOVE */
> > - TEST(madvise((void *)0x22000000, 4096, MADV_REMOVE));
> > + TEST(madvise((void *)addr1, 4096, MADV_REMOVE));
>
> (void *) is not needed now ?
That shouldn't be needed for NULL.
>
> otherwise, looks OK to me.
+1, this looks better than hardcoding some random address.
>
> Thanks,
> Wanlong Gao
>
> > check_and_print("MADV_REMOVE");
> >
> > /* (2) Test case for MADV_DONTFORK */
> >
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond.
> Discussions
> will include endpoint security, mobile security and the latest in
> malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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 1/1] madvise03: let the system select an address for shmat()
2012-08-03 6:38 ` Jan Stancek
@ 2012-08-03 9:21 ` Simon Xu
2012-08-03 9:24 ` Wanlong Gao
0 siblings, 1 reply; 5+ messages in thread
From: Simon Xu @ 2012-08-03 9:21 UTC (permalink / raw)
To: Jan Stancek, gaowanlong; +Cc: ltp-list
On 2012/8/3 14:38, Jan Stancek wrote:
> ----- Original Message -----
>> From: "Wanlong Gao" <gaowanlong@cn.fujitsu.com>
>> To: "Simon Xu" <xu.simon@oracle.com>
>> Cc: ltp-list@lists.sourceforge.net
>> Sent: Friday, 3 August, 2012 5:46:31 AM
>> Subject: Re: [LTP] [PATCH 1/1] madvise03: let the system select an address for shmat()
>>
>> On 08/03/2012 12:53 AM, Simon Xu wrote:
>>> In certain occasions, 0x22000000 is invalid for shmat() and
>>> madvise03 fails:
>>>
>>> madvise03 1 TBROK : shmat error
>>> madvise03 2 TBROK : Remaining cases broken
>>>
>>> Use `NULL' for shmat() to let the system attach the shared memory
>>> segment
>>> at the first available address.
>>>
>>> Signed-off-by: Simon Xu <xu.simon@oracle.com>
>>> ---
>>> testcases/kernel/syscalls/madvise/madvise03.c | 6 +++---
>>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/testcases/kernel/syscalls/madvise/madvise03.c
>>> b/testcases/kernel/syscalls/madvise/madvise03.c
>>> index 2e696e8..fd0bd97 100644
>>> --- a/testcases/kernel/syscalls/madvise/madvise03.c
>>> +++ b/testcases/kernel/syscalls/madvise/madvise03.c
>>> @@ -154,13 +154,13 @@ int main(int argc, char *argv[])
>>> if (shmid1 == -1)
>>> tst_brkm(TBROK, cleanup, "shmget failed");
>>>
>>> - /* Attach shared memory segment to 0x22000000 address */
>>> - addr1 = shmat(shmid1, (void *)0x22000000, 0);
>>> + /* Attach shared memory segment to an address selected by the
>>> system */
>>> + addr1 = shmat(shmid1, NULL, 0);
>>> if (addr1 == (void *) -1)
>>> tst_brkm(TBROK, cleanup, "shmat error");
>>>
>>> /* (1) Test case for MADV_REMOVE */
>>> - TEST(madvise((void *)0x22000000, 4096, MADV_REMOVE));
>>> + TEST(madvise((void *)addr1, 4096, MADV_REMOVE));
>> (void *) is not needed now ?
> That shouldn't be needed for NULL.
addr1 is the return value of shmat(), whose return value type is void
*. Yes, `(void *)' is no longer needed. Thanks for pointing this out.
Thanks
Simon
>> otherwise, looks OK to me.
> +1, this looks better than hardcoding some random address.
>
>> Thanks,
>> Wanlong Gao
>>
>>> check_and_print("MADV_REMOVE");
>>>
>>> /* (2) Test case for MADV_DONTFORK */
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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 1/1] madvise03: let the system select an address for shmat()
2012-08-03 9:21 ` Simon Xu
@ 2012-08-03 9:24 ` Wanlong Gao
0 siblings, 0 replies; 5+ messages in thread
From: Wanlong Gao @ 2012-08-03 9:24 UTC (permalink / raw)
To: Simon Xu; +Cc: ltp-list
On 08/03/2012 05:21 PM, Simon Xu wrote:
> On 2012/8/3 14:38, Jan Stancek wrote:
>> ----- Original Message -----
>>> From: "Wanlong Gao" <gaowanlong@cn.fujitsu.com>
>>> To: "Simon Xu" <xu.simon@oracle.com>
>>> Cc: ltp-list@lists.sourceforge.net
>>> Sent: Friday, 3 August, 2012 5:46:31 AM
>>> Subject: Re: [LTP] [PATCH 1/1] madvise03: let the system select an address for shmat()
>>>
>>> On 08/03/2012 12:53 AM, Simon Xu wrote:
>>>> In certain occasions, 0x22000000 is invalid for shmat() and
>>>> madvise03 fails:
>>>>
>>>> madvise03 1 TBROK : shmat error
>>>> madvise03 2 TBROK : Remaining cases broken
>>>>
>>>> Use `NULL' for shmat() to let the system attach the shared memory
>>>> segment
>>>> at the first available address.
>>>>
>>>> Signed-off-by: Simon Xu <xu.simon@oracle.com>
>>>> ---
>>>> testcases/kernel/syscalls/madvise/madvise03.c | 6 +++---
>>>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/testcases/kernel/syscalls/madvise/madvise03.c
>>>> b/testcases/kernel/syscalls/madvise/madvise03.c
>>>> index 2e696e8..fd0bd97 100644
>>>> --- a/testcases/kernel/syscalls/madvise/madvise03.c
>>>> +++ b/testcases/kernel/syscalls/madvise/madvise03.c
>>>> @@ -154,13 +154,13 @@ int main(int argc, char *argv[])
>>>> if (shmid1 == -1)
>>>> tst_brkm(TBROK, cleanup, "shmget failed");
>>>> - /* Attach shared memory segment to 0x22000000 address */
>>>> - addr1 = shmat(shmid1, (void *)0x22000000, 0);
>>>> + /* Attach shared memory segment to an address selected by the
>>>> system */
>>>> + addr1 = shmat(shmid1, NULL, 0);
>>>> if (addr1 == (void *) -1)
>>>> tst_brkm(TBROK, cleanup, "shmat error");
>>>> /* (1) Test case for MADV_REMOVE */
>>>> - TEST(madvise((void *)0x22000000, 4096, MADV_REMOVE));
>>>> + TEST(madvise((void *)addr1, 4096, MADV_REMOVE));
>>> (void *) is not needed now ?
>> That shouldn't be needed for NULL.
>
> addr1 is the return value of shmat(), whose return value type is void *. Yes, `(void *)' is no longer needed. Thanks for pointing this out.
OK, I can make a snip change for this and push this patch, no need to send a V2.
Thank you Simon.
Wanlong Gao
>
>
> Thanks
> Simon
>
>>> otherwise, looks OK to me.
>> +1, this looks better than hardcoding some random address.
>>
>>> Thanks,
>>> Wanlong Gao
>>>
>>>> check_and_print("MADV_REMOVE");
>>>> /* (2) Test case for MADV_DONTFORK */
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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:[~2012-08-03 9:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-02 16:53 [LTP] [PATCH 1/1] madvise03: let the system select an address for shmat() Simon Xu
2012-08-03 3:46 ` Wanlong Gao
2012-08-03 6:38 ` Jan Stancek
2012-08-03 9:21 ` Simon Xu
2012-08-03 9:24 ` Wanlong Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox