Sebastian Huber created a merge request: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1603

Project:Branches: sebhub/rtems:up/posix-mqueue-fixes to rtems/rtos/rtems:main
Author: Sebastian Huber

## Summary

Issue #5835: mq_setattr() changes the access mode of a message queue

Issue #5836: mq_send() accepts the priority MQ_PRIO_MAX

**Problem:** `mq_setattr()` replaces the access mode of a message
queue, and `mq_send()` accepts the priority `MQ_PRIO_MAX`. Both
contradict POSIX.1-2024. The receive and send functions also read the
flags of a message queue before they acquire its lock, which races
with `mq_setattr()` on SMP configurations.

**Fix:** `mq_setattr()` changes only `O_NONBLOCK`, and the send
functions reject a priority which is not less than `MQ_PRIO_MAX`. A new
helper `_POSIX_Message_queue_Get_open()` returns the open message queue
with its lock held. It replaces five copies of the lookup and the open
check. The priority conversion loses a conditional.

**Review hints:**
- A receive through a descriptor which is not open now reports `EBADF`
  before `EMSGSIZE`.
- `psxmsgq01` lowers its priorities by one and checks the error at
  `MQ_PRIO_MAX`. Its `.scn` file follows.

## Test

The tip builds without warnings for `sparc/gr740` with all tests. On SIS,
`psxmsgq01` to `psxmsgq04`, `psxtmmq01`, `psxtmmqrcvblock01`,
`psxtmmqrcvblock02`, `psxclockrealtime01`, `psxconfig01`, `spthreadq01`
and `spsysinit01` pass. The output of `psxmsgq01` matches its `.scn`
file except for the times, the dates and the `mq_notify()` part, which
needs `RTEMS_POSIX_API`.

## AI Details
<!-- Make sure you have read our statement at 
https://www.rtems.org/generative-ai/ -->

### Prompt used

None as a single prompt. The work was done in an interactive Claude Code 
session on the RTEMS tree. The task was to review the specification of the 
POSIX message queues and to prepare their implementation for it. Each change 
was directed and reviewed.

### AI model used

Claude Opus 5.5 (claude-opus-5-5), through Claude Code.

### How AI was used for the contribution

- ( ) Formatting
- ( ) Test creation.
- (x) Code comments.
- ( ) The entire contribution was generated using AI
- ( ) AI code completion such as Copilot in VSCode.

The analysis, the changes and the commit messages were produced in that session 
under my direction.

### Access

I have not used a product which claims copyright in its output, and I have 
legitimate access to the one I used.

-- 
View it on GitLab: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1603
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/namespace/49/sent_notifications/6-5t5n0tf77ti6z18vpfklm026d-1d/unsubscribe
 | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | 
Help: https://gitlab.rtems.org/help


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to