From: bugzilla@dpdk.org
To: dev@dpdk.org
Subject: [DPDK/ethdev Bug 1876] enic: pthread mutex in shared memory missing PTHREAD_PROCESS_SHARED (
Date: Fri, 30 Jan 2026 16:36:38 +0000 [thread overview]
Message-ID: <bug-1876-3@http.bugs.dpdk.org/> (raw)
http://bugs.dpdk.org/show_bug.cgi?id=1876
Bug ID: 1876
Summary: enic: pthread mutex in shared memory missing
PTHREAD_PROCESS_SHARED (
Product: DPDK
Version: 25.11
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: ethdev
Assignee: dev@dpdk.org
Reporter: stephen@networkplumber.org
Target Milestone: ---
This the enic driver portion of existing bug 662
The enic driver has a pthread mutex in shared memory that is initialized
without `PTHREAD_PROCESS_SHARED`, which causes undefined behavior when used
across multiple processes.
### Affected Mutex
1. **`enic->admin_chan_lock`** (`drivers/net/enic/enic_sriov.c`, line 352)
- Location: `struct enic` (device private data)
- Purpose: Protects SR-IOV admin channel operations between VF and PF
### Why This Is a Problem
The `struct enic` is the device private data accessed via
`eth_dev->data->dev_private`, which resides in shared memory accessible by both
primary and secondary processes.
The mutex is initialized in `enic_enable_vf_admin_chan()`:
```c
pthread_mutex_init(&enic->admin_chan_lock, NULL);
```
And used to protect admin channel operations:
```c
static void lock_admin_chan(struct enic *enic)
{
pthread_mutex_lock(&enic->admin_chan_lock);
}
static void unlock_admin_chan(struct enic *enic)
{
pthread_mutex_unlock(&enic->admin_chan_lock);
}
```
Per POSIX, mutexes in shared memory accessed by multiple processes must be
initialized with `PTHREAD_PROCESS_SHARED` attribute. Without this,
synchronization between processes is undefined behavior.
### Suggested Fix
Initialize the mutex with `PTHREAD_PROCESS_SHARED`:
```c
static void
enic_init_shared_mutex(pthread_mutex_t *mutex)
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
pthread_mutex_init(mutex, &attr);
pthread_mutexattr_destroy(&attr);
}
```
Then replace:
```c
pthread_mutex_init(&enic->admin_chan_lock, NULL);
```
With:
```c
enic_init_shared_mutex(&enic->admin_chan_lock);
```
--
You are receiving this mail because:
You are the assignee for the bug.
reply other threads:[~2026-01-30 16:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-1876-3@http.bugs.dpdk.org/ \
--to=bugzilla@dpdk.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox