svn commit: r362909 - in head: sys/netinet6 tests/sys/netinet6

2020-07-03 Thread Alexander V. Chernikov
Author: melifaro
Date: Fri Jul  3 08:06:26 2020
New Revision: 362909
URL: https://svnweb.freebsd.org/changeset/base/362909

Log:
  Fix IPv6 regression introduced by r362900.
  
  PR:   kern/247729

Modified:
  head/sys/netinet6/icmp6.c
  head/tests/sys/netinet6/redirect.sh

Modified: head/sys/netinet6/icmp6.c
==
--- head/sys/netinet6/icmp6.c   Fri Jul  3 07:25:26 2020(r362908)
+++ head/sys/netinet6/icmp6.c   Fri Jul  3 08:06:26 2020(r362909)
@@ -2277,7 +2277,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
in6_splitscope(&reddst6, &kdst, &scopeid);
NET_EPOCH_ASSERT();
nh = fib6_lookup(ifp->if_fib, &kdst, scopeid, 0, 0);
-   if (nh == NULL) {
+   if (nh != NULL) {
struct in6_addr nh_addr;
nh_addr = ifatoia6(nh->nh_ifa)->ia_addr.sin6_addr;
if ((nh->nh_flags & NHF_GATEWAY) == 0) {

Modified: head/tests/sys/netinet6/redirect.sh
==
--- head/tests/sys/netinet6/redirect.sh Fri Jul  3 07:25:26 2020
(r362908)
+++ head/tests/sys/netinet6/redirect.sh Fri Jul  3 08:06:26 2020
(r362909)
@@ -87,7 +87,15 @@ valid_redirect_body() {
local_ll_mac=`jexec ${jname} ifconfig ${epair}b ether | awk 
'$1~/ether/{print$2}'`
 
# wait for DAD to complete
-   sleep 2
+   while [ `ifconfig ${epair}a inet6 | grep -c tentative` != "0" ]; do
+   sleep 0.1
+   done
+   while [ `jexec ${jname}b ifconfig ${epair}b inet6 | grep -c tentative` 
!= "0" ]; do
+   sleep 0.1
+   done
+
+   # enable ND debugging in the target jail to ease catching errors
+   jexec ${jname} sysctl net.inet6.icmp6.nd6_debug=1
 
# echo "LOCAL: ${local_ll_ip} ${local_ll_mac}"
# echo "REMOTE: ${remote_rtr_ll_ip} ${remote_rtr_mac}"
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362910 - head/sys/kern

2020-07-03 Thread Mateusz Guzik
Author: mjg
Date: Fri Jul  3 09:23:11 2020
New Revision: 362910
URL: https://svnweb.freebsd.org/changeset/base/362910

Log:
  ifdef out pg_jobc assertions added in r361967
  
  They trigger for some people, the bug is not obvious, there are no takers
  for fixing it, the issue already had to be there for years beforehand and
  is low priority.

Modified:
  head/sys/kern/kern_proc.c

Modified: head/sys/kern/kern_proc.c
==
--- head/sys/kern/kern_proc.c   Fri Jul  3 08:06:26 2020(r362909)
+++ head/sys/kern/kern_proc.c   Fri Jul  3 09:23:11 2020(r362910)
@@ -731,10 +731,14 @@ pgadjustjobc(struct pgrp *pgrp, int entering)
 
PGRP_LOCK(pgrp);
if (entering) {
+#ifdef notyet
MPASS(pgrp->pg_jobc >= 0);
+#endif
pgrp->pg_jobc++;
} else {
+#ifdef notyet
MPASS(pgrp->pg_jobc > 0);
+#endif
--pgrp->pg_jobc;
if (pgrp->pg_jobc == 0)
orphanpg(pgrp);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362913 - in head/sys: amd64/amd64 amd64/include crypto/aesni crypto/blake2

2020-07-03 Thread Conrad Meyer
Author: cem
Date: Fri Jul  3 14:54:46 2020
New Revision: 362913
URL: https://svnweb.freebsd.org/changeset/base/362913

Log:
  Add domain policy allocation for amd64 fpu_kern_ctx
  
  Like other types of allocation, fpu_kern_ctx are frequently allocated per-cpu.
  Provide the API and sketch some example consumers.
  
  fpu_kern_alloc_ctx_domain() preferentially allocates memory from the
  provided domain, and falls back to other domains if that one is empty
  (DOMAINSET_PREF(domain) policy).
  
  Maybe it makes more sense to just shove one of these in the DPCPU area
  sooner or later -- left for future work.
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D22053

Modified:
  head/sys/amd64/amd64/fpu.c
  head/sys/amd64/include/fpu.h
  head/sys/crypto/aesni/aesni.c
  head/sys/crypto/blake2/blake2_cryptodev.c

Modified: head/sys/amd64/amd64/fpu.c
==
--- head/sys/amd64/amd64/fpu.c  Fri Jul  3 11:46:42 2020(r362912)
+++ head/sys/amd64/amd64/fpu.c  Fri Jul  3 14:54:46 2020(r362913)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1030,17 +1031,31 @@ struct fpu_kern_ctx {
char hwstate1[];
 };
 
+static inline size_t __pure2
+fpu_kern_alloc_sz(u_int max_est)
+{
+   return (sizeof(struct fpu_kern_ctx) + XSAVE_AREA_ALIGN + max_est);
+}
+
+static inline int __pure2
+fpu_kern_malloc_flags(u_int fpflags)
+{
+   return (((fpflags & FPU_KERN_NOWAIT) ? M_NOWAIT : M_WAITOK) | M_ZERO);
+}
+
 struct fpu_kern_ctx *
-fpu_kern_alloc_ctx(u_int flags)
+fpu_kern_alloc_ctx_domain(int domain, u_int flags)
 {
-   struct fpu_kern_ctx *res;
-   size_t sz;
+   return (malloc_domainset(fpu_kern_alloc_sz(cpu_max_ext_state_size),
+   M_FPUKERN_CTX, DOMAINSET_PREF(domain),
+   fpu_kern_malloc_flags(flags)));
+}
 
-   sz = sizeof(struct fpu_kern_ctx) + XSAVE_AREA_ALIGN +
-   cpu_max_ext_state_size;
-   res = malloc(sz, M_FPUKERN_CTX, ((flags & FPU_KERN_NOWAIT) ?
-   M_NOWAIT : M_WAITOK) | M_ZERO);
-   return (res);
+struct fpu_kern_ctx *
+fpu_kern_alloc_ctx(u_int flags)
+{
+   return (malloc(fpu_kern_alloc_sz(cpu_max_ext_state_size),
+   M_FPUKERN_CTX, fpu_kern_malloc_flags(flags)));
 }
 
 void

Modified: head/sys/amd64/include/fpu.h
==
--- head/sys/amd64/include/fpu.hFri Jul  3 11:46:42 2020
(r362912)
+++ head/sys/amd64/include/fpu.hFri Jul  3 14:54:46 2020
(r362913)
@@ -71,6 +71,7 @@ int   fputrap_sse(void);
 intfputrap_x87(void);
 void   fpuuserinited(struct thread *td);
 struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags);
+struct fpu_kern_ctx *fpu_kern_alloc_ctx_domain(int domain, u_int flags);
 void   fpu_kern_free_ctx(struct fpu_kern_ctx *ctx);
 void   fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx,
u_int flags);

Modified: head/sys/crypto/aesni/aesni.c
==
--- head/sys/crypto/aesni/aesni.c   Fri Jul  3 11:46:42 2020
(r362912)
+++ head/sys/crypto/aesni/aesni.c   Fri Jul  3 14:54:46 2020
(r362913)
@@ -180,7 +180,12 @@ aesni_attach(device_t dev)
M_WAITOK|M_ZERO);
 
CPU_FOREACH(i) {
-   ctx_fpu[i] = fpu_kern_alloc_ctx(0);
+#ifdef __amd64__
+   ctx_fpu[i] = fpu_kern_alloc_ctx_domain(
+   pcpu_find(i)->pc_domain, FPU_KERN_NORMAL);
+#else
+   ctx_fpu[i] = fpu_kern_alloc_ctx(FPU_KERN_NORMAL);
+#endif
mtx_init(&ctx_mtx[i], "anifpumtx", NULL, MTX_DEF|MTX_NEW);
}
 

Modified: head/sys/crypto/blake2/blake2_cryptodev.c
==
--- head/sys/crypto/blake2/blake2_cryptodev.c   Fri Jul  3 11:46:42 2020
(r362912)
+++ head/sys/crypto/blake2/blake2_cryptodev.c   Fri Jul  3 14:54:46 2020
(r362913)
@@ -142,7 +142,12 @@ blake2_attach(device_t dev)
M_WAITOK | M_ZERO);
 
CPU_FOREACH(i) {
-   ctx_fpu[i] = fpu_kern_alloc_ctx(0);
+#ifdef __amd64__
+   ctx_fpu[i] = fpu_kern_alloc_ctx_domain(
+   pcpu_find(i)->pc_domain, FPU_KERN_NORMAL);
+#else
+   ctx_fpu[i] = fpu_kern_alloc_ctx(FPU_KERN_NORMAL);
+#endif
mtx_init(&ctx_mtx[i], "bl2fpumtx", NULL, MTX_DEF | MTX_NEW);
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r362806 - head/sys/compat/linprocfs

2020-07-03 Thread Edward Tomasz Napierala
On 0630T1828, Mateusz Piotrowski wrote:
> Hi,
> 
> On 6/30/20 6:24 PM, Edward Tomasz Napierala wrote:
> > Author: trasz
> > Date: Tue Jun 30 16:24:28 2020
> > New Revision: 362806
> > URL: https://svnweb.freebsd.org/changeset/base/362806
> >
> > Log:
> >   Make linprocfs(5) create the /proc//task/ directores.
> >   This is to silence down some Chromium assertions.
> >   
> >   PR:   kern/240991
> >   Analyzed by:  Alex S 
> >   MFC after:2 weeks
> >   Sponsored by: The FreeBSD Foundation
> >   Differential Revision:https://reviews.freebsd.org/D25256
> 
> Hmm, could something similar be done to the following warning which is being 
> printed
> when service fahclient is started (from the biology/linux-foldingathome port):
> 
> 16:25:39:WARNING:Exception: Failed to open '/proc/bus/pci/devices': Failed to 
> open
> '/proc/bus/pci/devices': No such file or directory: No such file or directory

Sure: https://reviews.freebsd.org/D25557

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362914 - head/usr.bin/gh-bc

2020-07-03 Thread Ed Maste
Author: emaste
Date: Fri Jul  3 20:32:53 2020
New Revision: 362914
URL: https://svnweb.freebsd.org/changeset/base/362914

Log:
  bc: disable -flto on powerpc64
  
  Previously bc segfaulted at start, on powerpc64.
  
  PR:   247738
  Submitted by: luporl
  Reported by:  pkubaj
  MFC after:1 week

Modified:
  head/usr.bin/gh-bc/Makefile

Modified: head/usr.bin/gh-bc/Makefile
==
--- head/usr.bin/gh-bc/Makefile Fri Jul  3 14:54:46 2020(r362913)
+++ head/usr.bin/gh-bc/Makefile Fri Jul  3 20:32:53 2020(r362914)
@@ -50,7 +50,8 @@ CFLAGS+=  -DBC_ENABLE_NLS=0
 CFLAGS+=   -DBC_ENABLE_NLS=1
 
 # prevent floating point incompatibilities caused by -flto on some 
architectures
-.if ${MACHINE_ARCH} != mips && ${MACHINE_ARCH} != mips64 && ${MACHINE_ARCH} != 
riscv64
+.if ${MACHINE_ARCH} != mips && ${MACHINE_ARCH} != mips64 && \
+${MACHINE_ARCH} != powerpc64 && ${MACHINE_ARCH} != riscv64
 CFLAGS+=   -flto
 .endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r362902 - in head/lib/csu: . aarch64 amd64 arm i386 mips powerpc powerpc64 riscv

2020-07-03 Thread Kjell Tore Ullavik


Got a buildworld error for CURRENT, amd64 today. I have not rebuilt in 
while, but maybe r362902 is related?

I'm at r362906

sh /usr/src/tools/install.sh  -C -o root -g wheel -m 444 libgcc_eh.a 
/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/usr/lib32/

===> lib/libgcc_s (obj,all,install)
===> lib/csu (obj,all,install)
===> lib/csu/i386 (all)
cc -DCOMPAT_32BIT -march=i686 -mmmx -msse -msse2 -target 
x86_64-unknown-freebsd13.0 -m32 
-L/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/usr/lib32 
--sysroot=/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp 
-B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin 
-B/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/usr/lib32 -O2 -pipe 
-fno-common -I/usr/src/lib/csu/i386 -DCRT_IRELOC_REL 
-fno-asynchronous-unwind-tables -fno-omit-frame-pointer 
-I/usr/src/lib/csu/common  -I/usr/src/lib/libc/include -g -std=gnu99 
-Wno-format-zero-length -nobuiltininc -idirafter 
/usr/lib/clang/10.0.0/include  -Wsystem-headers -Werror -Wall 
-Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes 
-Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual 
-Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align 
-Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls 
-Wold-style-definition -Wno-pointer-sign -Wthread-safety -Wno-empty-body 
-Wno-string-plus-int -Wno-unused-const-variable -Qunused-arguments    
-fPIC -DPIC -c -o Scrt1_c.o /usr/src/lib/csu/i386/crt1_c.c
cc -DCOMPAT_32BIT -march=i686 -mmmx -msse -msse2 -target 
x86_64-unknown-freebsd13.0 -m32 
-L/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/usr/lib32 
--sysroot=/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp 
-B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin 
-B/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/usr/lib32 -O2 -pipe 
-fno-common -I/usr/src/lib/csu/i386 -DCRT_IRELOC_REL 
-fno-asynchronous-unwind-tables -fno-omit-frame-pointer 
-I/usr/src/lib/csu/common  -I/usr/src/lib/libc/include -g -std=gnu99 
-Wno-format-zero-length -nobuiltininc -idirafter 
/usr/lib/clang/10.0.0/include  -Wsystem-headers -Werror -Wall 
-Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes 
-Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual 
-Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align 
-Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls 
-Wold-style-definition -Wno-pointer-sign -Wthread-safety -Wno-empty-body 
-Wno-string-plus-int -Wno-unused-const-variable -Qunused-arguments 
-DLOCORE   -c /usr/src/lib/csu/i386/crt1_s.S -o crt1_s.o
cc -DCOMPAT_32BIT -march=i686 -mmmx -msse -msse2 -target 
x86_64-unknown-freebsd13.0 -m32 
-L/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/usr/lib32 
--sysroot=/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp 
-B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin 
-B/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/usr/lib32 -O2 -pipe 
-fno-common -I/usr/src/lib/csu/i386 -DCRT_IRELOC_REL 
-fno-asynchronous-unwind-tables -fno-omit-frame-pointer 
-I/usr/src/lib/csu/common  -I/usr/src/lib/libc/include -g -std=gnu99 
-Wno-format-zero-length -nobuiltininc -idirafter 
/usr/lib/clang/10.0.0/include  -Wsystem-headers -Werror -Wall 
-Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes 
-Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual 
-Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align 
-Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls 
-Wold-style-definition -Wno-pointer-sign -Wthread-safety -Wno-empty-body 
-Wno-string-plus-int -Wno-unused-const-variable -Qunused-arguments 
-DLOCORE   -c /usr/src/lib/csu/common/crtbrand.S -o crtbrand.o
cc -DCOMPAT_32BIT -march=i686 -mmmx -msse -msse2 -target 
x86_64-unknown-freebsd13.0 -m32 
-L/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/usr/lib32 
--sysroot=/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp 
-B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin 
-B/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/usr/lib32 -O2 -pipe 
-fno-common -I/usr/src/lib/csu/i386 -DCRT_IRELOC_REL 
-fno-asynchronous-unwind-tables -fno-omit-frame-pointer 
-I/usr/src/lib/csu/common  -I/usr/src/lib/libc/include -g -std=gnu99 
-Wno-format-zero-length -nobuiltininc -idirafter 
/usr/lib/clang/10.0.0/include  -Wsystem-headers -Werror -Wall 
-Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes 
-Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual 
-Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align 
-Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls 
-Wold-style-definition -Wno-pointer-sign -Wthread-safety -Wno-empty-body 
-Wno-string-plus-int -Wno-unused-const-variable -Qunused-arguments 
-DLOCORE   -c /usr/src/lib/csu/common/ignore_init_note.S -o 
ignore_init_note.o
ld -m elf_i386_fbsd 
-L/usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/usr/lib32  -o Scrt1.o -r 
Scrt1_c.o crt1_s.o crtbrand.o ignore_init_note.o

objcopy --localize-symbol _start1 crt1.o
objcopy: open crt1.o failed: No such file or directory
*** Error code 1

Stop.
make[5]: stopped in /usr/src/lib/csu/i386
*** Error code 1

Stop.
make[4]: stopped in /usr/src/lib/csu
*** 

svn commit: r362917 - head/sys/fs/nfs

2020-07-03 Thread Rick Macklem
Author: rmacklem
Date: Sat Jul  4 03:28:13 2020
New Revision: 362917
URL: https://svnweb.freebsd.org/changeset/base/362917

Log:
  Add support for ext_pgs mbufs to nfscl_reqstart() and nfsm_set().
  
  This is another in the series of commits that add support to the NFS client
  and server for building RPC messages in ext_pgs mbufs with anonymous pages.
  This is useful so that the entire mbuf list does not need to be
  copied before calling sosend() when NFS over TLS is enabled.
  
  Since ND_EXTPG is never set yet, there is no semantic change at this time.

Modified:
  head/sys/fs/nfs/nfs_commonsubs.c

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==
--- head/sys/fs/nfs/nfs_commonsubs.cSat Jul  4 03:27:51 2020
(r362916)
+++ head/sys/fs/nfs/nfs_commonsubs.cSat Jul  4 03:28:13 2020
(r362917)
@@ -359,13 +359,19 @@ nfscl_reqstart(struct nfsrv_descript *nd, int procnum,
/*
 * Get the first mbuf for the request.
 */
-   if (nfs_bigrequest[procnum])
-   NFSMCLGET(mb, M_WAITOK);
-   else
-   NFSMGET(mb);
-   mb->m_len = 0;
-   nd->nd_mreq = nd->nd_mb = mb;
-   nd->nd_bpos = mtod(mb, char *);
+   if ((nd->nd_flag & ND_EXTPG) != 0) {
+   mb = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK);
+   nd->nd_mreq = nd->nd_mb = mb;
+   nfsm_set(nd, 0);
+   } else {
+   if (nfs_bigrequest[procnum])
+   NFSMCLGET(mb, M_WAITOK);
+   else
+   NFSMGET(mb);
+   mb->m_len = 0;
+   nd->nd_mreq = nd->nd_mb = mb;
+   nd->nd_bpos = mtod(mb, char *);
+   }

/*
 * And fill the first file handle into the request.
@@ -4804,7 +4810,38 @@ void
 nfsm_set(struct nfsrv_descript *nd, u_int offs)
 {
struct mbuf *m;
+   int rlen;
 
m = nd->nd_mb;
-   nd->nd_bpos = mtod(m, char *) + offs;
+   if ((m->m_flags & M_EXTPG) != 0) {
+   nd->nd_bextpg = 0;
+   while (offs > 0) {
+   if (nd->nd_bextpg == 0)
+   rlen = m_epg_pagelen(m, 0, m->m_epg_1st_off);
+   else
+   rlen = m_epg_pagelen(m, nd->nd_bextpg, 0);
+   if (offs <= rlen)
+   break;
+   offs -= rlen;
+   nd->nd_bextpg++;
+   if (nd->nd_bextpg == m->m_epg_npgs) {
+   printf("nfsm_set: build offs "
+   "out of range\n");
+   nd->nd_bextpg--;
+   break;
+   }
+   }
+   nd->nd_bpos = (char *)(void *)
+   PHYS_TO_DMAP(m->m_epg_pa[nd->nd_bextpg]);
+   if (nd->nd_bextpg == 0)
+   nd->nd_bpos += m->m_epg_1st_off;
+   if (offs > 0) {
+   nd->nd_bpos += offs;
+   nd->nd_bextpgsiz = rlen - offs;
+   } else if (nd->nd_bextpg == 0)
+   nd->nd_bextpgsiz = PAGE_SIZE - m->m_epg_1st_off;
+   else
+   nd->nd_bextpgsiz = PAGE_SIZE;
+   } else
+   nd->nd_bpos = mtod(m, char *) + offs;
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362920 - head/sys/security/audit

2020-07-03 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul  4 06:21:20 2020
New Revision: 362920
URL: https://svnweb.freebsd.org/changeset/base/362920

Log:
  audit: provide AUDITING_TD for !AUDIT case

Modified:
  head/sys/security/audit/audit.h

Modified: head/sys/security/audit/audit.h
==
--- head/sys/security/audit/audit.h Sat Jul  4 03:30:19 2020
(r362919)
+++ head/sys/security/audit/audit.h Sat Jul  4 06:21:20 2020
(r362920)
@@ -468,6 +468,8 @@ void audit_thread_free(struct thread *td);
 #defineAUDIT_ARG_VNODE1(vp)
 #defineAUDIT_ARG_VNODE2(vp)
 
+#defineAUDITING_TD(td) 0
+
 #defineAUDIT_SYSCALL_ENTER(code, td)   0
 #defineAUDIT_SYSCALL_EXIT(error, td)
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362921 - in head/sys: kern sys

2020-07-03 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul  4 06:22:05 2020
New Revision: 362921
URL: https://svnweb.freebsd.org/changeset/base/362921

Log:
  Add char and short types to kcsan

Modified:
  head/sys/kern/subr_csan.c
  head/sys/sys/_cscan_atomic.h

Modified: head/sys/kern/subr_csan.c
==
--- head/sys/kern/subr_csan.c   Sat Jul  4 06:21:20 2020(r362920)
+++ head/sys/kern/subr_csan.c   Sat Jul  4 06:22:05 2020(r362921)
@@ -590,6 +590,38 @@ CSAN_ATOMIC_FUNC_TESTANDCLEAR(64, uint64_t)
 CSAN_ATOMIC_FUNC_TESTANDSET(64, uint64_t)
 #endif
 
+CSAN_ATOMIC_FUNC_ADD(char, uint8_t)
+CSAN_ATOMIC_FUNC_CLEAR(char, uint8_t)
+CSAN_ATOMIC_FUNC_CMPSET(char, uint8_t)
+CSAN_ATOMIC_FUNC_FCMPSET(char, uint8_t)
+CSAN_ATOMIC_FUNC_LOAD(char, uint8_t)
+CSAN_ATOMIC_FUNC_SET(char, uint8_t)
+CSAN_ATOMIC_FUNC_SUBTRACT(char, uint8_t)
+_CSAN_ATOMIC_FUNC_STORE(char, uint8_t)
+#if 0
+CSAN_ATOMIC_FUNC_FETCHADD(char, uint8_t)
+CSAN_ATOMIC_FUNC_READANDCLEAR(char, uint8_t)
+CSAN_ATOMIC_FUNC_SWAP(char, uint8_t)
+CSAN_ATOMIC_FUNC_TESTANDCLEAR(char, uint8_t)
+CSAN_ATOMIC_FUNC_TESTANDSET(char, uint8_t)
+#endif
+
+CSAN_ATOMIC_FUNC_ADD(short, uint16_t)
+CSAN_ATOMIC_FUNC_CLEAR(short, uint16_t)
+CSAN_ATOMIC_FUNC_CMPSET(short, uint16_t)
+CSAN_ATOMIC_FUNC_FCMPSET(short, uint16_t)
+CSAN_ATOMIC_FUNC_LOAD(short, uint16_t)
+CSAN_ATOMIC_FUNC_SET(short, uint16_t)
+CSAN_ATOMIC_FUNC_SUBTRACT(short, uint16_t)
+_CSAN_ATOMIC_FUNC_STORE(short, uint16_t)
+#if 0
+CSAN_ATOMIC_FUNC_FETCHADD(short, uint16_t)
+CSAN_ATOMIC_FUNC_READANDCLEAR(short, uint16_t)
+CSAN_ATOMIC_FUNC_SWAP(short, uint16_t)
+CSAN_ATOMIC_FUNC_TESTANDCLEAR(short, uint16_t)
+CSAN_ATOMIC_FUNC_TESTANDSET(short, uint16_t)
+#endif
+
 CSAN_ATOMIC_FUNC_ADD(int, u_int)
 CSAN_ATOMIC_FUNC_CLEAR(int, u_int)
 CSAN_ATOMIC_FUNC_CMPSET(int, u_int)

Modified: head/sys/sys/_cscan_atomic.h
==
--- head/sys/sys/_cscan_atomic.hSat Jul  4 06:21:20 2020
(r362920)
+++ head/sys/sys/_cscan_atomic.hSat Jul  4 06:22:05 2020
(r362921)
@@ -87,6 +87,8 @@
KCSAN_ATOMIC_TEST(testandclear, name, type);\
KCSAN_ATOMIC_TEST(testandset, name, type)
 
+KCSAN_ATOMIC_FUNCS(char, uint8_t);
+KCSAN_ATOMIC_FUNCS(short, uint16_t);
 KCSAN_ATOMIC_FUNCS(int, u_int);
 KCSAN_ATOMIC_FUNCS(long, u_long);
 KCSAN_ATOMIC_FUNCS(ptr, uintptr_t);
@@ -101,6 +103,62 @@ void   kcsan_atomic_thread_fence_rel(void);
 void   kcsan_atomic_thread_fence_seq_cst(void);
 
 #ifndef KCSAN_RUNTIME
+
+#defineatomic_add_char kcsan_atomic_add_char
+#defineatomic_add_acq_char kcsan_atomic_add_acq_char
+#defineatomic_add_rel_char kcsan_atomic_add_rel_char
+#defineatomic_clear_char   kcsan_atomic_clear_char
+#defineatomic_clear_acq_char   kcsan_atomic_clear_acq_char
+#defineatomic_clear_rel_char   kcsan_atomic_clear_rel_char
+#defineatomic_cmpset_char  kcsan_atomic_cmpset_char
+#defineatomic_cmpset_acq_char  kcsan_atomic_cmpset_acq_char
+#defineatomic_cmpset_rel_char  kcsan_atomic_cmpset_rel_char
+#defineatomic_fcmpset_char kcsan_atomic_fcmpset_char
+#defineatomic_fcmpset_acq_char kcsan_atomic_fcmpset_acq_char
+#defineatomic_fcmpset_rel_char kcsan_atomic_fcmpset_rel_char
+#defineatomic_fetchadd_charkcsan_atomic_fetchadd_char
+#defineatomic_load_charkcsan_atomic_load_char
+#defineatomic_load_acq_charkcsan_atomic_load_acq_char
+#defineatomic_readandclear_charkcsan_atomic_readandclear_char
+#defineatomic_set_char kcsan_atomic_set_char
+#defineatomic_set_acq_char kcsan_atomic_set_acq_char
+#defineatomic_set_rel_char kcsan_atomic_set_rel_char
+#defineatomic_subtract_charkcsan_atomic_subtract_char
+#defineatomic_subtract_acq_charkcsan_atomic_subtract_acq_char
+#defineatomic_subtract_rel_charkcsan_atomic_subtract_rel_char
+#defineatomic_store_char   kcsan_atomic_store_char
+#defineatomic_store_rel_char   kcsan_atomic_store_rel_char
+#defineatomic_swap_charkcsan_atomic_swap_char
+#defineatomic_testandclear_charkcsan_atomic_testandclear_char
+#defineatomic_testandset_char  kcsan_atomic_testandset_char
+
+#defineatomic_add_shortkcsan_atomic_add_short
+#defineatomic_add_acq_shortkcsan_atomic_add_acq_short
+#defineatomic_add_rel_shortkcsan_atomic_add_rel_short
+#defineatomic_clear_short  kcsan_atomic_clear_short
+#defineatomic_clear_acq_short  kcsan_atomic_clear_acq_short
+#define 

svn commit: r362922 - head/sys/compat/linux

2020-07-03 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul  4 06:25:41 2020
New Revision: 362922
URL: https://svnweb.freebsd.org/changeset/base/362922

Log:
  linux: fix ioctl performance for termios
  
  TCGETS et al are frequently issued by Linux binaries while the previous code
  avoidably ping-pongs a global sx lock and serializes on Giant.
  
  Note that even with the fix the common case will serialize on a per-tty lock.

Modified:
  head/sys/compat/linux/linux_ioctl.c

Modified: head/sys/compat/linux/linux_ioctl.c
==
--- head/sys/compat/linux/linux_ioctl.c Sat Jul  4 06:22:05 2020
(r362921)
+++ head/sys/compat/linux/linux_ioctl.c Sat Jul  4 06:25:41 2020
(r362922)
@@ -132,8 +132,6 @@ static struct linux_ioctl_handler socket_handler =
 { linux_ioctl_socket, LINUX_IOCTL_SOCKET_MIN, LINUX_IOCTL_SOCKET_MAX };
 static struct linux_ioctl_handler sound_handler =
 { linux_ioctl_sound, LINUX_IOCTL_SOUND_MIN, LINUX_IOCTL_SOUND_MAX };
-static struct linux_ioctl_handler termio_handler =
-{ linux_ioctl_termio, LINUX_IOCTL_TERMIO_MIN, LINUX_IOCTL_TERMIO_MAX };
 static struct linux_ioctl_handler private_handler =
 { linux_ioctl_private, LINUX_IOCTL_PRIVATE_MIN, LINUX_IOCTL_PRIVATE_MAX };
 static struct linux_ioctl_handler drm_handler =
@@ -156,7 +154,6 @@ DATA_SET(linux_ioctl_handler_set, hdio_handler);
 DATA_SET(linux_ioctl_handler_set, disk_handler);
 DATA_SET(linux_ioctl_handler_set, socket_handler);
 DATA_SET(linux_ioctl_handler_set, sound_handler);
-DATA_SET(linux_ioctl_handler_set, termio_handler);
 DATA_SET(linux_ioctl_handler_set, private_handler);
 DATA_SET(linux_ioctl_handler_set, drm_handler);
 DATA_SET(linux_ioctl_handler_set, sg_handler);
@@ -165,6 +162,14 @@ DATA_SET(linux_ioctl_handler_set, video2_handler);
 DATA_SET(linux_ioctl_handler_set, fbsd_usb);
 DATA_SET(linux_ioctl_handler_set, evdev_handler);
 
+/*
+ * Keep sorted by low.
+ */
+static struct linux_ioctl_handler linux_ioctls[] = {
+   { .func = linux_ioctl_termio, .low = LINUX_IOCTL_TERMIO_MIN,
+   .high = LINUX_IOCTL_TERMIO_MAX },
+};
+
 #ifdef __i386__
 static TAILQ_HEAD(, linux_ioctl_handler_element) linux_ioctl_handlers =
 TAILQ_HEAD_INITIALIZER(linux_ioctl_handlers);
@@ -3558,8 +3563,8 @@ linux_ioctl_evdev(struct thread *td, struct linux_ioct
  * main ioctl syscall function
  */
 
-int
-linux_ioctl(struct thread *td, struct linux_ioctl_args *args)
+static int
+linux_ioctl_fallback(struct thread *td, struct linux_ioctl_args *args)
 {
struct file *fp;
struct linux_ioctl_handler_element *he;
@@ -3618,6 +3623,35 @@ linux_ioctl(struct thread *td, struct linux_ioctl_args
}
 
return (EINVAL);
+}
+
+int
+linux_ioctl(struct thread *td, struct linux_ioctl_args *args)
+{
+   struct linux_ioctl_handler *handler;
+   int error, cmd, i;
+
+   cmd = args->cmd & 0x;
+
+   /*
+* array of ioctls known at compilation time. Elides a lot of work on
+* each call compared to the list variant. Everything frequently used
+* should be moved here.
+*
+* Arguably the magic creating the list should create an array instead.
+*
+* For now just a linear scan.
+*/
+   for (i = 0; i < nitems(linux_ioctls); i++) {
+   handler = &linux_ioctls[i];
+   if (cmd >= handler->low && cmd <= handler->high) {
+   error = (*handler->func)(td, args);
+   if (error != ENOIOCTL) {
+   return (error);
+   }
+   }
+   }
+   return (linux_ioctl_fallback(td, args));
 }
 
 int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362923 - head/sys/fs/devfs

2020-07-03 Thread Mateusz Guzik
Author: mjg
Date: Sat Jul  4 06:27:28 2020
New Revision: 362923
URL: https://svnweb.freebsd.org/changeset/base/362923

Log:
  devfs: fix a vnode use-after-free in devfs_ioctl
  
  The vnode to be replaced was read with a shared lock, meaning 2 racing threads
  can find the same one.
  
  While here clean it up a little bit.

Modified:
  head/sys/fs/devfs/devfs_vnops.c

Modified: head/sys/fs/devfs/devfs_vnops.c
==
--- head/sys/fs/devfs/devfs_vnops.c Sat Jul  4 06:25:41 2020
(r362922)
+++ head/sys/fs/devfs/devfs_vnops.c Sat Jul  4 06:27:28 2020
(r362923)
@@ -787,6 +787,7 @@ devfs_ioctl(struct vop_ioctl_args *ap)
struct vnode *vpold, *vp;
struct cdevsw *dsw;
struct thread *td;
+   struct session *sess;
struct cdev *dev;
int error, ref, i;
const char *p;
@@ -836,18 +837,18 @@ devfs_ioctl(struct vop_ioctl_args *ap)
 * nothing left to do.
 */
sx_slock(&proctree_lock);
-   if (td->td_proc->p_session->s_ttyvp == vp ||
-   td->td_proc->p_session->s_ttyp == NULL) {
+   sess = td->td_proc->p_session;
+   if (sess->s_ttyvp == vp || sess->s_ttyp == NULL) {
sx_sunlock(&proctree_lock);
return (0);
}
 
-   vpold = td->td_proc->p_session->s_ttyvp;
-   VREF(vp);
-   SESS_LOCK(td->td_proc->p_session);
-   td->td_proc->p_session->s_ttyvp = vp;
-   td->td_proc->p_session->s_ttydp = cdev2priv(dev);
-   SESS_UNLOCK(td->td_proc->p_session);
+   vrefact(vp);
+   SESS_LOCK(sess);
+   vpold = sess->s_ttyvp;
+   sess->s_ttyvp = vp;
+   sess->s_ttydp = cdev2priv(dev);
+   SESS_UNLOCK(sess);
 
sx_sunlock(&proctree_lock);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"