git: e39435733339 - stable/14 - rawip: Take the inpcb lock when appropriate in rip_ctloutput()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Jan 2025 14:43:38 UTC
The branch stable/14 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=e3943573333937b881d4b7839c0b7d8595753d21
commit e3943573333937b881d4b7839c0b7d8595753d21
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-01-07 02:20:05 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-01-14 14:14:35 +0000
rawip: Take the inpcb lock when appropriate in rip_ctloutput()
Reviewed by: glebius
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D48344
(cherry picked from commit fd94571ccf0c9c6521063c08a72a760873e87897)
---
sys/netinet/raw_ip.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 04b12b6587dd..c30878d48c74 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -627,8 +627,6 @@ rip_send(struct socket *so, int pruflags, struct mbuf *m, struct sockaddr *nam,
*
* When adding new socket options here, make sure to add access control
* checks here as necessary.
- *
- * XXX-BZ inp locking?
*/
int
rip_ctloutput(struct socket *so, struct sockopt *sopt)
@@ -639,7 +637,9 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt)
if (sopt->sopt_level != IPPROTO_IP) {
if ((sopt->sopt_level == SOL_SOCKET) &&
(sopt->sopt_name == SO_SETFIB)) {
+ INP_WLOCK(inp);
inp->inp_inc.inc_fibnum = so->so_fibnum;
+ INP_WUNLOCK(inp);
return (0);
}
return (EINVAL);
@@ -709,10 +709,12 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt)
sizeof optval);
if (error)
break;
+ INP_WLOCK(inp);
if (optval)
inp->inp_flags |= INP_HDRINCL;
else
inp->inp_flags &= ~INP_HDRINCL;
+ INP_WUNLOCK(inp);
break;
case IP_FW3: /* generic ipfw v.3 functions */