Browse Source

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

* freebsd/current/master:
  Speed up "zpool import" in the presence of many zvols
  tests: Test for an epair panic
  epair: Do not abuse params to register the second interface
  Merge r357231 from the clang1000-import branch:
  Merge r357225 from the clang1000-import branch:
  Merge r357224 from the clang1000-import branch:
  Merge r357222 from the clang1000-import branch:
  Fix urldecode buffer overrun.
  geli: add a test case for attaching multiple providers with 1 command
  amd64: revamp memcmp
hardened/current/master
HardenedBSD Sync Service 5 months ago
parent
commit
28e6573acd
13 changed files with 355 additions and 126 deletions
  1. +12
    -0
      cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
  2. +14
    -14
      contrib/binutils/bfd/peicode.h
  3. +8
    -2
      lib/libfetch/fetch.c
  4. +2
    -1
      libexec/rbootd/rmpproto.c
  5. +4
    -4
      sbin/newfs_msdos/newfs_msdos.c
  6. +1
    -1
      stand/i386/gptboot/gptldr.S
  7. +173
    -74
      sys/amd64/amd64/support.S
  8. +13
    -6
      sys/net/if_clone.c
  9. +2
    -1
      sys/net/if_clone.h
  10. +20
    -22
      sys/net/if_epair.c
  11. +31
    -0
      tests/sys/geom/class/eli/attach_test.sh
  12. +2
    -1
      tests/sys/net/Makefile
  13. +73
    -0
      tests/sys/net/if_epair.c

+ 12
- 0
cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c View File

@@ -1244,12 +1244,20 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
avl_tree_t slice_cache;
rdsk_node_t *slice;
void *cookie;
boolean_t skip_zvols = B_FALSE;
int value;
size_t size = sizeof(value);

if (dirs == 0) {
dirs = 1;
dir = &default_dir;
}

if (sysctlbyname("vfs.zfs.vol.recursive", &value, &size, NULL, 0) == 0
&& value == 0) {
skip_zvols = B_TRUE;
}

/*
* Go through and read the label configuration information from every
* possible device, organizing the information according to pool GUID
@@ -1314,6 +1322,10 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
}

LIST_FOREACH(mp, &mesh.lg_class, lg_class) {
if (skip_zvols &&
strcmp(mp->lg_name, "ZFS::ZVOL") == 0) {
continue;
}
LIST_FOREACH(gp, &mp->lg_geom, lg_geom) {
LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
slice = zfs_alloc(hdl, sizeof (rdsk_node_t));

+ 14
- 14
contrib/binutils/bfd/peicode.h View File

@@ -1353,13 +1353,13 @@ pe_bfd_object_p (bfd * abfd)
if (pe_arch (bfd_target_efi_arch (*target_ptr)) != arch)
continue;

if (efi)
{
/* TARGET_PTR is an EFI backend. Don't match
TARGET with a EFI file. */
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
if (efi)
{
/* TARGET_PTR is an EFI backend. Don't match
TARGET with a EFI file. */
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
}
else if (bfd_target_pei_p (*target_ptr))
{
@@ -1367,13 +1367,13 @@ pe_bfd_object_p (bfd * abfd)
if (pe_arch (bfd_target_pei_arch (*target_ptr)) != arch)
continue;

if (!efi)
{
/* TARGET_PTR is a PE backend. Don't match
TARGET with a PE file. */
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
if (!efi)
{
/* TARGET_PTR is a PE backend. Don't match
TARGET with a PE file. */
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
}
}
}

+ 8
- 2
lib/libfetch/fetch.c View File

@@ -332,6 +332,8 @@ fetch_pctdecode(char *dst, const char *src, size_t dlen)
}
if (dlen-- > 0)
*dst++ = c;
else
return (NULL);
}
return (s);
}
@@ -381,11 +383,15 @@ fetchParseURL(const char *URL)
if (p && *p == '@') {
/* username */
q = fetch_pctdecode(u->user, URL, URL_USERLEN);
if (q == NULL)
goto ouch;

/* password */
if (*q == ':')
if (*q == ':') {
q = fetch_pctdecode(u->pwd, q + 1, URL_PWDLEN);

if (q == NULL)
goto ouch;
}
p++;
} else {
p = URL;

+ 2
- 1
libexec/rbootd/rmpproto.c View File

@@ -332,7 +332,8 @@ SendBootRepl(struct rmp_packet *req, RMPCONN *rconn, char *filelist[])
* stripped file name and spoof the client into thinking that it
* really got what it wanted.
*/
filename = (filename = strrchr(filepath,'/'))? ++filename: filepath;
filename = strrchr(filepath,'/');
filename = filename? filename + 1: filepath;

/*
* Check that this is a valid boot file name.

+ 4
- 4
sbin/newfs_msdos/newfs_msdos.c View File

@@ -178,10 +178,10 @@ main(int argc, char *argv[])
argv += optind;
if (argc < 1 || argc > 2)
usage();
if (o.align) {
if (o.reserved_sectors)
errx(1, "align (-A) is incompatible with -r");
}
if (o.align) {
if (o.reserved_sectors)
errx(1, "align (-A) is incompatible with -r");
}
fname = *argv++;
if (!o.create_size && !strchr(fname, '/')) {
snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname);

+ 1
- 1
stand/i386/gptboot/gptldr.S View File

@@ -138,5 +138,5 @@ seta20.3: sti # Enable interrupts
* Save drive number from BIOS so boot2 can see it and start BTX.
*/
movb %dl,MEM_ARG
jmp MEM_JMP # Start BTX
jmp start+MEM_JMP-MEM_ORG # Start BTX
end:

+ 173
- 74
sys/amd64/amd64/support.S View File

@@ -111,92 +111,191 @@ END(sse2_pagezero)
*/
ENTRY(memcmp)
PUSH_FRAME_POINTER

xorl %eax,%eax
10:
cmpq $16,%rdx
jae 5f
ja 101632f

100816:
cmpb $8,%dl
jl 100408f
movq (%rdi),%r8
movq (%rsi),%r9
cmpq %r8,%r9
jne 1f
movq -8(%rdi,%rdx),%r8
movq -8(%rsi,%rdx),%r9
cmpq %r8,%r9
jne 10081608f
POP_FRAME_POINTER
ret
100408:
cmpb $4,%dl
jl 100204f
movl (%rsi),%r8d
movl (%rdi),%r9d
cmpl %r8d,%r9d
jne 1f
movl -4(%rsi,%rdx),%r8d
movl -4(%rdi,%rdx),%r9d
cmpl %r8d,%r9d
jne 1f
POP_FRAME_POINTER
ret
100204:
cmpb $2,%dl
jl 100001f
movzwl (%rsi),%r8d
movzwl (%rdi),%r9d
cmpl %r8d,%r9d
jne 1f
movzwl -2(%rsi,%rdx),%r8d
movzwl -2(%rdi,%rdx),%r9d
cmpl %r8d,%r9d
jne 1f
POP_FRAME_POINTER
ret
100001:
cmpb $1,%dl
jl 100000f
movzbl (%rdi),%r8d
movzbl (%rsi),%r9d
cmpb %r8b,%r9b
jne 1f
100000:
POP_FRAME_POINTER
ret
ALIGN_TEXT
101632:
cmpq $32,%rdx
ja 103200f
movq (%rdi),%r8
movq (%rsi),%r9
cmpq %r8,%r9
jne 1f
movq 8(%rdi),%r8
movq 8(%rsi),%r9
cmpq %r8,%r9
jne 10163208f
movq -16(%rdi,%rdx),%r8
movq -16(%rsi,%rdx),%r9
cmpq %r8,%r9
jne 10163216f
movq -8(%rdi,%rdx),%r8
movq -8(%rsi,%rdx),%r9
cmpq %r8,%r9
jne 10163224f
POP_FRAME_POINTER
ret
ALIGN_TEXT
103200:
movq (%rdi),%r8
movq 8(%rdi),%r9
subq (%rsi),%r8
subq 8(%rsi),%r9
or %r8,%r9
jnz 10320000f

movq 16(%rdi),%r8
movq 24(%rdi),%r9
subq 16(%rsi),%r8
subq 24(%rsi),%r9
or %r8,%r9
jnz 10320016f

leaq 32(%rdi),%rdi
leaq 32(%rsi),%rsi
subq $32,%rdx
cmpq $32,%rdx
jae 103200b
cmpb $0,%dl
jne 10b
POP_FRAME_POINTER
ret

10320016:
leaq 16(%rdi),%rdi
leaq 16(%rsi),%rsi
10320000:
/*
* Mismatch was found within a 16 bytes range. The part of the routine
* which calculates it only operates on sizes up to 8 bytes. Find the
* right part.
*/
movq (%rdi),%r8
movq (%rsi),%r9
cmpq %r8,%r9
jne 1f
leaq 8(%rdi),%rdi
leaq 8(%rsi),%rsi
jmp 1f
10163224:
leaq -8(%rdi,%rdx),%rdi
leaq -8(%rsi,%rdx),%rsi
jmp 1f
10163216:
leaq -16(%rdi,%rdx),%rdi
leaq -16(%rsi,%rdx),%rsi
jmp 1f
10163208:
10081608:
leaq 8(%rdi),%rdi
leaq 8(%rsi),%rsi
jmp 1f

/*
* Mismatch was found. We have no more than 8 bytes to inspect.
*/
ALIGN_TEXT
1:
testq %rdx,%rdx
je 3f
xorl %ecx,%ecx
2:
movzbl (%rdi,%rcx,1),%eax
movzbl (%rsi,%rcx,1),%r8d
movzbl (%rdi),%eax
movzbl (%rsi),%r8d
cmpb %r8b,%al
jne 4f
addq $1,%rcx
cmpq %rcx,%rdx
jz 3f
movzbl (%rdi,%rcx,1),%eax
movzbl (%rsi,%rcx,1),%r8d
jne 2f

movzbl 1(%rdi),%eax
movzbl 1(%rsi),%r8d
cmpb %r8b,%al
jne 4f
addq $1,%rcx
cmpq %rcx,%rdx
jz 3f
movzbl (%rdi,%rcx,1),%eax
movzbl (%rsi,%rcx,1),%r8d
jne 2f

movzbl 2(%rdi),%eax
movzbl 2(%rsi),%r8d
cmpb %r8b,%al
jne 4f
addq $1,%rcx
cmpq %rcx,%rdx
jz 3f
movzbl (%rdi,%rcx,1),%eax
movzbl (%rsi,%rcx,1),%r8d
jne 2f

movzbl 3(%rdi),%eax
movzbl 3(%rsi),%r8d
cmpb %r8b,%al
jne 4f
addq $1,%rcx
cmpq %rcx,%rdx
jne 2b
3:
jne 2f

movzbl 4(%rdi),%eax
movzbl 4(%rsi),%r8d
cmpb %r8b,%al
jne 2f

movzbl 5(%rdi),%eax
movzbl 5(%rsi),%r8d
cmpb %r8b,%al
jne 2f

movzbl 6(%rdi),%eax
movzbl 6(%rsi),%r8d
cmpb %r8b,%al
jne 2f

movzbl 7(%rdi),%eax
movzbl 7(%rsi),%r8d
cmpb %r8b,%al
jne 2f

xorl %eax,%eax
POP_FRAME_POINTER
ret
4:
2:
subl %r8d,%eax
POP_FRAME_POINTER
ret
5:
cmpq $32,%rdx
jae 7f
6:
/*
* 8 bytes
*/
movq (%rdi),%r8
movq (%rsi),%r9
cmpq %r8,%r9
jne 1b
leaq 8(%rdi),%rdi
leaq 8(%rsi),%rsi
subq $8,%rdx
cmpq $8,%rdx
jae 6b
jl 1b
jmp 3b
7:
/*
* 32 bytes
*/
movq (%rsi),%r8
movq 8(%rsi),%r9
subq (%rdi),%r8
subq 8(%rdi),%r9
or %r8,%r9
jnz 1b

movq 16(%rsi),%r8
movq 24(%rsi),%r9
subq 16(%rdi),%r8
subq 24(%rdi),%r9
or %r8,%r9
jnz 1b

leaq 32(%rdi),%rdi
leaq 32(%rsi),%rsi
subq $32,%rdx
cmpq $32,%rdx
jae 7b
jnz 1b
jmp 3b
END(memcmp)

/*

+ 13
- 6
sys/net/if_clone.c View File

@@ -211,6 +211,18 @@ if_clone_create(char *name, size_t len, caddr_t params)
return (if_clone_createif(ifc, name, len, params));
}

void
if_clone_addif(struct if_clone *ifc, struct ifnet *ifp)
{

if ((ifc->ifc_flags & IFC_NOGROUP) == 0)
if_addgroup(ifp, ifc->ifc_name);

IF_CLONE_LOCK(ifc);
IFC_IFLIST_INSERT(ifc, ifp);
IF_CLONE_UNLOCK(ifc);
}

/*
* Create a clone network interface.
*/
@@ -233,12 +245,7 @@ if_clone_createif(struct if_clone *ifc, char *name, size_t len, caddr_t params)
if (ifp == NULL)
panic("%s: lookup failed for %s", __func__, name);

if ((ifc->ifc_flags & IFC_NOGROUP) == 0)
if_addgroup(ifp, ifc->ifc_name);

IF_CLONE_LOCK(ifc);
IFC_IFLIST_INSERT(ifc, ifp);
IF_CLONE_UNLOCK(ifc);
if_clone_addif(ifc, ifp);
}

return (err);

+ 2
- 1
sys/net/if_clone.h View File

@@ -79,7 +79,8 @@ int if_clone_list(struct if_clonereq *);
struct if_clone *if_clone_findifc(struct ifnet *);
void if_clone_addgroup(struct ifnet *, struct if_clone *);

/* The below interface used only by epair(4). */
/* The below interfaces are used only by epair(4). */
void if_clone_addif(struct if_clone *, struct ifnet *);
int if_clone_destroyif(struct if_clone *, struct ifnet *);

#endif /* _KERNEL */

+ 20
- 22
sys/net/if_epair.c View File

@@ -711,6 +711,21 @@ epair_clone_match(struct if_clone *ifc, const char *name)
return (1);
}

static void
epair_clone_add(struct if_clone *ifc, struct epair_softc *scb)
{
struct ifnet *ifp;
uint8_t eaddr[ETHER_ADDR_LEN]; /* 00:00:00:00:00:00 */

ifp = scb->ifp;
/* Copy epairNa etheraddr and change the last byte. */
memcpy(eaddr, scb->oifp->if_hw_addr, ETHER_ADDR_LEN);
eaddr[5] = 0x0b;
ether_ifattach(ifp, eaddr);

if_clone_addif(ifc, ifp);
}

static int
epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
{
@@ -723,24 +738,6 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
uint32_t hash;
uint8_t eaddr[ETHER_ADDR_LEN]; /* 00:00:00:00:00:00 */

/*
* We are abusing params to create our second interface.
* Actually we already created it and called if_clone_create()
* for it to do the official insertion procedure the moment we knew
* it cannot fail anymore. So just do attach it here.
*/
if (params) {
scb = (struct epair_softc *)params;
ifp = scb->ifp;
/* Copy epairNa etheraddr and change the last byte. */
memcpy(eaddr, scb->oifp->if_hw_addr, ETHER_ADDR_LEN);
eaddr[5] = 0x0b;
ether_ifattach(ifp, eaddr);
/* Correctly set the name for the cloner list. */
strlcpy(name, ifp->if_xname, len);
return (0);
}

/* Try to see if a special unit was requested. */
error = ifc_name2unit(name, &unit);
if (error != 0)
@@ -891,10 +888,11 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
if_setsendqready(ifp);
/* We need to play some tricks here for the second interface. */
strlcpy(name, epairname, len);
error = if_clone_create(name, len, (caddr_t)scb);
if (error)
panic("%s: if_clone_create() for our 2nd iface failed: %d",
__func__, error);

/* Correctly set the name for the cloner list. */
strlcpy(name, scb->ifp->if_xname, len);
epair_clone_add(ifc, scb);

scb->if_qflush = ifp->if_qflush;
ifp->if_qflush = epair_qflush;
ifp->if_transmit = epair_transmit;

+ 31
- 0
tests/sys/geom/class/eli/attach_test.sh View File

@@ -68,6 +68,36 @@ attach_r_cleanup()
geli_test_cleanup
}

atf_test_case attach_multiple cleanup
attach_multiple_head()
{
atf_set "descr" "geli attach can attach multiple providers"
atf_set "require.user" "root"
}
attach_multiple_body()
{
geli_test_setup

sectors=100
md0=$(attach_md -t malloc -s `expr $sectors + 1`)
md1=$(attach_md -t malloc -s `expr $sectors + 1`)
md2=$(attach_md -t malloc -s `expr $sectors + 1`)
atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none

atf_check geli init -B none -P -K keyfile ${md0}
atf_check geli init -B none -P -K keyfile ${md1}
atf_check geli init -B none -P -K keyfile ${md2}
atf_check geli attach -p -k keyfile ${md0} ${md1} ${md2}
# verify that it did create all 3 geli devices
atf_check -s exit:0 test -c /dev/${md0}.eli
atf_check -s exit:0 test -c /dev/${md1}.eli
atf_check -s exit:0 test -c /dev/${md2}.eli
}
attach_multiple_cleanup()
{
geli_test_cleanup
}

atf_test_case nokey cleanup
nokey_head()
{
@@ -95,5 +125,6 @@ atf_init_test_cases()
{
atf_add_test_case attach_d
atf_add_test_case attach_r
atf_add_test_case attach_multiple
atf_add_test_case nokey
}

+ 2
- 1
tests/sys/net/Makefile View File

@@ -9,6 +9,7 @@ ATF_TESTS_SH+= if_lagg_test
ATF_TESTS_SH+= if_clone_test
ATF_TESTS_SH+= if_tun_test
ATF_TESTS_SH+= if_vlan
ATF_TESTS_C+= if_epair

TESTS_SUBDIRS+= routing

@@ -18,7 +19,7 @@ TESTS_SUBDIRS+= routing
TEST_METADATA+= is_exclusive=true

MAN=
PROG= randsleep
PROGS+= randsleep

WARNS?= 6


+ 73
- 0
tests/sys/net/if_epair.c View File

@@ -0,0 +1,73 @@
/*-
* Copyright (c) 2020 Kristof Provost <kp@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/

#include <sys/ioctl.h>
#include <sys/linker.h>
#include <sys/module.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/types.h>

#include <net/if.h>

#include <fcntl.h>
#include <stdio.h>

#include <atf-c.h>

ATF_TC(params);
ATF_TC_HEAD(params, tc)
{
atf_tc_set_md_var(tc, "require.user", "root");
}

ATF_TC_BODY(params, tc)
{
struct ifreq ifr;
int s;

s = kldload("if_epair");
if (s != 0)
atf_tc_fail("Failed to load if_epair");

s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
atf_tc_fail("Failed to create socket");

bzero(&ifr, sizeof(ifr));
ifr.ifr_data = (caddr_t)-1;
(void) strlcpy(ifr.ifr_name, "epair", sizeof(ifr.ifr_name));

ioctl(s, SIOCIFCREATE2, &ifr);
}

ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, params);

return (atf_no_error());
}

Loading…
Cancel
Save