git: 0df8a998a9fe - main - qlnxe: Prevent potential concurrency between ioctls
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 06 Feb 2026 17:59:29 UTC
The branch main has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=0df8a998a9fe28af659cb401c537c6d785e55f81
commit 0df8a998a9fe28af659cb401c537c6d785e55f81
Author: Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2026-02-06 17:52:53 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2026-02-06 17:52:53 +0000
qlnxe: Prevent potential concurrency between ioctls
The driver-managed status flags should be lock protected to be touched.
Also this can serialize ioctls those check the IFF_DRV_RUNNING status.
Reviewed by: kbowling
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D54886
---
sys/dev/qlnx/qlnxe/qlnx_os.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/sys/dev/qlnx/qlnxe/qlnx_os.c b/sys/dev/qlnx/qlnxe/qlnx_os.c
index ec2fd7cacfae..b0dac3a82582 100644
--- a/sys/dev/qlnx/qlnxe/qlnx_os.c
+++ b/sys/dev/qlnx/qlnxe/qlnx_os.c
@@ -2568,9 +2568,7 @@ qlnx_set_multi(qlnx_host_t *ha, uint32_t add_multi)
mcnt = if_foreach_llmaddr(ifp, qlnx_copy_maddr, mta);
- QLNX_LOCK(ha);
qlnx_hw_set_multi(ha, mta, mcnt, add_multi);
- QLNX_UNLOCK(ha);
return (0);
}
@@ -2637,11 +2635,10 @@ qlnx_ioctl(if_t ifp, u_long cmd, caddr_t data)
#ifdef INET
if (ifa->ifa_addr->sa_family == AF_INET) {
if_setflagbits(ifp, IFF_UP, 0);
- if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) {
- QLNX_LOCK(ha);
+ QLNX_LOCK(ha);
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
qlnx_init_locked(ha);
- QLNX_UNLOCK(ha);
- }
+ QLNX_UNLOCK(ha);
QL_DPRINT4(ha, "SIOCSIFADDR (0x%lx) ipv4 [0x%08x]\n",
cmd, ntohl(IA_SIN(ifa)->sin_addr.s_addr));
@@ -2703,19 +2700,23 @@ qlnx_ioctl(if_t ifp, u_long cmd, caddr_t data)
case SIOCADDMULTI:
QL_DPRINT4(ha, "%s (0x%lx)\n", "SIOCADDMULTI", cmd);
- if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
+ QLNX_LOCK(ha);
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
if (qlnx_set_multi(ha, 1))
ret = EINVAL;
}
+ QLNX_UNLOCK(ha);
break;
case SIOCDELMULTI:
QL_DPRINT4(ha, "%s (0x%lx)\n", "SIOCDELMULTI", cmd);
- if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
+ QLNX_LOCK(ha);
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
if (qlnx_set_multi(ha, 0))
ret = EINVAL;
}
+ QLNX_UNLOCK(ha);
break;
case SIOCSIFMEDIA: