Browse Source

Merge branch 'freebsd/current/master' into hardened/current/master

* freebsd/current/master:
  Update the man page to reflect that "-M" and "-N" are deprecated and ignored.
  The map-entry clipping functions modify start and end entries of an entry in the vm_map, making invariants related to the max_free entry field invalid. Move the clipping work into vm_map_entry_link, so that linking is okay when the new entry clips a current entry, and the vm_map doesn't have to be briefly corrupted. Change assertions and conditions in SPLAY_{LEFT,RIGHT}_STEP since the max_free invariants can now be trusted in all cases.
  Get rid of old nfsstat options no longer used.
  Add basic getcpu(2) support to linuxulator.  The purpose of this syscall is to query the CPU number and the NUMA domain the calling thread is currently running on.  The third argument is ignored. It doesn't do anything regarding scheduling - it's literally just a way to query the current state, without any guarantees you won't get rescheduled an opcode later.
  Relax locking of carp_forus().
  Fix NOINET6 build broken by r356236.
hardened/current/master
HardenedBSD Sync Service 6 months ago
parent
commit
9ede8d9ce9
10 changed files with 87 additions and 55 deletions
  1. +0
    -2
      sys/amd64/linux/linux_dummy.c
  2. +0
    -2
      sys/amd64/linux32/linux32_dummy.c
  3. +0
    -2
      sys/arm64/linux/linux_dummy.c
  4. +16
    -0
      sys/compat/linux/linux_misc.c
  5. +0
    -2
      sys/i386/linux/linux_dummy.c
  6. +3
    -1
      sys/net/rtsock.c
  7. +4
    -3
      sys/netinet/ip_carp.c
  8. +57
    -16
      sys/vm/vm_map.c
  9. +3
    -15
      usr.bin/nfsstat/nfsstat.1
  10. +4
    -12
      usr.bin/nfsstat/nfsstat.c

+ 0
- 2
sys/amd64/linux/linux_dummy.c View File

@@ -102,8 +102,6 @@ DUMMY(tee);
DUMMY(vmsplice);
/* Linux 2.6.18: */
DUMMY(move_pages);
/* Linux 2.6.19: */
DUMMY(getcpu);
/* Linux 2.6.22: */
DUMMY(signalfd);
/* Linux 2.6.27: */

+ 0
- 2
sys/amd64/linux32/linux32_dummy.c View File

@@ -108,8 +108,6 @@ DUMMY(tee);
DUMMY(vmsplice);
/* Linux 2.6.18: */
DUMMY(move_pages);
/* Linux 2.6.19: */
DUMMY(getcpu);
/* Linux 2.6.22: */
DUMMY(signalfd);
/* Linux 2.6.27: */

+ 0
- 2
sys/arm64/linux/linux_dummy.c View File

@@ -104,8 +104,6 @@ DUMMY(tee);
DUMMY(vmsplice);
/* Linux 2.6.18: */
DUMMY(move_pages);
/* Linux 2.6.19: */
DUMMY(getcpu);
/* Linux 2.6.27: */
DUMMY(signalfd4);
DUMMY(inotify_init1);

+ 16
- 0
sys/compat/linux/linux_misc.c View File

@@ -2353,3 +2353,19 @@ out:
td->td_retval[0] = dst - args->buf;
return (error);
}

int
linux_getcpu(struct thread *td, struct linux_getcpu_args *args)
{
int cpu, error, node;

cpu = td->td_oncpu; /* Make sure it doesn't change during copyout(9) */
error = 0;
node = 0; /* XXX: Fake NUMA node 0 for now */

if (args->cpu != NULL)
error = copyout(&cpu, args->cpu, sizeof(l_int));
if (args->node != NULL)
error = copyout(&node, args->node, sizeof(l_int));
return (error);
}

+ 0
- 2
sys/i386/linux/linux_dummy.c View File

@@ -104,8 +104,6 @@ DUMMY(tee);
DUMMY(vmsplice);
/* Linux 2.6.18: */
DUMMY(move_pages);
/* Linux 2.6.19: */
DUMMY(getcpu);
/* Linux 2.6.22: */
DUMMY(signalfd);
/* Linux 2.6.27: */

+ 3
- 1
sys/net/rtsock.c View File

@@ -841,9 +841,9 @@ route_output(struct mbuf *m, struct socket *so, ...)
struct rt_msghdr *rtm = NULL;
struct rtentry *rt = NULL;
struct rt_addrinfo info;
struct sockaddr_storage ss;
struct epoch_tracker et;
#ifdef INET6
struct sockaddr_storage ss;
struct sockaddr_in6 *sin6;
int i, rti_need_deembed = 0;
#endif
@@ -968,7 +968,9 @@ report:
* writing updated rtm in rtsock_msg_buffer().
* With that in mind, skip deembedding procedure below.
*/
#ifdef INET6
rti_need_deembed = 0;
#endif
RT_UNLOCK(rt);
if (error != 0)
senderr(error);

+ 4
- 3
sys/netinet/ip_carp.c View File

@@ -1230,14 +1230,15 @@ carp_forus(struct ifnet *ifp, u_char *dhost)

CIF_LOCK(ifp->if_carp);
IFNET_FOREACH_CARP(ifp, sc) {
CARP_LOCK(sc);
/*
* CARP_LOCK() is not here, since would protect nothing, but
* cause deadlock with if_bridge, calling this under its lock.
*/
if (sc->sc_state == MASTER && !bcmp(dhost, LLADDR(&sc->sc_addr),
ETHER_ADDR_LEN)) {
CARP_UNLOCK(sc);
CIF_UNLOCK(ifp->if_carp);
return (1);
}
CARP_UNLOCK(sc);
}
CIF_UNLOCK(ifp->if_carp);


+ 57
- 16
sys/vm/vm_map.c View File

@@ -1044,9 +1044,11 @@ vm_size_max(vm_size_t a, vm_size_t b)
*/ \
y = root->left; \
max_free = root->max_free; \
KASSERT(max_free >= vm_map_entry_max_free_right(root, rlist), \
KASSERT(max_free == vm_size_max( \
vm_map_entry_max_free_left(root, llist), \
vm_map_entry_max_free_right(root, rlist)), \
("%s: max_free invariant fails", __func__)); \
if (y == llist ? max_free > 0 : max_free - 1 < y->max_free) \
if (max_free - 1 < vm_map_entry_max_free_left(root, llist)) \
max_free = vm_map_entry_max_free_right(root, rlist); \
if (y != llist && (test)) { \
/* Rotate right and make y root. */ \
@@ -1083,9 +1085,11 @@ vm_size_max(vm_size_t a, vm_size_t b)
*/ \
y = root->right; \
max_free = root->max_free; \
KASSERT(max_free >= vm_map_entry_max_free_left(root, llist), \
KASSERT(max_free == vm_size_max( \
vm_map_entry_max_free_left(root, llist), \
vm_map_entry_max_free_right(root, rlist)), \
("%s: max_free invariant fails", __func__)); \
if (y == rlist ? max_free > 0 : max_free - 1 < y->max_free) \
if (max_free - 1 < vm_map_entry_max_free_right(root, rlist)) \
max_free = vm_map_entry_max_free_left(root, llist); \
if (y != rlist && (test)) { \
/* Rotate left and make y root. */ \
@@ -1372,12 +1376,17 @@ vm_map_splay(vm_map_t map, vm_offset_t addr)
/*
* vm_map_entry_{un,}link:
*
* Insert/remove entries from maps.
* Insert/remove entries from maps. On linking, if new entry clips
* existing entry, trim existing entry to avoid overlap, and manage
* offsets. On unlinking, merge disappearing entry with neighbor, if
* called for, and manage offsets. Callers should not modify fields in
* entries already mapped.
*/
static void
vm_map_entry_link(vm_map_t map, vm_map_entry_t entry)
{
vm_map_entry_t header, llist, rlist, root;
vm_size_t max_free_left, max_free_right;

CTR3(KTR_VM,
"vm_map_entry_link: map %p, nentries %d, entry %p", map,
@@ -1386,13 +1395,48 @@ vm_map_entry_link(vm_map_t map, vm_map_entry_t entry)
map->nentries++;
header = &map->header;
root = vm_map_splay_split(map, entry->start, 0, &llist, &rlist);
KASSERT(root == NULL,
("vm_map_entry_link: link object already mapped"));
root = entry;
root->max_free = vm_size_max(
vm_map_splay_merge_pred(header, root, llist),
vm_map_splay_merge_succ(header, root, rlist));
map->root = root;
if (root == NULL) {
/*
* The new entry does not overlap any existing entry in the
* map, so it becomes the new root of the map tree.
*/
max_free_left = vm_map_splay_merge_pred(header, entry, llist);
max_free_right = vm_map_splay_merge_succ(header, entry, rlist);
} else if (entry->start == root->start) {
/*
* The new entry is a clone of root, with only the end field
* changed. The root entry will be shrunk to abut the new
* entry, and will be the right child of the new root entry in
* the modified map.
*/
KASSERT(entry->end < root->end,
("%s: clip_start not within entry", __func__));
vm_map_splay_findprev(root, &llist);
root->offset += entry->end - root->start;
root->start = entry->end;
max_free_left = vm_map_splay_merge_pred(header, entry, llist);
max_free_right = root->max_free = vm_size_max(
vm_map_splay_merge_pred(entry, root, entry),
vm_map_splay_merge_right(header, root, rlist));
} else {
/*
* The new entry is a clone of root, with only the start field
* changed. The root entry will be shrunk to abut the new
* entry, and will be the left child of the new root entry in
* the modified map.
*/
KASSERT(entry->end == root->end,
("%s: clip_start not within entry", __func__));
vm_map_splay_findnext(root, &rlist);
entry->offset += entry->start - root->start;
root->end = entry->start;
max_free_left = root->max_free = vm_size_max(
vm_map_splay_merge_left(header, root, llist),
vm_map_splay_merge_succ(entry, root, entry));
max_free_right = vm_map_splay_merge_succ(header, entry, rlist);
}
entry->max_free = vm_size_max(max_free_left, max_free_right);
map->root = entry;
VM_MAP_ASSERT_CONSISTENT(map);
}

@@ -2377,8 +2421,6 @@ _vm_map_clip_start(vm_map_t map, vm_map_entry_t entry, vm_offset_t start)
* so that this entry has the specified starting address.
*/
new_entry->end = start;
entry->offset += (start - entry->start);
entry->start = start;
vm_map_entry_link(map, new_entry);
}

@@ -2414,8 +2456,7 @@ _vm_map_clip_end(vm_map_t map, vm_map_entry_t entry, vm_offset_t end)
* Split off the back portion. Insert the new entry AFTER this one,
* so that this entry has the specified ending address.
*/
new_entry->start = entry->end = end;
new_entry->offset += (end - entry->start);
new_entry->start = end;
vm_map_entry_link(map, new_entry);
}


+ 3
- 15
usr.bin/nfsstat/nfsstat.1 View File

@@ -28,7 +28,7 @@
.\" From: @(#)nfsstat.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
.Dd December 21, 2019
.Dd December 31, 2019
.Dt NFSSTAT 1
.Os
.Sh NAME
@@ -40,8 +40,6 @@ statistics
.Nm
.Op Fl -libxo
.Op Fl cdEemszW
.Op Fl M Ar core
.Op Fl N Ar system
.Op Fl w Ar wait
.Sh DESCRIPTION
The
@@ -94,17 +92,14 @@ or
.Fl E
can be specified.
.It Fl M
Extract values associated with the name list from the specified core
instead of the default
.Pa /dev/kmem .
Deprecated and ignored.
.It Fl m
Report the mount options for all NFS client mounts.
This option overrides all others and
.Nm
will exit after completing the report.
.It Fl N
Extract the name list from the specified system instead of the default
.Pa /boot/kernel/kernel .
Deprecated and ignored.
.It Fl s
Only display server side statistics.
.It Fl W
@@ -134,13 +129,6 @@ See
.Xr xo_parse_args 3
for details on command line arguments.
.El
.Sh FILES
.Bl -tag -width ".Pa /boot/kernel/kernel" -compact
.It Pa /boot/kernel/kernel
default kernel namelist
.It Pa /dev/kmem
default memory file
.El
.Sh SEE ALSO
.Xr fstat 1 ,
.Xr netstat 1 ,

+ 4
- 12
usr.bin/nfsstat/nfsstat.c View File

@@ -149,14 +149,12 @@ main(int argc, char **argv)
int serverOnly = -1;
int newStats = 0;
int ch;
char *memf, *nlistf;
int mntlen, i;
char buf[1024];
struct statfs *mntbuf;
struct nfscl_dumpmntopts dumpmntopts;

interval = 0;
memf = nlistf = NULL;

argc = xo_parse_args(argc, argv);
if (argc < 0)
@@ -167,7 +165,7 @@ main(int argc, char **argv)
while ((ch = getopt(argc, argv, "cdEesWM:mN:w:zq")) != -1)
switch(ch) {
case 'M':
memf = optarg;
printf("*** -M option deprecated, ignored\n\n");
break;
case 'm':
/* Display mount options for NFS mount points. */
@@ -191,7 +189,7 @@ main(int argc, char **argv)
}
exit(0);
case 'N':
nlistf = optarg;
printf("*** -N option deprecated, ignored\n\n");
break;
case 'W':
widemode = 1;
@@ -239,14 +237,8 @@ main(int argc, char **argv)

#define BACKWARD_COMPATIBILITY
#ifdef BACKWARD_COMPATIBILITY
if (*argv) {
if (*argv)
interval = atoi(*argv);
if (*++argv) {
nlistf = *argv;
if (*++argv)
memf = *argv;
}
}
#endif
if (modfind("nfscommon") < 0)
xo_err(1, "NFS client/server not loaded");
@@ -529,7 +521,7 @@ static void
usage(void)
{
(void)fprintf(stderr,
"usage: nfsstat [-cdemszW] [-M core] [-N system] [-w wait]\n");
"usage: nfsstat [-cdemszW] [-w wait]\n");
exit(1);
}


Loading…
Cancel
Save