Hi Cyril Any comments on this patch ?
Jin [email protected] wrote: > From: Wei Yang <[email protected]> > > > Hi, Please folks help me review the patch below. > > thanks > > The patch fixes upon the issue described by the subject above. > The funciton shmget(shkey++, INT_SIZE,...) and shmat() only > ensure that a page linear address range is avaiable. > shmat() will return base_addr aligned on a page boundary, > For x86 and ppc, since SHMLBA is equal to PAGE_SIZE, so the > base_addr returned by shmat() is the same as the base_addr > is aligned to next SHMLBA. But for mips architecture, > SHMLBA is not equal to PAGE_SIZE(SHMLBA > PAGE_SIZE) > so when base_addr is aligned to next SHMLBA address. base_addr will > expire a page range and the base_addr can already be used by the process, > then shmat(shkey, base_addr....) will return -1. > Therefore we should probe a bigger available virtual address space for > ensuring that base_addr aligned to next SHMLBA always is available. that is > the base_addr aligned to next SHMLBA is not used by the process. > > > Signed-off-by: Wei Yang <[email protected]> > --- > testcases/kernel/syscalls/ipc/shmat/shmat01.c | 27 +++++++++++++++++++++++- > 1 files changed, 25 insertions(+), 2 deletions(-) > > diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat01.c > b/testcases/kernel/syscalls/ipc/shmat/shmat01.c > index 7c68459..344ad3f 100644 > --- a/testcases/kernel/syscalls/ipc/shmat/shmat01.c > +++ b/testcases/kernel/syscalls/ipc/shmat/shmat01.c > @@ -65,6 +65,9 @@ void check_functionality(int); > #define CASE1 20 /* memory location. */ > > int shm_id_1 = -1; > +#if defined(__mips__) || defined(__mips64) > +int shm_id_2 = -1; > +#endif > > void *base_addr; /* By probing this address first, we can make > * non-aligned addresses from it for different > @@ -262,14 +265,34 @@ void setup(void) > tst_brkm(TBROK, cleanup, "Failed to create shared memory " > "resource 1 in setup()"); > } > - > /* Probe an available linear address for attachment */ > +#if defined(__mips__) || defined(__mips64) > + /* > + * For mips architecture, SHMLBA is not equal to PAGE_SIZE > + * base_addr is not available address for process after > + * base_addr is aligned to next SHMLBA address > + */ > + if ((shm_id_2 = shmget(shmkey++, SHMLBA, SHM_RW | IPC_CREAT | > IPC_EXCL)) == -1) { > + tst_brkm(TBROK, cleanup, "Failed to create shared memory "); > + } > + if ((base_addr = shmat(shm_id_2, NULL, 0)) == (void *) -1) { > + rm_shm(shm_id_2); > + tst_brkm(TBROK, cleanup, "Couldn't attach shared memory"); > + } > + if (shmdt((const void *)base_addr) == -1) { > + rm_shm(shm_id_2); > + tst_brkm(TBROK, cleanup, "Couldn't detach shared memory"); > + } > + rm_shm(shm_id_2); > +#else > if ((base_addr = shmat(shm_id_1, NULL, 0)) == (void *)-1) { > tst_brkm(TBROK, cleanup, "Couldn't attach shared memory"); > } > if (shmdt((const void *)base_addr) == -1) { > tst_brkm(TBROK, cleanup, "Couldn't detach shared memory"); > } > +#endif > + > > /* some architectures (e.g. parisc) are strange, so better always align > to > * next SHMLBA address. */ > @@ -299,4 +322,4 @@ void cleanup(void) > */ > TEST_CLEANUP; > > -} > \ No newline at end of file > +} ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
