shm_open_23-1: modified memory protection attributes

POSIX doesn't state that if mmap() is given only PROT_WRITE, then
that memory region will have read access too. It's an implementation
issue of the platform.

On a platform which don't imply read access when only PROT_WRITE is given,
such a situation happens:
  1) a child process decrements the semaphore with sem_wait(sem)
  2) then tries to dereference create_cnt via (*create_cnt)++. This
     will result in a SIGSEGV, and the child will be terminated.

Therefore the semaphore will be left in a "decremented" state and this
test case will hang.

To overcome this problem we should explicitly pass PROT_READ to mmap().

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
1 file changed