git: 24df85d29a30 - main - unix/*: unp_internalize() can sleep, so allocate mbufs with M_WAITOK
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 09 May 2022 17:55:04 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=24df85d29a309522a4878bdf382696c7319ce898
commit 24df85d29a309522a4878bdf382696c7319ce898
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-05-09 17:42:48 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-05-09 17:42:48 +0000
unix/*: unp_internalize() can sleep, so allocate mbufs with M_WAITOK
---
sys/kern/uipc_usrreq.c | 49 ++++++++++++-------------------------------------
1 file changed, 12 insertions(+), 37 deletions(-)
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index f1b7dd75008d..3ce7ddcd7f17 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -2232,12 +2232,8 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
* Fill in credential information.
*/
case SCM_CREDS:
- *controlp = sbcreatecontrol(NULL, sizeof(*cmcred),
- SCM_CREDS, SOL_SOCKET);
- if (*controlp == NULL) {
- error = ENOBUFS;
- goto out;
- }
+ *controlp = sbcreatecontrol_how(NULL, sizeof(*cmcred),
+ SCM_CREDS, SOL_SOCKET, M_WAITOK);
cmcred = (struct cmsgcred *)
CMSG_DATA(mtod(*controlp, struct cmsghdr *));
cmcred->cmcred_pid = p->p_pid;
@@ -2280,13 +2276,8 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
* file structure and capability rights.
*/
newlen = oldfds * sizeof(fdep[0]);
- *controlp = sbcreatecontrol(NULL, newlen,
- SCM_RIGHTS, SOL_SOCKET);
- if (*controlp == NULL) {
- FILEDESC_SUNLOCK(fdesc);
- error = E2BIG;
- goto out;
- }
+ *controlp = sbcreatecontrol_how(NULL, newlen,
+ SCM_RIGHTS, SOL_SOCKET, M_WAITOK);
fdp = data;
for (i = 0; i < oldfds; i++, fdp++) {
if (!fhold(fdesc->fd_ofiles[*fdp].fde_file)) {
@@ -2317,48 +2308,32 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
break;
case SCM_TIMESTAMP:
- *controlp = sbcreatecontrol(NULL, sizeof(*tv),
- SCM_TIMESTAMP, SOL_SOCKET);
- if (*controlp == NULL) {
- error = ENOBUFS;
- goto out;
- }
+ *controlp = sbcreatecontrol_how(NULL, sizeof(*tv),
+ SCM_TIMESTAMP, SOL_SOCKET, M_WAITOK);
tv = (struct timeval *)
CMSG_DATA(mtod(*controlp, struct cmsghdr *));
microtime(tv);
break;
case SCM_BINTIME:
- *controlp = sbcreatecontrol(NULL, sizeof(*bt),
- SCM_BINTIME, SOL_SOCKET);
- if (*controlp == NULL) {
- error = ENOBUFS;
- goto out;
- }
+ *controlp = sbcreatecontrol_how(NULL, sizeof(*bt),
+ SCM_BINTIME, SOL_SOCKET, M_WAITOK);
bt = (struct bintime *)
CMSG_DATA(mtod(*controlp, struct cmsghdr *));
bintime(bt);
break;
case SCM_REALTIME:
- *controlp = sbcreatecontrol(NULL, sizeof(*ts),
- SCM_REALTIME, SOL_SOCKET);
- if (*controlp == NULL) {
- error = ENOBUFS;
- goto out;
- }
+ *controlp = sbcreatecontrol_how(NULL, sizeof(*ts),
+ SCM_REALTIME, SOL_SOCKET, M_WAITOK);
ts = (struct timespec *)
CMSG_DATA(mtod(*controlp, struct cmsghdr *));
nanotime(ts);
break;
case SCM_MONOTONIC:
- *controlp = sbcreatecontrol(NULL, sizeof(*ts),
- SCM_MONOTONIC, SOL_SOCKET);
- if (*controlp == NULL) {
- error = ENOBUFS;
- goto out;
- }
+ *controlp = sbcreatecontrol_how(NULL, sizeof(*ts),
+ SCM_MONOTONIC, SOL_SOCKET, M_WAITOK);
ts = (struct timespec *)
CMSG_DATA(mtod(*controlp, struct cmsghdr *));
nanouptime(ts);