| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: procfs_linux.c,v 1.63 2011/12/16 20:45:07 christos Exp $ */ | | 1 | /* $NetBSD: procfs_linux.c,v 1.64 2011/12/19 03:02:31 christos Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2001 Wasabi Systems, Inc. | | 4 | * Copyright (c) 2001 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Frank van der Linden for Wasabi Systems, Inc. | | 7 | * Written by Frank van der Linden for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -26,27 +26,27 @@ | | | @@ -26,27 +26,27 @@ |
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | | 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC |
29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | * POSSIBILITY OF SUCH DAMAGE. | | 35 | * POSSIBILITY OF SUCH DAMAGE. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.63 2011/12/16 20:45:07 christos Exp $"); | | 39 | __KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.64 2011/12/19 03:02:31 christos Exp $"); |
40 | | | 40 | |
41 | #include <sys/param.h> | | 41 | #include <sys/param.h> |
42 | #include <sys/systm.h> | | 42 | #include <sys/systm.h> |
43 | #include <sys/time.h> | | 43 | #include <sys/time.h> |
44 | #include <sys/kernel.h> | | 44 | #include <sys/kernel.h> |
45 | #include <sys/proc.h> | | 45 | #include <sys/proc.h> |
46 | #include <sys/vnode.h> | | 46 | #include <sys/vnode.h> |
47 | #include <sys/exec.h> | | 47 | #include <sys/exec.h> |
48 | #include <sys/resource.h> | | 48 | #include <sys/resource.h> |
49 | #include <sys/resourcevar.h> | | 49 | #include <sys/resourcevar.h> |
50 | #include <sys/signal.h> | | 50 | #include <sys/signal.h> |
51 | #include <sys/signalvar.h> | | 51 | #include <sys/signalvar.h> |
52 | #include <sys/tty.h> | | 52 | #include <sys/tty.h> |
| @@ -583,45 +583,42 @@ procfs_format_sfs(char **mtab, size_t *m | | | @@ -583,45 +583,42 @@ procfs_format_sfs(char **mtab, size_t *m |
583 | *mtab = realloc(*mtab, *mlen + blen, M_TEMP, M_WAITOK); | | 583 | *mtab = realloc(*mtab, *mlen + blen, M_TEMP, M_WAITOK); |
584 | memcpy(*mtab + *mlen, buf, blen); | | 584 | memcpy(*mtab + *mlen, buf, blen); |
585 | *mlen += blen; | | 585 | *mlen += blen; |
586 | return sfs->f_mntonname[0] == '/' && sfs->f_mntonname[1] == '\0'; | | 586 | return sfs->f_mntonname[0] == '/' && sfs->f_mntonname[1] == '\0'; |
587 | } | | 587 | } |
588 | | | 588 | |
589 | int | | 589 | int |
590 | procfs_domounts(struct lwp *curl, struct proc *p, | | 590 | procfs_domounts(struct lwp *curl, struct proc *p, |
591 | struct pfsnode *pfs, struct uio *uio) | | 591 | struct pfsnode *pfs, struct uio *uio) |
592 | { | | 592 | { |
593 | char *bf, *mtab = NULL; | | 593 | char *bf, *mtab = NULL; |
594 | size_t mtabsz = 0; | | 594 | size_t mtabsz = 0; |
595 | struct mount *mp, *nmp; | | 595 | struct mount *mp, *nmp; |
596 | int error = 0, suser, root = 0; | | 596 | int error = 0, root = 0; |
597 | struct cwdinfo *cwdi = curl->l_proc->p_cwdi; | | 597 | struct cwdinfo *cwdi = curl->l_proc->p_cwdi; |
598 | | | 598 | |
599 | suser = kauth_authorize_generic(curl->l_cred, | | | |
600 | KAUTH_GENERIC_ISSUSER, NULL) == 0; | | | |
601 | | | | |
602 | bf = malloc(LBFSZ, M_TEMP, M_WAITOK); | | 599 | bf = malloc(LBFSZ, M_TEMP, M_WAITOK); |
603 | | | 600 | |
604 | mutex_enter(&mountlist_lock); | | 601 | mutex_enter(&mountlist_lock); |
605 | for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; | | 602 | for (mp = CIRCLEQ_FIRST(&mountlist); mp != (void *)&mountlist; |
606 | mp = nmp) { | | 603 | mp = nmp) { |
607 | struct statvfs sfs; | | 604 | struct statvfs sfs; |
608 | | | 605 | |
609 | if (vfs_busy(mp, &nmp)) | | 606 | if (vfs_busy(mp, &nmp)) |
610 | continue; | | 607 | continue; |
611 | | | 608 | |
612 | if ((error = dostatvfs(mp, &sfs, curl, MNT_WAIT, suser)) == 0) | | 609 | if ((error = dostatvfs(mp, &sfs, curl, MNT_WAIT, 0)) == 0) |
613 | root |= procfs_format_sfs(&mtab, &mtabsz, bf, LBFSZ, | | 610 | root |= procfs_format_sfs(&mtab, &mtabsz, bf, LBFSZ, |
614 | &sfs, curl, suser); | | 611 | &sfs, curl, 0); |
615 | | | 612 | |
616 | vfs_unbusy(mp, false, &nmp); | | 613 | vfs_unbusy(mp, false, &nmp); |
617 | } | | 614 | } |
618 | mutex_exit(&mountlist_lock); | | 615 | mutex_exit(&mountlist_lock); |
619 | | | 616 | |
620 | /* | | 617 | /* |
621 | * If we are inside a chroot that is not itself a mount point, | | 618 | * If we are inside a chroot that is not itself a mount point, |
622 | * fake a root entry. | | 619 | * fake a root entry. |
623 | */ | | 620 | */ |
624 | if (!root && cwdi->cwdi_rdir) | | 621 | if (!root && cwdi->cwdi_rdir) |
625 | (void)procfs_format_sfs(&mtab, &mtabsz, bf, LBFSZ, | | 622 | (void)procfs_format_sfs(&mtab, &mtabsz, bf, LBFSZ, |
626 | &cwdi->cwdi_rdir->v_mount->mnt_stat, curl, 1); | | 623 | &cwdi->cwdi_rdir->v_mount->mnt_stat, curl, 1); |
627 | | | 624 | |