Page MenuHomeFreeBSD

System V standardized IPC syscalls concerned with manipulating semaphore sets
ClosedPublic

Authored by aniketp on Jun 19 2018, 3:57 AM.
Tags
None
Referenced Files
F83065902: D15897.id.diff
Sun, May 5, 7:58 PM
Unknown Object (File)
Fri, May 3, 8:45 PM
Unknown Object (File)
Sat, Apr 27, 8:43 PM
Unknown Object (File)
Fri, Apr 19, 3:44 PM
Unknown Object (File)
Fri, Apr 19, 3:40 PM
Unknown Object (File)
Mar 11 2024, 3:07 PM
Unknown Object (File)
Mar 11 2024, 3:07 PM
Unknown Object (File)
Mar 11 2024, 3:07 PM
Subscribers

Details

Summary

This revision introduces test cases for System V standardized system calls concerned
with creating and manipulating semaphore sets. These system calls are categorized
within inter-process-communication audit class (as expected).

System calls in question are:

  • semget(2)
  • semop(2)
  • semctl(2)

Note:
semctl(2) takes as argument a cmd which is a separate audit event in itself.
List of semctl(2) audit events:

  • AUE_SEMCTL [Illegal Command]
  • AUE_SEMCTL_GETALL
  • AUE_SEMCTL_GETNCNT
  • AUE_SEMCTL_GETZCNT
  • AUE_SEMCTL_GETPID
  • AUE_SEMCTL_GETVAL
  • AUE_SEMCTL_SETALL
  • AUE_SEMCTL_SETVAL
  • AUE_SEMCTL_STAT
  • AUE_SEMCTL_RMID
  • AUE_SEMCTL_SET

For full details, please see: sys/security/audit/audit_bsm_klib.c#L271

Each of them have been treated as separate audit events. (And hence, separate tests)

Test Plan

Execute make && make install from test/sys/audit.
Execute kyua test from /usr/tests/sys/audit. All testcases should succeed.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 17528
Build 17351: arc lint + arc unit

Event Timeline

asomers requested changes to this revision.Jun 19 2018, 4:14 PM
asomers added inline comments.
tests/sys/audit/inter-process.c
50

This is defined in sem.h. Don't redefine it here. Just #define _WANT_SEMUN before including sem.h.

54

IMHO, "arg" is too vague a name for a global variable.

777

There's actually nothing in the spec that says this should fail. However, the man page does say that semget should fail in either of the two following situations:

  • key is IPC_PRIVATE and nsems is <= 0
  • key is IPC_PRIVATE, and flags does not include IPC_CREAT.
807

sizeof(sop) would be safer.

855

arg->array is used uninitialized here. But GETVAL doesn't need the fourth argument, anyway.

958

GETPID does not require the fourth argument.

1009

GETNCNT doesn't require arg, either.

1164

semvals is used uninitialized.

1267

It makes no sense to initialize two fields of a union, because initializing the second one will wipe out the first.

This revision now requires changes to proceed.Jun 19 2018, 4:14 PM
aniketp marked 7 inline comments as done.

Replace arg with semarg; And some minor changes

tests/sys/audit/inter-process.c
1164

semvals would be filled up by the SETALL command. Man-page doesn't say we need to explicitely initialize it.

asomers requested changes to this revision.Jun 20 2018, 2:59 PM
asomers added inline comments.
tests/sys/audit/inter-process.c
855

Why don't you just remove the fourth argument and invoke it as semctl(semid, 0, GETVAL)?

1164

I don't see that at all. Are you thinking about GETALL?

This revision now requires changes to proceed.Jun 20 2018, 2:59 PM
  • Remove semarg from GETVAL, GETPID, GETZCNT, GETNCNT
  • Initialize semvals in SETALL by first calling GETALL
tests/sys/audit/inter-process.c
855

Oops! I had removed them from all GET* commands. Must have crept back it when I git stashed the changes.
Will remove them again.

Don't forget the _WANT_SEMUN change.

tests/sys/audit/inter-process.c
1388

Technically you're still using semarg uninitialized here. I recommend simply removing it.

Define _WANT_SEMUN instead of declaring union semun in the test program

This revision is now accepted and ready to land.Jun 22 2018, 12:54 AM
This revision was automatically updated to reflect the committed changes.