Deleted Added
full compact
uipc_usrreq.c (109153) uipc_usrreq.c (109623)
1/*
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * From: @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94
1/*
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * From: @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94
34 * $FreeBSD: head/sys/kern/uipc_usrreq.c 109153 2003-01-13 00:33:17Z dillon $
34 * $FreeBSD: head/sys/kern/uipc_usrreq.c 109623 2003-01-21 08:56:16Z alfred $
35 */
36
37#include "opt_mac.h"
38
39#include <sys/param.h>
40#include <sys/domain.h>
41#include <sys/fcntl.h>
42#include <sys/malloc.h> /* XXX must be before <sys/file.h> */

--- 485 unchanged lines hidden (view full) ---

528 break;
529
530 default:
531 panic("unp_attach");
532 }
533 if (error)
534 return (error);
535 }
35 */
36
37#include "opt_mac.h"
38
39#include <sys/param.h>
40#include <sys/domain.h>
41#include <sys/fcntl.h>
42#include <sys/malloc.h> /* XXX must be before <sys/file.h> */

--- 485 unchanged lines hidden (view full) ---

528 break;
529
530 default:
531 panic("unp_attach");
532 }
533 if (error)
534 return (error);
535 }
536 unp = uma_zalloc(unp_zone, M_WAITOK);
536 unp = uma_zalloc(unp_zone, 0);
537 if (unp == NULL)
538 return (ENOBUFS);
539 bzero(unp, sizeof *unp);
540 unp->unp_gencnt = ++unp_gencnt;
541 unp_count++;
542 LIST_INIT(&unp->unp_refs);
543 unp->unp_socket = so;
544 FILEDESC_LOCK(curproc->p_fd);

--- 55 unchanged lines hidden (view full) ---

600
601 if (unp->unp_vnode != NULL)
602 return (EINVAL);
603
604 namelen = soun->sun_len - offsetof(struct sockaddr_un, sun_path);
605 if (namelen <= 0)
606 return EINVAL;
607
537 if (unp == NULL)
538 return (ENOBUFS);
539 bzero(unp, sizeof *unp);
540 unp->unp_gencnt = ++unp_gencnt;
541 unp_count++;
542 LIST_INIT(&unp->unp_refs);
543 unp->unp_socket = so;
544 FILEDESC_LOCK(curproc->p_fd);

--- 55 unchanged lines hidden (view full) ---

600
601 if (unp->unp_vnode != NULL)
602 return (EINVAL);
603
604 namelen = soun->sun_len - offsetof(struct sockaddr_un, sun_path);
605 if (namelen <= 0)
606 return EINVAL;
607
608 buf = malloc(namelen + 1, M_TEMP, M_WAITOK);
608 buf = malloc(namelen + 1, M_TEMP, 0);
609 strlcpy(buf, soun->sun_path, namelen + 1);
610
611restart:
612 NDINIT(&nd, CREATE, NOFOLLOW | LOCKPARENT | SAVENAME, UIO_SYSSPACE,
613 buf, td);
614/* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */
615 error = namei(&nd);
616 if (error) {

--- 226 unchanged lines hidden (view full) ---

843 }
844
845 if (req->newptr != 0)
846 return EPERM;
847
848 /*
849 * OK, now we're committed to doing something.
850 */
609 strlcpy(buf, soun->sun_path, namelen + 1);
610
611restart:
612 NDINIT(&nd, CREATE, NOFOLLOW | LOCKPARENT | SAVENAME, UIO_SYSSPACE,
613 buf, td);
614/* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */
615 error = namei(&nd);
616 if (error) {

--- 226 unchanged lines hidden (view full) ---

843 }
844
845 if (req->newptr != 0)
846 return EPERM;
847
848 /*
849 * OK, now we're committed to doing something.
850 */
851 xug = malloc(sizeof(*xug), M_TEMP, M_WAITOK);
851 xug = malloc(sizeof(*xug), M_TEMP, 0);
852 gencnt = unp_gencnt;
853 n = unp_count;
854
855 xug->xug_len = sizeof *xug;
856 xug->xug_count = n;
857 xug->xug_gen = gencnt;
858 xug->xug_sogen = so_gencnt;
859 error = SYSCTL_OUT(req, xug, sizeof *xug);
860 if (error) {
861 free(xug, M_TEMP);
862 return error;
863 }
864
852 gencnt = unp_gencnt;
853 n = unp_count;
854
855 xug->xug_len = sizeof *xug;
856 xug->xug_count = n;
857 xug->xug_gen = gencnt;
858 xug->xug_sogen = so_gencnt;
859 error = SYSCTL_OUT(req, xug, sizeof *xug);
860 if (error) {
861 free(xug, M_TEMP);
862 return error;
863 }
864
865 unp_list = malloc(n * sizeof *unp_list, M_TEMP, M_WAITOK);
865 unp_list = malloc(n * sizeof *unp_list, M_TEMP, 0);
866
867 for (unp = LIST_FIRST(head), i = 0; unp && i < n;
868 unp = LIST_NEXT(unp, unp_link)) {
869 if (unp->unp_gencnt <= gencnt) {
870 if (cr_cansee(req->td->td_ucred,
871 unp->unp_socket->so_cred))
872 continue;
873 unp_list[i++] = unp;
874 }
875 }
876 n = i; /* in case we lost some during malloc */
877
878 error = 0;
866
867 for (unp = LIST_FIRST(head), i = 0; unp && i < n;
868 unp = LIST_NEXT(unp, unp_link)) {
869 if (unp->unp_gencnt <= gencnt) {
870 if (cr_cansee(req->td->td_ucred,
871 unp->unp_socket->so_cred))
872 continue;
873 unp_list[i++] = unp;
874 }
875 }
876 n = i; /* in case we lost some during malloc */
877
878 error = 0;
879 xu = malloc(sizeof(*xu), M_TEMP, M_WAITOK);
879 xu = malloc(sizeof(*xu), M_TEMP, 0);
880 for (i = 0; i < n; i++) {
881 unp = unp_list[i];
882 if (unp->unp_gencnt <= gencnt) {
883 xu->xu_len = sizeof *xu;
884 xu->xu_unpp = unp;
885 /*
886 * XXX - need more locking here to protect against
887 * connect/disconnect races for SMP.

--- 486 unchanged lines hidden (view full) ---

1374 * descriptor. Then, we call sorflush ourself, since we know
1375 * it is a Unix domain socket anyhow. After we destroy all the
1376 * rights carried in messages, we do a last closef to get rid
1377 * of our extra reference. This is the last close, and the
1378 * unp_detach etc will shut down the socket.
1379 *
1380 * 91/09/19, bsy@cs.cmu.edu
1381 */
880 for (i = 0; i < n; i++) {
881 unp = unp_list[i];
882 if (unp->unp_gencnt <= gencnt) {
883 xu->xu_len = sizeof *xu;
884 xu->xu_unpp = unp;
885 /*
886 * XXX - need more locking here to protect against
887 * connect/disconnect races for SMP.

--- 486 unchanged lines hidden (view full) ---

1374 * descriptor. Then, we call sorflush ourself, since we know
1375 * it is a Unix domain socket anyhow. After we destroy all the
1376 * rights carried in messages, we do a last closef to get rid
1377 * of our extra reference. This is the last close, and the
1378 * unp_detach etc will shut down the socket.
1379 *
1380 * 91/09/19, bsy@cs.cmu.edu
1381 */
1382 extra_ref = malloc(nfiles * sizeof(struct file *), M_TEMP, M_WAITOK);
1382 extra_ref = malloc(nfiles * sizeof(struct file *), M_TEMP, 0);
1383 sx_slock(&filelist_lock);
1384 for (nunref = 0, fp = LIST_FIRST(&filehead), fpp = extra_ref; fp != 0;
1385 fp = nextfp) {
1386 nextfp = LIST_NEXT(fp, f_list);
1387 FILE_LOCK(fp);
1388 /*
1389 * If it's not open, skip it
1390 */

--- 128 unchanged lines hidden ---
1383 sx_slock(&filelist_lock);
1384 for (nunref = 0, fp = LIST_FIRST(&filehead), fpp = extra_ref; fp != 0;
1385 fp = nextfp) {
1386 nextfp = LIST_NEXT(fp, f_list);
1387 FILE_LOCK(fp);
1388 /*
1389 * If it's not open, skip it
1390 */

--- 128 unchanged lines hidden ---