svn commit: r368510 - head/usr.sbin/diskinfo

2020-12-10 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Dec 10 10:23:18 2020
New Revision: 368510
URL: https://svnweb.freebsd.org/changeset/base/368510

Log:
  Make "diskinfo -i" also test 1MB reads.

Modified:
  head/usr.sbin/diskinfo/diskinfo.c

Modified: head/usr.sbin/diskinfo/diskinfo.c
==
--- head/usr.sbin/diskinfo/diskinfo.c   Thu Dec 10 10:00:43 2020
(r368509)
+++ head/usr.sbin/diskinfo/diskinfo.c   Thu Dec 10 10:23:18 2020
(r368510)
@@ -644,6 +644,9 @@ iopsbench(int fd, off_t mediasize, u_int sectorsize)
printf("\t128 kbytes:  ");
iops(fd, mediasize, 128 * 1024);
 
+   printf("\t1024 kbytes: ");
+   iops(fd, mediasize, 1024 * 1024);
+   
printf("\n");
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367956 - head/usr.sbin/ctladm

2020-11-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Nov 23 14:30:27 2020
New Revision: 367956
URL: https://svnweb.freebsd.org/changeset/base/367956

Log:
  Replace paths in ctladm(8) examples with something sensible.
  
  PR:   251181
  Reviewed by:  0mp, rm, ygy
  MFC after:2 weeks
  Sponsored by: EPSRC
  Differential Revision:https://reviews.freebsd.org/D27249

Modified:
  head/usr.sbin/ctladm/ctladm.8

Modified: head/usr.sbin/ctladm/ctladm.8
==
--- head/usr.sbin/ctladm/ctladm.8   Mon Nov 23 14:30:22 2020
(r367955)
+++ head/usr.sbin/ctladm/ctladm.8   Mon Nov 23 14:30:27 2020
(r367956)
@@ -36,7 +36,7 @@
 .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
 .\" $FreeBSD$
 .\"
-.Dd August 6, 2020
+.Dd November 23, 2020
 .Dt CTLADM 8
 .Os
 .Sh NAME
@@ -1029,23 +1029,17 @@ while reporting size of 10 terabytes,
 .Pp
 .Dl ctladm create -b ramdisk -s 10T -o capacity=10G
 .Pp
-Create a LUN using the block backend, and specify the file
-.Pa src/usr.sbin/ctladm/ctladm.8
-as the backing store.
-The size of the LUN will be derived from the size of the file.
-.Pp
-.Dl ctladm create -b block -o file=src/usr.sbin/ctladm/ctladm.8
-.Pp
-Create a LUN using the block backend, specify the file
-.Pa src/usr.sbin/ctladm/ctladm.8
+Create a LUN using the block backend, specify the ZFS volume
+.Pa tank/example
 as the backing store, and specify the
 .Tn SCSI
 VPD page 0x80 and 0x83 serial number
 .Fl ( S )
 and device ID
 .Fl ( d ) .
+The size of the LUN will be derived from the size of the ZVOL.
 .Pp
-.Dl ctladm create -b block -o file=src/usr.sbin/ctladm/ctladm.8 -S MYSERIAL321 
-d MYDEVID123
+.Dl ctladm create -b block -o file=/dev/zvol/tank/example -S MYSERIAL321 -d 
MYDEVID123
 .Pp
 Use to specify generic options on ioctl frontend port, now it is
 only possible to set pp and/or vp port number.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367954 - head/share/man/man7

2020-11-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Nov 23 14:26:59 2020
New Revision: 367954
URL: https://svnweb.freebsd.org/changeset/base/367954

Log:
  Assorted tweaks to hier(7): punctuation, some .Xr's, clarify wording.
  
  Reviewed by:  0mp, bcr, imp
  MFC after:2 weeks
  Sponsored by: EPSRC
  Differential Revision:https://reviews.freebsd.org/D27248

Modified:
  head/share/man/man7/hier.7

Modified: head/share/man/man7/hier.7
==
--- head/share/man/man7/hier.7  Mon Nov 23 13:05:11 2020(r367953)
+++ head/share/man/man7/hier.7  Mon Nov 23 14:26:59 2020(r367954)
@@ -28,7 +28,7 @@
 .\"@(#)hier.7  8.1 (Berkeley) 6/5/93
 .\" $FreeBSD$
 .\"
-.Dd January 20, 2020
+.Dd November 23, 2020
 .Dt HIER 7
 .Os
 .Sh NAME
@@ -54,7 +54,7 @@ Compiled flattened device tree (FDT) files; see
 and
 .Xr dtc 1
 .It Pa efi/
-Mount point for EFI System Partition (ESP) on UEFI systems.
+Mount point for EFI System Partition (ESP) on UEFI systems
 .It Pa firmware/
 loadable kernel modules containing binary firmware for hardware that needs
 firmware downloaded to it to function
@@ -62,9 +62,8 @@ firmware downloaded to it to function
 pure kernel executable (the operating system loaded into memory
 at boot time) and kernel modules
 .It Pa modules/
-third-party loadable kernel modules;
-see
-.Xr kldstat 8
+third-party loadable kernel modules, such as the ones installed from
+.Xr ports 7
 .It Pa overlays/
 Compiled flattened device tree (FDT) overlays; see
 .Xr fdt 4
@@ -197,8 +196,9 @@ contains the majority of user utilities and applicatio
 .It Pa bin/
 common utilities, programming tools, and applications
 .It Pa compat/
-files needed to support binary compatibility with other operating systems,
-such as Linux
+files needed to support binary compatibility with other operating systems;
+see
+.Xr linux 4
 .It Pa include/
 standard C include files
 .Pp
@@ -435,7 +435,7 @@ tree
 .Xr ports 7 ,
 the
 .Fx
-ports collection.
+ports collection
 .It Pa sbin/
 system daemons & system utilities (executed by users)
 .It Pa share/
@@ -604,8 +604,8 @@ see
 .El
 .Pp
 .It Pa src/
-.Bx ,
-third-party, and/or local source files
+.Fx
+source code
 .Pp
 .Bl -tag -width "kerberos5/" -compact
 .It Pa bin/
@@ -734,10 +734,8 @@ source code for files in
 .It Pa tests/
 The
 .Fx
-test suite.
-See
+test suite; see
 .Xr tests 7
-for more details.
 .El
 .It Pa /var/
 multi-purpose log, temporary, transient, and spool files
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367953 - head/sys/dev/firewire

2020-11-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Nov 23 13:05:11 2020
New Revision: 367953
URL: https://svnweb.freebsd.org/changeset/base/367953

Log:
  Make sbp(4) use xpt_alloc_ccb/xpt_free_ccb instead of malloc/free.
  
  Reviewed by:  imp, mav
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D26843

Modified:
  head/sys/dev/firewire/sbp.c

Modified: head/sys/dev/firewire/sbp.c
==
--- head/sys/dev/firewire/sbp.c Mon Nov 23 13:02:23 2020(r367952)
+++ head/sys/dev/firewire/sbp.c Mon Nov 23 13:05:11 2020(r367953)
@@ -987,7 +987,7 @@ END_DEBUG
sdev = sbp_next_dev(target, sdev->lun_id + 1);
if (sdev == NULL) {
SBP_UNLOCK(sbp);
-   free(ccb, M_SBP);
+   xpt_free_ccb(ccb);
return;
}
/* reuse ccb */
@@ -1019,9 +1019,9 @@ SBP_DEBUG(0)
device_printf(sdev->target->sbp->fd.dev,
"%s:%s\n", __func__, sdev->bustgtlun);
 END_DEBUG
-   ccb = malloc(sizeof(union ccb), M_SBP, M_NOWAIT | M_ZERO);
+   ccb = xpt_alloc_ccb_nowait();
if (ccb == NULL) {
-   printf("sbp_cam_scan_target: malloc failed\n");
+   printf("sbp_cam_scan_target: xpt_alloc_ccb_nowait() failed\n");
return;
}
SBP_UNLOCK(target->sbp);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367952 - head/sys/dev/tws

2020-11-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Nov 23 13:02:23 2020
New Revision: 367952
URL: https://svnweb.freebsd.org/changeset/base/367952

Log:
  Make tws(4) use xpt_alloc_ccb()/xpt_free_ccb() instead of malloc/free.
  
  Reviewed by:  imp
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D26841

Modified:
  head/sys/dev/tws/tws.c

Modified: head/sys/dev/tws/tws.c
==
--- head/sys/dev/tws/tws.c  Mon Nov 23 12:59:56 2020(r367951)
+++ head/sys/dev/tws/tws.c  Mon Nov 23 13:02:23 2020(r367952)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 
 MALLOC_DEFINE(M_TWS, "twsbuf", "buffers used by tws driver");
 int tws_queue_depth = TWS_MAX_REQS;
@@ -412,7 +413,7 @@ tws_detach(device_t dev)
 callout_drain(>stats_timer);
 free(sc->reqs, M_TWS);
 free(sc->sense_bufs, M_TWS);
-free(sc->scan_ccb, M_TWS);
+xpt_free_ccb(sc->scan_ccb);
 if (sc->ioctl_data_mem)
 bus_dmamem_free(sc->data_tag, sc->ioctl_data_mem, 
sc->ioctl_data_map);
 if (sc->data_tag)
@@ -597,7 +598,7 @@ tws_init(struct tws_softc *sc)
   M_WAITOK | M_ZERO);
 sc->sense_bufs = malloc(sizeof(struct tws_sense) * tws_queue_depth, M_TWS,
   M_WAITOK | M_ZERO);
-sc->scan_ccb = malloc(sizeof(union ccb), M_TWS, M_WAITOK | M_ZERO);
+sc->scan_ccb = xpt_alloc_ccb();
 if (bus_dmamem_alloc(sc->data_tag, (void **)>ioctl_data_mem,
 (BUS_DMA_NOWAIT | BUS_DMA_ZERO), >ioctl_data_map)) {
 device_printf(sc->tws_dev, "Cannot allocate ioctl data mem\n");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367951 - head/sys/dev/hptmv

2020-11-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Nov 23 12:59:56 2020
New Revision: 367951
URL: https://svnweb.freebsd.org/changeset/base/367951

Log:
  Don't check return from xpt_alloc_ccb() for being NULL; since it's not
  the _nowait wariant, it cannot fail.
  
  Suggested by: mav
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.

Modified:
  head/sys/dev/hptmv/entry.c

Modified: head/sys/dev/hptmv/entry.c
==
--- head/sys/dev/hptmv/entry.c  Mon Nov 23 12:57:24 2020(r367950)
+++ head/sys/dev/hptmv/entry.c  Mon Nov 23 12:59:56 2020(r367951)
@@ -2008,15 +2008,10 @@ hpt_attach(device_t dev)
}
 
 
-   if ((ccb = xpt_alloc_ccb()) != NULL)
-   {
-   ccb->ccb_h.pinfo.priority = 1;
-   ccb->ccb_h.pinfo.index = CAM_UNQUEUED_INDEX;
-   }
-   else
-   {
-   return ENOMEM;
-   }
+   ccb = xpt_alloc_ccb();
+   ccb->ccb_h.pinfo.priority = 1;
+   ccb->ccb_h.pinfo.index = CAM_UNQUEUED_INDEX;
+
/*
 * Create the device queue for our SIM(s).
 */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367950 - head/sys/dev/hptmv

2020-11-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Nov 23 12:57:24 2020
New Revision: 367950
URL: https://svnweb.freebsd.org/changeset/base/367950

Log:
  Make hptmv(4) use xpt_alloc_ccb/xpt_free_ccb instead of malloc/free.
  
  Reviewed by:  imp, mav
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D26842

Modified:
  head/sys/dev/hptmv/entry.c

Modified: head/sys/dev/hptmv/entry.c
==
--- head/sys/dev/hptmv/entry.c  Mon Nov 23 12:54:19 2020(r367949)
+++ head/sys/dev/hptmv/entry.c  Mon Nov 23 12:57:24 2020(r367950)
@@ -2008,9 +2008,8 @@ hpt_attach(device_t dev)
}
 
 
-   if((ccb = (union ccb *)malloc(sizeof(*ccb), M_DEVBUF, M_WAITOK)) != 
(union ccb*)NULL)
+   if ((ccb = xpt_alloc_ccb()) != NULL)
{
-   bzero(ccb, sizeof(*ccb));
ccb->ccb_h.pinfo.priority = 1;
ccb->ccb_h.pinfo.index = CAM_UNQUEUED_INDEX;
}
@@ -2065,7 +2064,7 @@ hpt_attach(device_t dev)
ccb->csa.callback = hpt_async;
ccb->csa.callback_arg = hpt_vsim;
xpt_action((union ccb *)ccb);
-   free(ccb, M_DEVBUF);
+   xpt_free_ccb(ccb);
 
if (device_get_unit(dev) == 0) {
/* Start the work thread.  XXX */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367949 - head/sys/dev/smartpqi

2020-11-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Nov 23 12:54:19 2020
New Revision: 367949
URL: https://svnweb.freebsd.org/changeset/base/367949

Log:
  smartpqi: don't bzero the new ccb; xpt_alloc_ccb_nowait() already does that.
  
  Reviewed by:  imp
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D26838

Modified:
  head/sys/dev/smartpqi/smartpqi_cam.c

Modified: head/sys/dev/smartpqi/smartpqi_cam.c
==
--- head/sys/dev/smartpqi/smartpqi_cam.cMon Nov 23 12:50:38 2020
(r367948)
+++ head/sys/dev/smartpqi/smartpqi_cam.cMon Nov 23 12:54:19 2020
(r367949)
@@ -623,7 +623,6 @@ static void smartpqi_lun_rescan(struct pqisrc_softstat
return;
}
 
-   bzero(ccb, sizeof(union ccb));
xpt_setup_ccb(>ccb_h, path, 5);
ccb->ccb_h.func_code = XPT_SCAN_LUN;
ccb->ccb_h.cbfcnp = smartpqi_lunrescan_cb;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367948 - head/sys/dev/arcmsr

2020-11-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Nov 23 12:50:38 2020
New Revision: 367948
URL: https://svnweb.freebsd.org/changeset/base/367948

Log:
  arcmsr(4): don't bzero newly allocated ccb; xpt_alloc_ccb() already does that.
  
  Reviewed by:  delphij, imp, ching2...@areca.com.tw
  Tested by:ching2...@areca.com.tw
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D26840

Modified:
  head/sys/dev/arcmsr/arcmsr.c

Modified: head/sys/dev/arcmsr/arcmsr.c
==
--- head/sys/dev/arcmsr/arcmsr.cMon Nov 23 12:47:23 2020
(r367947)
+++ head/sys/dev/arcmsr/arcmsr.cMon Nov 23 12:50:38 2020
(r367948)
@@ -1707,7 +1707,6 @@ static void   arcmsr_rescan_lun(struct 
AdapterControlBlo
return;
}
 /* printf("arcmsr_rescan_lun: Rescan Target=%x, Lun=%x\n", target, lun); */
-   bzero(ccb, sizeof(union ccb));
xpt_setup_ccb(>ccb_h, path, 5);
ccb->ccb_h.func_code = XPT_SCAN_LUN;
ccb->ccb_h.cbfcnp = arcmsr_rescanLun_cb;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367947 - head/sys/kern

2020-11-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Nov 23 12:47:23 2020
New Revision: 367947
URL: https://svnweb.freebsd.org/changeset/base/367947

Log:
  Remove the 'wantparent' variable, unused since r145004.
  
  Reviewed by:  kib
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D27193

Modified:
  head/sys/kern/vfs_lookup.c

Modified: head/sys/kern/vfs_lookup.c
==
--- head/sys/kern/vfs_lookup.c  Mon Nov 23 10:13:56 2020(r367946)
+++ head/sys/kern/vfs_lookup.c  Mon Nov 23 12:47:23 2020(r367947)
@@ -1305,7 +1305,6 @@ int
 relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
 {
struct vnode *dp = NULL;/* the directory we are 
searching */
-   int wantparent; /* 1 => wantparent or lockparent flag */
int rdonly; /* lookup read-only flag bit */
int error = 0;
 
@@ -1314,8 +1313,8 @@ relookup(struct vnode *dvp, struct vnode **vpp, struct
/*
 * Setup: break out flag bits into variables.
 */
-   wantparent = cnp->cn_flags & (LOCKPARENT|WANTPARENT);
-   KASSERT(wantparent, ("relookup: parent not wanted."));
+   KASSERT((cnp->cn_flags & (LOCKPARENT | WANTPARENT)) != 0,
+   ("relookup: parent not wanted"));
rdonly = cnp->cn_flags & RDONLY;
cnp->cn_flags &= ~ISSYMLINK;
dp = dvp;
@@ -1406,13 +1405,8 @@ relookup(struct vnode *dvp, struct vnode **vpp, struct
/*
 * Set the parent lock/ref state to the requested state.
 */
-   if ((cnp->cn_flags & LOCKPARENT) == 0 && dvp != dp) {
-   if (wantparent)
-   VOP_UNLOCK(dvp);
-   else
-   vput(dvp);
-   } else if (!wantparent)
-   vrele(dvp);
+   if ((cnp->cn_flags & LOCKPARENT) == 0 && dvp != dp)
+   VOP_UNLOCK(dvp);
/*
 * Check for symbolic link
 */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367517 - in head/sys: compat/linux fs/fuse

2020-11-09 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Nov  9 08:53:15 2020
New Revision: 367517
URL: https://svnweb.freebsd.org/changeset/base/367517

Log:
  Make it possible to mount a fuse filesystem, such as squashfuse,
  from a Linux binary.  Should come handy for AppImages.
  
  Reviewed by:  asomers
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26959

Modified:
  head/sys/compat/linux/linux_file.c
  head/sys/fs/fuse/fuse_device.c
  head/sys/fs/fuse/fuse_ipc.h
  head/sys/fs/fuse/fuse_vfsops.c

Modified: head/sys/compat/linux/linux_file.c
==
--- head/sys/compat/linux/linux_file.c  Mon Nov  9 05:20:02 2020
(r367516)
+++ head/sys/compat/linux/linux_file.c  Mon Nov  9 08:53:15 2020
(r367517)
@@ -1181,13 +1181,15 @@ linux_pwritev(struct thread *td, struct linux_pwritev_
 int
 linux_mount(struct thread *td, struct linux_mount_args *args)
 {
-   char fstypename[MFSNAMELEN];
-   char *mntonname, *mntfromname;
+   struct mntarg *ma = NULL;
+   char *fstypename, *mntonname, *mntfromname, *data;
int error, fsflags;
 
+   fstypename = malloc(MNAMELEN, M_TEMP, M_WAITOK);
mntonname = malloc(MNAMELEN, M_TEMP, M_WAITOK);
mntfromname = malloc(MNAMELEN, M_TEMP, M_WAITOK);
-   error = copyinstr(args->filesystemtype, fstypename, MFSNAMELEN - 1,
+   data = NULL;
+   error = copyinstr(args->filesystemtype, fstypename, MNAMELEN - 1,
NULL);
if (error != 0)
goto out;
@@ -1208,6 +1210,31 @@ linux_mount(struct thread *td, struct linux_mount_args
strcpy(fstypename, "linprocfs");
} else if (strcmp(fstypename, "vfat") == 0) {
strcpy(fstypename, "msdosfs");
+   } else if (strcmp(fstypename, "fuse") == 0) {
+   char *fuse_options, *fuse_option, *fuse_name;
+
+   if (strcmp(mntfromname, "fuse") == 0)
+   strcpy(mntfromname, "/dev/fuse");
+
+   strcpy(fstypename, "fusefs");
+   data = malloc(MNAMELEN, M_TEMP, M_WAITOK);
+   error = copyinstr(args->data, data, MNAMELEN - 1, NULL);
+   if (error != 0)
+   goto out;
+
+   fuse_options = data;
+   while ((fuse_option = strsep(_options, ",")) != NULL) {
+   fuse_name = strsep(_option, "=");
+   if (fuse_name == NULL || fuse_option == NULL)
+   goto out;
+   ma = mount_arg(ma, fuse_name, fuse_option, -1);
+   }
+
+   /*
+* The FUSE server uses Linux errno values instead of FreeBSD
+* ones; add a flag to tell fuse(4) to do errno translation.
+*/
+   ma = mount_arg(ma, "linux_errnos", "1", -1);
}
 
fsflags = 0;
@@ -1225,14 +1252,15 @@ linux_mount(struct thread *td, struct linux_mount_args
if (args->rwflag & LINUX_MS_REMOUNT)
fsflags |= MNT_UPDATE;
 
-   error = kernel_vmount(fsflags,
-   "fstype", fstypename,
-   "fspath", mntonname,
-   "from", mntfromname,
-   NULL);
+   ma = mount_arg(ma, "fstype", fstypename, -1);
+   ma = mount_arg(ma, "fspath", mntonname, -1);
+   ma = mount_arg(ma, "from", mntfromname, -1);
+   error = kernel_mount(ma, fsflags);
 out:
+   free(fstypename, M_TEMP);
free(mntonname, M_TEMP);
free(mntfromname, M_TEMP);
+   free(data, M_TEMP);
return (error);
 }
 

Modified: head/sys/fs/fuse/fuse_device.c
==
--- head/sys/fs/fuse/fuse_device.c  Mon Nov  9 05:20:02 2020
(r367516)
+++ head/sys/fs/fuse/fuse_device.c  Mon Nov  9 08:53:15 2020
(r367517)
@@ -89,6 +89,9 @@ __FBSDID("$FreeBSD$");
 #include "fuse_internal.h"
 #include "fuse_ipc.h"
 
+#include 
+#include 
+
 SDT_PROVIDER_DECLARE(fusefs);
 /* 
  * Fuse trace probe:
@@ -450,6 +453,15 @@ fuse_device_write(struct cdev *dev, struct uio *uio, i
}
if ((err = uiomove(, sizeof(struct fuse_out_header), uio)) != 0)
return (err);
+
+   if (data->linux_errnos != 0 && ohead.error != 0) {
+   err = -ohead.error;
+   if (err < 0 || err >= nitems(linux_to_bsd_errtbl))
+   return (EINVAL);
+
+   /* '-', because it will get flipped again below */
+   ohead.error = -linux_to_bsd_errtbl[err];
+   }
 
/*
 * We check header information (which is redundant) and compare it

Modified: head/sys/fs/fuse/fuse_ipc.h
==
--- head/sys/fs/fuse/fuse_ipc.h Mon Nov  9 05:20:02 2020(r367516)
+++ head/sys/fs/fuse/fuse_ipc.h Mon Nov  9 08:53:15 2020

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

2020-11-08 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun Nov  8 15:54:59 2020
New Revision: 367488
URL: https://svnweb.freebsd.org/changeset/base/367488

Log:
  Move syscall_thread_{enter,exit}() into the slow path.  This is only
  needed for syscalls from unloadable modules.
  
  Reviewed by:  kib
  MFC after:2 weeks
  Sponsored by: EPSRC
  Differential Revision:https://reviews.freebsd.org/D26988

Modified:
  head/sys/kern/kern_syscalls.c
  head/sys/kern/subr_syscall.c
  head/sys/sys/sysent.h

Modified: head/sys/kern/kern_syscalls.c
==
--- head/sys/kern/kern_syscalls.c   Sun Nov  8 14:08:00 2020
(r367487)
+++ head/sys/kern/kern_syscalls.c   Sun Nov  8 15:54:59 2020
(r367488)
@@ -80,10 +80,13 @@ syscall_thread_drain(struct sysent *se)
 }
 
 int
-_syscall_thread_enter(struct thread *td, struct sysent *se)
+syscall_thread_enter(struct thread *td, struct sysent *se)
 {
u_int32_t cnt, oldcnt;
 
+   KASSERT((se->sy_thrcnt & SY_THR_STATIC) == 0,
+   ("%s: not a static syscall", __func__));
+
do {
oldcnt = se->sy_thrcnt;
if ((oldcnt & (SY_THR_DRAINING | SY_THR_ABSENT)) != 0)
@@ -94,9 +97,12 @@ _syscall_thread_enter(struct thread *td, struct sysent
 }
 
 void
-_syscall_thread_exit(struct thread *td, struct sysent *se)
+syscall_thread_exit(struct thread *td, struct sysent *se)
 {
u_int32_t cnt, oldcnt;
+
+   KASSERT((se->sy_thrcnt & SY_THR_STATIC) == 0,
+   ("%s: not a static syscall", __func__));
 
do {
oldcnt = se->sy_thrcnt;

Modified: head/sys/kern/subr_syscall.c
==
--- head/sys/kern/subr_syscall.cSun Nov  8 14:08:00 2020
(r367487)
+++ head/sys/kern/subr_syscall.cSun Nov  8 15:54:59 2020
(r367488)
@@ -61,6 +61,7 @@ syscallenter(struct thread *td)
struct syscall_args *sa;
struct sysent *se;
int error, traced;
+   bool sy_thr_static;
 
VM_CNT_INC(v_syscall);
p = td->td_proc;
@@ -128,12 +129,6 @@ syscallenter(struct thread *td)
}
 #endif
 
-   error = syscall_thread_enter(td, se);
-   if (error != 0) {
-   td->td_errno = error;
-   goto retval;
-   }
-
/*
 * Fetch fast sigblock value at the time of syscall entry to
 * handle sleepqueue primitives which might call cursig().
@@ -145,8 +140,19 @@ syscallenter(struct thread *td)
KASSERT((td->td_pflags & TDP_NERRNO) == 0,
("%s: TDP_NERRNO set", __func__));
 
+   sy_thr_static = (se->sy_thrcnt & SY_THR_STATIC) != 0;
+
if (__predict_false(SYSTRACE_ENABLED() ||
-   AUDIT_SYSCALL_ENTER(sa->code, td))) {
+   AUDIT_SYSCALL_ENTER(sa->code, td) ||
+   !sy_thr_static)) {
+   if (!sy_thr_static) {
+   error = syscall_thread_enter(td, se);
+   if (error != 0) {
+   td->td_errno = error;
+   goto retval;
+   }
+   }
+
 #ifdef KDTRACE_HOOKS
/* Give the syscall:::entry DTrace probe a chance to fire. */
if (__predict_false(se->sy_entry != 0))
@@ -176,6 +182,9 @@ syscallenter(struct thread *td)
(*systrace_probe_func)(sa, SYSTRACE_RETURN,
error ? -1 : td->td_retval[0]);
 #endif
+
+   if (!sy_thr_static)
+   syscall_thread_exit(td, se);
} else {
error = (se->sy_call)(td, sa->args);
/* Save the latest error return value. */
@@ -184,7 +193,6 @@ syscallenter(struct thread *td)
else
td->td_errno = error;
}
-   syscall_thread_exit(td, se);
 
  retval:
KTR_STOP4(KTR_SYSC, "syscall", syscallname(p, sa->code),

Modified: head/sys/sys/sysent.h
==
--- head/sys/sys/sysent.h   Sun Nov  8 14:08:00 2020(r367487)
+++ head/sys/sys/sysent.h   Sun Nov  8 15:54:59 2020(r367488)
@@ -294,26 +294,8 @@ struct nosys_args;
 intlkmnosys(struct thread *, struct nosys_args *);
 intlkmressys(struct thread *, struct nosys_args *);
 
-int_syscall_thread_enter(struct thread *td, struct sysent *se);
-void   _syscall_thread_exit(struct thread *td, struct sysent *se);
-
-static inline int
-syscall_thread_enter(struct thread *td, struct sysent *se)
-{
-
-   if (__predict_true((se->sy_thrcnt & SY_THR_STATIC) != 0))
-   return (0);
-   return (_syscall_thread_enter(td, se));
-}
-
-static inline void
-syscall_thread_exit(struct thread *td, struct sysent *se)
-{
-
-   if (__predict_true((se->sy_thrcnt & SY_THR_STATIC) != 0))
-   return;
-   _syscall_thread_exit(td, se);
-}

svn commit: r367445 - head/sys/kern

2020-11-07 Thread Edward Tomasz Napierala
Author: trasz
Date: Sat Nov  7 13:09:51 2020
New Revision: 367445
URL: https://svnweb.freebsd.org/changeset/base/367445

Log:
  Move TDB_USERWR check under 'if (traced)'.
  
  If we hadn't been traced in the first place when syscallenter()
  started executing, we can ignore TDB_USERWR.  TDB_USERWR can get set,
  sure, but if it does, it's because the debugger raced with the syscall,
  and it cannot depend on winning that race.
  
  Reviewed by:  kib
  MFC after:2 weeks
  Sponsored by: EPSRC
  Differential Revision:https://reviews.freebsd.org/D26585

Modified:
  head/sys/kern/subr_syscall.c

Modified: head/sys/kern/subr_syscall.c
==
--- head/sys/kern/subr_syscall.cSat Nov  7 05:10:46 2020
(r367444)
+++ head/sys/kern/subr_syscall.cSat Nov  7 13:09:51 2020
(r367445)
@@ -97,21 +97,22 @@ syscallenter(struct thread *td)
if (p->p_ptevents & PTRACE_SCE)
ptracestop((td), SIGTRAP, NULL);
PROC_UNLOCK(p);
-   }
-   if (__predict_false((td->td_dbgflags & TDB_USERWR) != 0)) {
-   /*
-* Reread syscall number and arguments if debugger
-* modified registers or memory.
-*/
-   error = (p->p_sysent->sv_fetch_syscall_args)(td);
-   se = sa->callp;
+
+   if ((td->td_dbgflags & TDB_USERWR) != 0) {
+   /*
+* Reread syscall number and arguments if debugger
+* modified registers or memory.
+*/
+   error = (p->p_sysent->sv_fetch_syscall_args)(td);
+   se = sa->callp;
 #ifdef KTRACE
-   if (KTRPOINT(td, KTR_SYSCALL))
-   ktrsyscall(sa->code, se->sy_narg, sa->args);
+   if (KTRPOINT(td, KTR_SYSCALL))
+   ktrsyscall(sa->code, se->sy_narg, sa->args);
 #endif
-   if (error != 0) {
-   td->td_errno = error;
-   goto retval;
+   if (error != 0) {
+   td->td_errno = error;
+   goto retval;
+   }
}
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367430 - head/sys/powerpc/include

2020-11-06 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Nov  6 19:27:27 2020
New Revision: 367430
URL: https://svnweb.freebsd.org/changeset/base/367430

Log:
  Make powerpc use MAXARGS (defined as 8) instead of hardcoding '10'.
  This brings its 'struct syscall_args' in sync with other architectures.
  
  Reviewed by:  bdragon, jhibbits
  MFC after:2 weeks
  Sponsored by: EPSRC
  Differential Revision:https://reviews.freebsd.org/D26605

Modified:
  head/sys/powerpc/include/proc.h

Modified: head/sys/powerpc/include/proc.h
==
--- head/sys/powerpc/include/proc.h Fri Nov  6 19:19:51 2020
(r367429)
+++ head/sys/powerpc/include/proc.h Fri Nov  6 19:27:27 2020
(r367430)
@@ -59,10 +59,11 @@ struct mdproc {
 #defineKINFO_PROC_SIZE 816
 #endif
 
+#defineMAXARGS 8
 struct syscall_args {
u_int code;
struct sysent *callp;
-   register_t args[10];
+   register_t args[MAXARGS];
 };
 
 #ifdef _KERNEL
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367429 - in head/sys/mips: include mips

2020-11-06 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Nov  6 19:19:51 2020
New Revision: 367429
URL: https://svnweb.freebsd.org/changeset/base/367429

Log:
  Remove 'struct trapframe' pointer from mips64's 'struct syscall_args'.
  While here, use MAXARGS.  This brings its 'struct syscall_args' in sync
  with most other architectures.
  
  Reviewed by:  arichardson, brooks
  MFC after:2 weeks
  Sponsored by: EPSRC
  Differential Revision:https://reviews.freebsd.org/D26619

Modified:
  head/sys/mips/include/proc.h
  head/sys/mips/mips/trap.c

Modified: head/sys/mips/include/proc.h
==
--- head/sys/mips/include/proc.hFri Nov  6 19:04:20 2020
(r367428)
+++ head/sys/mips/include/proc.hFri Nov  6 19:19:51 2020
(r367429)
@@ -81,11 +81,11 @@ struct mdproc {
size_t  md_tls_tcb_offset;  /* TCB offset */
 };
 
+#defineMAXARGS 8
 struct syscall_args {
u_int code;
struct sysent *callp;
-   register_t args[8];
-   struct trapframe *trapframe;
+   register_t args[MAXARGS];
 };
 
 #ifdef __mips_n64

Modified: head/sys/mips/mips/trap.c
==
--- head/sys/mips/mips/trap.c   Fri Nov  6 19:04:20 2020(r367428)
+++ head/sys/mips/mips/trap.c   Fri Nov  6 19:19:51 2020(r367429)
@@ -349,9 +349,9 @@ cpu_fetch_syscall_args(struct thread *td)
bzero(sa->args, sizeof(sa->args));
 
/* compute next PC after syscall instruction */
-   td->td_pcb->pcb_tpc = sa->trapframe->pc; /* Remember if restart */
-   if (DELAYBRANCH(sa->trapframe->cause))   /* Check BD bit */
-   locr0->pc = MipsEmulateBranch(locr0, sa->trapframe->pc, 0, 0);
+   td->td_pcb->pcb_tpc = locr0->pc; /* Remember if restart */
+   if (DELAYBRANCH(locr0->cause))   /* Check BD bit */
+   locr0->pc = MipsEmulateBranch(locr0, locr0->pc, 0, 0);
else
locr0->pc += sizeof(int);
sa->code = locr0->v0;
@@ -781,7 +781,6 @@ dofault:
 
case T_SYSCALL + T_USER:
{
-   td->td_sa.trapframe = trapframe;
syscallenter(td);
 
 #if !defined(SMP) && (defined(DDB) || defined(DEBUG))
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367394 - in head/sys/arm: arm include

2020-11-05 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Nov  5 18:10:03 2020
New Revision: 367394
URL: https://svnweb.freebsd.org/changeset/base/367394

Log:
  Remove the 'nap' field from ARM's 'struct syscall_args', to bring it
  in sync with (most) other architectures.  No functional changes.
  
  Reviewed by:  manu
  Tested by:mmel
  MFC after:2 weeks
  Sponsored by: EPSRC
  Differential Revision:https://reviews.freebsd.org/D26604

Modified:
  head/sys/arm/arm/syscall.c
  head/sys/arm/include/proc.h

Modified: head/sys/arm/arm/syscall.c
==
--- head/sys/arm/arm/syscall.c  Thu Nov  5 17:10:14 2020(r367393)
+++ head/sys/arm/arm/syscall.c  Thu Nov  5 18:10:03 2020(r367394)
@@ -102,17 +102,19 @@ cpu_fetch_syscall_args(struct thread *td)
struct proc *p;
register_t *ap;
struct syscall_args *sa;
+   u_int nap;
int error;
 
+   nap = 4;
sa = >td_sa;
sa->code = td->td_frame->tf_r7;
ap = >td_frame->tf_r0;
if (sa->code == SYS_syscall) {
sa->code = *ap++;
-   sa->nap--;
+   nap--;
} else if (sa->code == SYS___syscall) {
sa->code = ap[_QUAD_LOWWORD];
-   sa->nap -= 2;
+   nap -= 2;
ap += 2;
}
p = td->td_proc;
@@ -121,11 +123,10 @@ cpu_fetch_syscall_args(struct thread *td)
else
sa->callp = >p_sysent->sv_table[sa->code];
error = 0;
-   memcpy(sa->args, ap, sa->nap * sizeof(register_t));
-   if (sa->callp->sy_narg > sa->nap) {
+   memcpy(sa->args, ap, nap * sizeof(register_t));
+   if (sa->callp->sy_narg > nap) {
error = copyin((void *)td->td_frame->tf_usr_sp, sa->args +
-   sa->nap, (sa->callp->sy_narg - sa->nap) *
-   sizeof(register_t));
+   nap, (sa->callp->sy_narg - nap) * sizeof(register_t));
}
if (error == 0) {
td->td_retval[0] = 0;
@@ -140,7 +141,6 @@ static void
 syscall(struct thread *td, struct trapframe *frame)
 {
 
-   td->td_sa.nap = 4;
syscallenter(td);
syscallret(td);
 }

Modified: head/sys/arm/include/proc.h
==
--- head/sys/arm/include/proc.h Thu Nov  5 17:10:14 2020(r367393)
+++ head/sys/arm/include/proc.h Thu Nov  5 18:10:03 2020(r367394)
@@ -82,7 +82,6 @@ struct syscall_args {
u_int code;
struct sysent *callp;
register_t args[MAXARGS];
-   u_int nap;
 } __aligned(8);
 
 #endif /* !_MACHINE_PROC_H_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-11-04 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Nov  4 21:39:04 2020
New Revision: 367348
URL: https://svnweb.freebsd.org/changeset/base/367348

Log:
  Unbreak buildworld after r367339.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/compat/linux/linux_errno.h

Modified: head/sys/compat/linux/linux_errno.h
==
--- head/sys/compat/linux/linux_errno.h Wed Nov  4 21:23:25 2020
(r367347)
+++ head/sys/compat/linux/linux_errno.h Wed Nov  4 21:39:04 2020
(r367348)
@@ -180,8 +180,6 @@
 #defineLINUX_ERFKILL   132
 #defineLINUX_EHWPOISON 133
 
-#ifdef _KERNEL
 #defineLINUX_ELAST LINUX_EHWPOISON
-#endif
 
 #endif /* _LINUX_ERRNO_H_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-11-04 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Nov  4 19:54:18 2020
New Revision: 367339
URL: https://svnweb.freebsd.org/changeset/base/367339

Log:
  Add linux_to_bsd_errtbl[], mapping Linux errnos to their BSD counterparts.
  This will be used by fuse(4).
  
  Reviewed by:  asomers
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26974

Modified:
  head/sys/compat/linux/linux_errno.c
  head/sys/compat/linux/linux_errno.h
  head/sys/compat/linux/linux_errno.inc

Modified: head/sys/compat/linux/linux_errno.c
==
--- head/sys/compat/linux/linux_errno.c Wed Nov  4 18:23:59 2020
(r367338)
+++ head/sys/compat/linux/linux_errno.c Wed Nov  4 19:54:18 2020
(r367339)
@@ -31,5 +31,11 @@ linux_check_errtbl(void)
KASSERT(linux_errtbl[i] != 0,
("%s: linux_errtbl[%d] == 0", __func__, i));
}
+
+   for (i = 1; i < nitems(linux_to_bsd_errtbl); i++) {
+   KASSERT(linux_to_bsd_errtbl[i] != 0,
+   ("%s: linux_to_bsd_errtbl[%d] == 0", __func__, i));
+   }
+
 }
 #endif

Modified: head/sys/compat/linux/linux_errno.h
==
--- head/sys/compat/linux/linux_errno.h Wed Nov  4 18:23:59 2020
(r367338)
+++ head/sys/compat/linux/linux_errno.h Wed Nov  4 19:54:18 2020
(r367339)
@@ -180,4 +180,8 @@
 #defineLINUX_ERFKILL   132
 #defineLINUX_EHWPOISON 133
 
+#ifdef _KERNEL
+#defineLINUX_ELAST LINUX_EHWPOISON
+#endif
+
 #endif /* _LINUX_ERRNO_H_ */

Modified: head/sys/compat/linux/linux_errno.inc
==
--- head/sys/compat/linux/linux_errno.inc   Wed Nov  4 18:23:59 2020
(r367338)
+++ head/sys/compat/linux/linux_errno.inc   Wed Nov  4 19:54:18 2020
(r367339)
@@ -160,3 +160,170 @@ static const int linux_errtbl[ELAST + 1] = {
 
 _Static_assert(ELAST == 97,
 "missing errno entries in linux_errtbl");
+
+static const int linux_to_bsd_errtbl[LINUX_ELAST + 1] = {
+   /* [0, 9] */
+   [0] = 0,
+   [LINUX_EPERM] = EPERM,
+   [LINUX_ENOENT] = ENOENT,
+   [LINUX_ESRCH] = ESRCH,
+   [LINUX_EINTR] = EINTR,
+   [LINUX_EIO] = EIO,
+   [LINUX_ENXIO] = ENXIO,
+   [LINUX_E2BIG] = E2BIG,
+   [LINUX_ENOEXEC] = ENOENT,
+   [LINUX_EBADF] = EBADF,
+
+   /* [10, 19] */
+   [LINUX_ECHILD] = ECHILD,
+   [LINUX_EAGAIN] = EAGAIN,
+   [LINUX_ENOMEM] = ENOMEM,
+   [LINUX_EACCES] = EACCES,
+   [LINUX_EFAULT] = EFAULT,
+   [LINUX_ENOTBLK] = ENOTBLK,
+   [LINUX_EBUSY] = EBUSY,
+   [LINUX_EEXIST] = EEXIST,
+   [LINUX_EXDEV] = EXDEV,
+   [LINUX_ENODEV] = ENODEV,
+
+   /* [20, 29] */
+   [LINUX_ENOTDIR] = ENOTDIR,
+   [LINUX_EISDIR] = EISDIR,
+   [LINUX_EINVAL] = EINVAL,
+   [LINUX_ENFILE] = ENFILE,
+   [LINUX_EMFILE] = EMFILE,
+   [LINUX_ENOTTY] = ENOTTY,
+   [LINUX_ETXTBSY] = ETXTBSY,
+   [LINUX_EFBIG] = EFBIG,
+   [LINUX_ENOSPC] = ENOSPC,
+   [LINUX_ESPIPE] = ESPIPE,
+
+   /* [30, 39] */
+   [LINUX_EROFS] = EROFS,
+   [LINUX_EMLINK] = EMLINK,
+   [LINUX_EPIPE] = EPIPE,
+   [LINUX_EDOM] = EDOM,
+   [LINUX_ERANGE] = ERANGE,
+   [LINUX_EDEADLK] = EDEADLK,
+   [LINUX_ENAMETOOLONG] = ENAMETOOLONG,
+   [LINUX_ENOLCK] = ENOLCK,
+   [LINUX_ENOSYS] = ENOSYS,
+   [LINUX_ENOTEMPTY] = ENOTEMPTY,
+
+   /* [40, 49] */
+   [LINUX_ELOOP] = ELOOP,
+   [41] = EINVAL,
+   [LINUX_ENOMSG] = ENOMSG,
+   [LINUX_EIDRM] = EIDRM,
+   [LINUX_ECHRNG] = EINVAL,/* XXX */
+   [LINUX_EL2NSYNC] = EINVAL,  /* XXX */
+   [LINUX_EL3HLT] = EINVAL,/* XXX */
+   [LINUX_EL3RST] = EINVAL,/* XXX */
+   [LINUX_ELNRNG] = EINVAL,/* XXX */
+   [LINUX_EUNATCH] = EINVAL,   /* XXX */
+
+   /* [50, 59] */
+   [LINUX_ENOCSI] = EINVAL,/* XXX */
+   [LINUX_EL2HLT] = EINVAL,/* XXX */
+   [LINUX_EBADE] = EINVAL, /* XXX */
+   [LINUX_EBADR] = EINVAL, /* XXX */
+   [LINUX_EXFULL] = EINVAL,/* XXX */
+   [LINUX_ENOANO] = EINVAL,/* XXX */
+   [LINUX_EBADRQC] = EINVAL,   /* XXX */
+   [LINUX_EBADSLT] = EINVAL,   /* XXX */
+   [58] = EINVAL,
+   [LINUX_EBFONT] = EINVAL,/* XXX */
+
+   /* [60, 69] */
+   [LINUX_ENOSTR] = EINVAL,/* XXX */
+   [LINUX_ENODATA] = ENOATTR,  /* XXX */
+   [LINUX_ENOTIME] = EINVAL,   /* XXX */
+   [LINUX_ENOSR] = EINVAL, /* XXX */
+   [LINUX_ENONET] = EINVAL,/* XXX */
+   [LINUX_ENOPKG] = EINVAL,/* XXX */
+   [LINUX_EREMOTE] = EREMOTE,
+   [LINUX_ENOLINK] = ENOLINK,
+   [LINUX_EADV] = EINVAL,  /* XXX */
+ 

svn commit: r367301 - in head: lib/libsysdecode sys/compat/linux sys/modules/linux_common

2020-11-03 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Nov  3 19:12:33 2020
New Revision: 367301
URL: https://svnweb.freebsd.org/changeset/base/367301

Log:
  Make linux_errtbl[] static.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D27004

Modified:
  head/lib/libsysdecode/errno.c
  head/sys/compat/linux/linux_emul.h
  head/sys/compat/linux/linux_errno.inc
  head/sys/modules/linux_common/Makefile

Modified: head/lib/libsysdecode/errno.c
==
--- head/lib/libsysdecode/errno.c   Tue Nov  3 18:13:42 2020
(r367300)
+++ head/lib/libsysdecode/errno.c   Tue Nov  3 19:12:33 2020
(r367301)
@@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$");
 
 #if defined(__aarch64__) || defined(__amd64__) || defined(__i386__)
 #include 
-static
 #include 
 #endif
 

Modified: head/sys/compat/linux/linux_emul.h
==
--- head/sys/compat/linux/linux_emul.h  Tue Nov  3 18:13:42 2020
(r367300)
+++ head/sys/compat/linux/linux_emul.h  Tue Nov  3 19:12:33 2020
(r367301)
@@ -80,6 +80,4 @@ struct linux_pemuldata {
 
 struct linux_pemuldata *pem_find(struct proc *);
 
-extern const int linux_errtbl[];
-
 #endif /* !_LINUX_EMUL_H_ */

Modified: head/sys/compat/linux/linux_errno.inc
==
--- head/sys/compat/linux/linux_errno.inc   Tue Nov  3 18:13:42 2020
(r367300)
+++ head/sys/compat/linux/linux_errno.inc   Tue Nov  3 19:12:33 2020
(r367301)
@@ -38,7 +38,7 @@
  * XXX: The "XXX" comments below should be replaced with rationale
  *  for the errno value chosen.
  */
-const int linux_errtbl[ELAST + 1] = {
+static const int linux_errtbl[ELAST + 1] = {
/* [0, 9] */
[0] = -0,
[EPERM] = -LINUX_EPERM,

Modified: head/sys/modules/linux_common/Makefile
==
--- head/sys/modules/linux_common/Makefile  Tue Nov  3 18:13:42 2020
(r367300)
+++ head/sys/modules/linux_common/Makefile  Tue Nov  3 19:12:33 2020
(r367301)
@@ -9,7 +9,6 @@ SRCS=   linux_common.c linux_mib.c linux_mmap.c linux_ut
 
 EXPORT_SYMS=
 EXPORT_SYMS+=  linux_emul_path
-EXPORT_SYMS+=  linux_errtbl
 EXPORT_SYMS+=  linux_ioctl_register_handler
 EXPORT_SYMS+=  linux_ioctl_unregister_handler
 EXPORT_SYMS+=  linux_get_osname
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-11-03 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Nov  3 14:44:33 2020
New Revision: 367298
URL: https://svnweb.freebsd.org/changeset/base/367298

Log:
  Fix rookie mistake - it's nitems(), not sizeof().
  
  Reported by:  xtouqh_icloud.com
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

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

Modified: head/sys/compat/linux/linux_errno.c
==
--- head/sys/compat/linux/linux_errno.c Tue Nov  3 14:41:49 2020
(r367297)
+++ head/sys/compat/linux/linux_errno.c Tue Nov  3 14:44:33 2020
(r367298)
@@ -27,7 +27,7 @@ linux_check_errtbl(void)
 {
int i;
 
-   for (i = 1; i < sizeof(linux_errtbl); i++) {
+   for (i = 1; i < nitems(linux_errtbl); i++) {
KASSERT(linux_errtbl[i] != 0,
("%s: linux_errtbl[%d] == 0", __func__, i));
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367139 - head/sys/compat/linprocfs

2020-10-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Oct 29 15:44:44 2020
New Revision: 367139
URL: https://svnweb.freebsd.org/changeset/base/367139

Log:
  Make linprocfs(4) print a warning when there's not enough room to fill
  /proc/self/maps.
  
  Submitted by: dchagin (earlier version)
  Reviewed by:  emaste (earlier version)
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D20576

Modified:
  head/sys/compat/linprocfs/linprocfs.c

Modified: head/sys/compat/linprocfs/linprocfs.c
==
--- head/sys/compat/linprocfs/linprocfs.c   Thu Oct 29 15:36:20 2020
(r367138)
+++ head/sys/compat/linprocfs/linprocfs.c   Thu Oct 29 15:44:44 2020
(r367139)
@@ -1252,6 +1252,10 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
*name ? " " : " ",
name
);
+   if (error == -1) {
+   linux_msg(td, "cannot fill /proc/self/maps; "
+   "consider bumping PFS_MAXBUFSIZ");
+   }
if (freename)
free(freename, M_TEMP);
vm_map_lock_read(map);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367138 - head/sys/riscv/riscv

2020-10-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Oct 29 15:36:20 2020
New Revision: 367138
URL: https://svnweb.freebsd.org/changeset/base/367138

Log:
  Optimize set_syscall_retval for riscv by predicting the return
  value to be zero.
  
  Reviewed by:  mhorne, kp
  MFC after:2 weeks
  Sponsored by: EPSRC
  Differential Revision:https://reviews.freebsd.org/D26990

Modified:
  head/sys/riscv/riscv/vm_machdep.c

Modified: head/sys/riscv/riscv/vm_machdep.c
==
--- head/sys/riscv/riscv/vm_machdep.c   Thu Oct 29 15:28:15 2020
(r367137)
+++ head/sys/riscv/riscv/vm_machdep.c   Thu Oct 29 15:36:20 2020
(r367138)
@@ -132,12 +132,14 @@ cpu_set_syscall_retval(struct thread *td, int error)
 
frame = td->td_frame;
 
-   switch (error) {
-   case 0:
+   if (__predict_true(error == 0)) {
frame->tf_a[0] = td->td_retval[0];
frame->tf_a[1] = td->td_retval[1];
frame->tf_t[0] = 0; /* syscall succeeded */
-   break;
+   return;
+   }
+
+   switch (error) {
case ERESTART:
frame->tf_sepc -= 4;/* prev instruction */
break;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367137 - head/sys/fs/nullfs

2020-10-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Oct 29 15:28:15 2020
New Revision: 367137
URL: https://svnweb.freebsd.org/changeset/base/367137

Log:
  Make it possible to mount nullfs(5) using plain mount(8)
  instead of mount_nullfs(8).
  
  Obviously you'd need to force mount(8) to not call
  mount_nullfs(8) to make use of it.
  
  Reviewed by:  kib
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26934

Modified:
  head/sys/fs/nullfs/null_vfsops.c

Modified: head/sys/fs/nullfs/null_vfsops.c
==
--- head/sys/fs/nullfs/null_vfsops.cThu Oct 29 14:44:09 2020
(r367136)
+++ head/sys/fs/nullfs/null_vfsops.cThu Oct 29 15:28:15 2020
(r367137)
@@ -104,7 +104,9 @@ nullfs_mount(struct mount *mp)
/*
 * Get argument
 */
-   error = vfs_getopt(mp->mnt_optnew, "target", (void **), );
+   error = vfs_getopt(mp->mnt_optnew, "from", (void **), );
+   if (error != 0)
+   error = vfs_getopt(mp->mnt_optnew, "target", (void **), 
);
if (error || target[len - 1] != '\0')
return (EINVAL);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-10-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Oct 29 14:42:51 2020
New Revision: 367135
URL: https://svnweb.freebsd.org/changeset/base/367135

Log:
  Fix typo.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/compat/linux/linux_errno.h

Modified: head/sys/compat/linux/linux_errno.h
==
--- head/sys/compat/linux/linux_errno.h Thu Oct 29 14:42:02 2020
(r367134)
+++ head/sys/compat/linux/linux_errno.h Thu Oct 29 14:42:51 2020
(r367135)
@@ -88,7 +88,7 @@
 #defineLINUX_EUNATCH   49
 
 #defineLINUX_ENOCSI50
-#defineLINUX_L2HLT 51
+#defineLINUX_EL2HLT51
 #defineLINUX_EBADE 52
 #defineLINUX_EBADR 53
 #defineLINUX_EXFULL54
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367132 - in head: lib/libsysdecode sys/compat/linux

2020-10-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Oct 29 14:23:52 2020
New Revision: 367132
URL: https://svnweb.freebsd.org/changeset/base/367132

Log:
  Add defines for Linux errno values and use them to make linux_errtbl[]
  more readable.  While here, add linux_check_errtbl() function to make
  sure we don't leave holes.
  
  No objections:emaste (earlier version)
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26972

Added:
  head/sys/compat/linux/linux_errno.h   (contents, props changed)
Modified:
  head/lib/libsysdecode/errno.c
  head/sys/compat/linux/linux.h
  head/sys/compat/linux/linux_common.c
  head/sys/compat/linux/linux_errno.c
  head/sys/compat/linux/linux_errno.inc

Modified: head/lib/libsysdecode/errno.c
==
--- head/lib/libsysdecode/errno.c   Thu Oct 29 14:21:25 2020
(r367131)
+++ head/lib/libsysdecode/errno.c   Thu Oct 29 14:23:52 2020
(r367132)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #if defined(__aarch64__) || defined(__amd64__) || defined(__i386__)
+#include 
 static
 #include 
 #endif

Modified: head/sys/compat/linux/linux.h
==
--- head/sys/compat/linux/linux.h   Thu Oct 29 14:21:25 2020
(r367131)
+++ head/sys/compat/linux/linux.h   Thu Oct 29 14:23:52 2020
(r367132)
@@ -197,5 +197,6 @@ int linux_to_bsd_bits_(int value, struct bsd_to_linux_
 #defineBITMAP_1t1_LINUX(_name) BITMAP_EASY_LINUX(_name, LINUX_##_name)
 
 int bsd_to_linux_errno(int error);
+void linux_check_errtbl(void);
 
 #endif /* _LINUX_MI_H_ */

Modified: head/sys/compat/linux/linux_common.c
==
--- head/sys/compat/linux/linux_common.cThu Oct 29 14:21:25 2020
(r367131)
+++ head/sys/compat/linux/linux_common.cThu Oct 29 14:23:52 2020
(r367132)
@@ -67,6 +67,9 @@ linux_common_modevent(module_t mod, int type, void *da
 
switch(type) {
case MOD_LOAD:
+#ifdef INVARIANTS
+   linux_check_errtbl();
+#endif
linux_dev_shm_create();
linux_osd_jail_register();
linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,

Modified: head/sys/compat/linux/linux_errno.c
==
--- head/sys/compat/linux/linux_errno.c Thu Oct 29 14:21:25 2020
(r367131)
+++ head/sys/compat/linux/linux_errno.c Thu Oct 29 14:23:52 2020
(r367132)
@@ -8,6 +8,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 
 int
@@ -19,3 +20,16 @@ bsd_to_linux_errno(int error)
 
return (linux_errtbl[error]);
 }
+
+#ifdef INVARIANTS
+void
+linux_check_errtbl(void)
+{
+   int i;
+
+   for (i = 1; i < sizeof(linux_errtbl); i++) {
+   KASSERT(linux_errtbl[i] != 0,
+   ("%s: linux_errtbl[%d] == 0", __func__, i));
+   }
+}
+#endif

Added: head/sys/compat/linux/linux_errno.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/compat/linux/linux_errno.h Thu Oct 29 14:23:52 2020
(r367132)
@@ -0,0 +1,183 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2020 The FreeBSD Foundation
+ *
+ * This software was developed by Edward Tomasz Napierala under sponsorship
+ * from the FreeBSD Foundation.
+ *
+ * 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$
+ */
+

svn commit: r367107 - head/sys/kern

2020-10-28 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Oct 28 14:43:38 2020
New Revision: 367107
URL: https://svnweb.freebsd.org/changeset/base/367107

Log:
  Add local variable to store the sysent pointer.  Just a cleanup,
  no functional changes.
  
  Reviewed by:  kib (earlier version)
  MFC after:2 weeks
  Sponsored by: EPSRC
  Differential Revision:https://reviews.freebsd.org/D26977

Modified:
  head/sys/kern/subr_syscall.c

Modified: head/sys/kern/subr_syscall.c
==
--- head/sys/kern/subr_syscall.cWed Oct 28 14:16:08 2020
(r367106)
+++ head/sys/kern/subr_syscall.cWed Oct 28 14:43:38 2020
(r367107)
@@ -59,6 +59,7 @@ syscallenter(struct thread *td)
 {
struct proc *p;
struct syscall_args *sa;
+   struct sysent *se;
int error, traced;
 
VM_CNT_INC(v_syscall);
@@ -77,9 +78,10 @@ syscallenter(struct thread *td)
PROC_UNLOCK(p);
}
error = (p->p_sysent->sv_fetch_syscall_args)(td);
+   se = sa->callp;
 #ifdef KTRACE
if (KTRPOINT(td, KTR_SYSCALL))
-   ktrsyscall(sa->code, sa->callp->sy_narg, sa->args);
+   ktrsyscall(sa->code, se->sy_narg, sa->args);
 #endif
KTR_START4(KTR_SYSC, "syscall", syscallname(p, sa->code),
(uintptr_t)td, "pid:%d", td->td_proc->p_pid, "arg0:%p", sa->args[0],
@@ -102,9 +104,10 @@ syscallenter(struct thread *td)
 * modified registers or memory.
 */
error = (p->p_sysent->sv_fetch_syscall_args)(td);
+   se = sa->callp;
 #ifdef KTRACE
if (KTRPOINT(td, KTR_SYSCALL))
-   ktrsyscall(sa->code, sa->callp->sy_narg, sa->args);
+   ktrsyscall(sa->code, se->sy_narg, sa->args);
 #endif
if (error != 0) {
td->td_errno = error;
@@ -118,13 +121,13 @@ syscallenter(struct thread *td)
 * flagged with SYF_CAPENABLED.
 */
if (__predict_false(IN_CAPABILITY_MODE(td) &&
-   !(sa->callp->sy_flags & SYF_CAPENABLED))) {
+   (se->sy_flags & SYF_CAPENABLED) == 0)) {
td->td_errno = error = ECAPMODE;
goto retval;
}
 #endif
 
-   error = syscall_thread_enter(td, sa->callp);
+   error = syscall_thread_enter(td, se);
if (error != 0) {
td->td_errno = error;
goto retval;
@@ -145,10 +148,10 @@ syscallenter(struct thread *td)
AUDIT_SYSCALL_ENTER(sa->code, td))) {
 #ifdef KDTRACE_HOOKS
/* Give the syscall:::entry DTrace probe a chance to fire. */
-   if (__predict_false(sa->callp->sy_entry != 0))
+   if (__predict_false(se->sy_entry != 0))
(*systrace_probe_func)(sa, SYSTRACE_ENTRY, 0);
 #endif
-   error = (sa->callp->sy_call)(td, sa->args);
+   error = (se->sy_call)(td, sa->args);
/* Save the latest error return value. */
if (__predict_false((td->td_pflags & TDP_NERRNO) != 0))
td->td_pflags &= ~TDP_NERRNO;
@@ -168,19 +171,19 @@ syscallenter(struct thread *td)
 
 #ifdef KDTRACE_HOOKS
/* Give the syscall:::return DTrace probe a chance to fire. */
-   if (__predict_false(sa->callp->sy_return != 0))
+   if (__predict_false(se->sy_return != 0))
(*systrace_probe_func)(sa, SYSTRACE_RETURN,
error ? -1 : td->td_retval[0]);
 #endif
} else {
-   error = (sa->callp->sy_call)(td, sa->args);
+   error = (se->sy_call)(td, sa->args);
/* Save the latest error return value. */
if (__predict_false((td->td_pflags & TDP_NERRNO) != 0))
td->td_pflags &= ~TDP_NERRNO;
else
td->td_errno = error;
}
-   syscall_thread_exit(td, sa->callp);
+   syscall_thread_exit(td, se);
 
  retval:
KTR_STOP4(KTR_SYSC, "syscall", syscallname(p, sa->code),
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-10-28 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Oct 28 14:16:08 2020
New Revision: 367106
URL: https://svnweb.freebsd.org/changeset/base/367106

Log:
  Make linux_errtbl a bit more readable by using named initializers.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26970

Modified:
  head/sys/compat/linux/linux_errno.inc

Modified: head/sys/compat/linux/linux_errno.inc
==
--- head/sys/compat/linux/linux_errno.inc   Wed Oct 28 13:46:11 2020
(r367105)
+++ head/sys/compat/linux/linux_errno.inc   Wed Oct 28 14:16:08 2020
(r367106)
@@ -36,113 +36,123 @@
  *include/uapi/asm-generic/errno.h
  */
 const int linux_errtbl[ELAST + 1] = {
-   -0,
-   -1,
-   -2,
-   -3,
-   -4,
-   -5,
-   -6,
-   -7,
-   -8,
-   -9,
+   /* [0, 9] */
+   [0] = -0,
+   [EPERM] = -1,
+   [ENOENT] = -2,
+   [ESRCH] = -3,
+   [EINTR] = -4,
+   [EIO] = -5,
+   [ENXIO] = -6,
+   [E2BIG] = -7,
+   [ENOEXEC] = -8,
+   [EBADF] = -9,
 
-   -10,
-   -35,/* EDEADLK */
-   -12,
-   -13,
-   -14,
-   -15,
-   -16,
-   -17,
-   -18,
-   -19,
+   /* [10, 19] */
+   [ECHILD] = -10,
+   [EDEADLK] = -35,
+   [ENOMEM] = -12,
+   [EACCES] = -13,
+   [EFAULT] = -14,
+   [ENOTBLK] = -15,
+   [EBUSY] = -16,
+   [EEXIST] = -17,
+   [EXDEV] = -18,
+   [ENODEV] = -19,
 
-   -20,
-   -21,
-   -22,
-   -23,
-   -24,
-   -25,
-   -26,
-   -27,
-   -28,
-   -29,
+   /* [20, 29] */
+   [ENOTDIR] = -20,
+   [EISDIR] = -21,
+   [EINVAL] = -22,
+   [ENFILE] = -23,
+   [EMFILE] = -24,
+   [ENOTTY] = -25,
+   [ETXTBSY] = -26,
+   [EFBIG] = -27,
+   [ENOSPC] = -28,
+   [ESPIPE] = -29,
 
-   -30,
-   -31,
-   -32,
-   -33,
-   -34,
-   -11,/* EAGAIN */
-   -115,
-   -114,
-   -88,
-   -89,
+   /* [30, 39] */
+   [EROFS] = -30,
+   [EMLINK] = -31,
+   [EPIPE] = -32,
+   [EDOM] = -33,
+   [ERANGE] = -34,
+   [EAGAIN] = -11,
+   [EINPROGRESS] = -115,
+   [EALREADY] = -114,
+   [ENOTSOCK] = -88,
+   [EDESTADDRREQ] = -89,
 
-   -90,
-   -91,
-   -92,
-   -93,
-   -94,
-   -95,
-   -96,
-   -97,
-   -98,
-   -99,
+   /* [40, 49] */
+   [EMSGSIZE] = -90,
+   [EPROTOTYPE] = -91,
+   [ENOPROTOOPT] = -92,
+   [EPROTONOSUPPORT] = -93,
+   [ESOCKTNOSUPPORT] = -94,
+   [EOPNOTSUPP] = -95,
+   [EPFNOSUPPORT] = -96,
+   [EAFNOSUPPORT] = -97,
+   [EADDRINUSE] = -98,
+   [EADDRNOTAVAIL] = -99,
 
-   -100,
-   -101,
-   -102,
-   -103,
-   -104,
-   -105,
-   -106,
-   -107,
-   -108,
-   -109,
+   /* [50, 59] */
+   [ENETDOWN] = -100,
+   [ENETUNREACH] = -101,
+   [ENETRESET] = -102,
+   [ECONNABORTED] = -103,
+   [ECONNRESET] = -104,
+   [ENOBUFS] = -105,
+   [EISCONN] = -106,
+   [ENOTCONN] = -107,
+   [ESHUTDOWN] = -108,
+   [ETOOMANYREFS] = -109,
 
-   -110,
-   -111,
-   -40,
-   -36,
-   -112,
-   -113,
-   -39,
-   -11,
-   -87,
-   -122,
+   /* [60, 69] */
+   [ETIMEDOUT] = -110,
+   [ECONNREFUSED] = -111,
+   [ELOOP] = -40,
+   [ENAMETOOLONG] = -36,
+   [EHOSTDOWN] = -112,
+   [EHOSTUNREACH] = -113,
+   [ENOTEMPTY] = -39,
+   [EPROCLIM] = -11,
+   [EUSERS] = -87,
+   [EDQUOT] = -122,
 
-   -116,
-   -66,
-   -6, /* EBADRPC -> ENXIO */
-   -6, /* ERPCMISMATCH -> ENXIO */
-   -6, /* EPROGUNAVAIL -> ENXIO */
-   -6, /* EPROGMISMATCH -> ENXIO */
-   -6, /* EPROCUNAVAIL -> ENXIO */
-   -37,
-   -38,
-   -9,
+   /* [70, 79] */
+   [ESTALE] = -116,
+   [EREMOTE] = -66,
+   [EBADRPC] = -6, /* EBADRPC -> ENXIO */
+   [ERPCMISMATCH] = -6,/* ERPCMISMATCH -> ENXIO */
+   [EPROGUNAVAIL] = -6,/* EPROGUNAVAIL -> ENXIO */
+   [EPROGMISMATCH] = -6,   /* EPROGMISMATCH -> ENXIO */
+   [EPROCUNAVAIL] = -6,/* EPROCUNAVAIL -> ENXIO */
+   [ENOLCK] = -37,
+   [ENOSYS] = -38,
+   [EFTYPE] = -9,
 
-   -6, /* EAUTH -> ENXIO */
-   -6, /* ENEEDAUTH -> ENXIO */
-   -43,
-   -42,
-   -75,
-   -125,
-   -84,
-   -61,
-   -22,/* EDOOFUS -> EINVAL */
-   -74,
+   /* [80, 89] */
+   [EAUTH] = -6,   /* EAUTH -> ENXIO */
+   [ENEEDAUTH] = -6,   /* ENEEDAUTH -> ENXIO */
+   [EIDRM] = -43,
+   [ENOMSG] = -42,
+   [EOVERFLOW] = -75,
+   [ECANCELED] = -125,
+   [EILSEQ] = -84,
+   [ENOATTR] = -61,
+   [EDOOFUS] = -22,/* EDOOFUS -> EINVAL 

svn commit: r367105 - in head: lib/geom/mountver lib/libc/posix1e lib/libc/sys sbin/mdconfig/tests share/man/man4 share/man/man5 share/man/man7 sys/amd64/linux sys/cam/ctl sys/cddl/compat/opensolar...

2020-10-28 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Oct 28 13:46:11 2020
New Revision: 367105
URL: https://svnweb.freebsd.org/changeset/base/367105

Log:
  Drop "All rights reserved" from all my stuff.  This includes
  Foundation copyrights, approved by emaste@.  It does not include
  files which carry other people's copyrights; if you're one
  of those people, feel free to make similar change.
  
  Reviewed by:  emaste, imp, gbe (manpages)
  Differential Revision:https://reviews.freebsd.org/D26980

Modified:
  head/lib/geom/mountver/geom_mountver.c
  head/lib/geom/mountver/gmountver.8
  head/lib/libc/posix1e/acl_add_flag_np.3
  head/lib/libc/posix1e/acl_branding.c
  head/lib/libc/posix1e/acl_clear_flags_np.3
  head/lib/libc/posix1e/acl_compat.c
  head/lib/libc/posix1e/acl_delete_flag_np.3
  head/lib/libc/posix1e/acl_flag.c
  head/lib/libc/posix1e/acl_from_text_nfs4.c
  head/lib/libc/posix1e/acl_get_brand_np.3
  head/lib/libc/posix1e/acl_get_entry_type_np.3
  head/lib/libc/posix1e/acl_get_flag_np.3
  head/lib/libc/posix1e/acl_get_flagset_np.3
  head/lib/libc/posix1e/acl_is_trivial_np.3
  head/lib/libc/posix1e/acl_set_entry_type_np.3
  head/lib/libc/posix1e/acl_set_flagset_np.3
  head/lib/libc/posix1e/acl_strip_np.3
  head/lib/libc/posix1e/acl_support_nfs4.c
  head/lib/libc/posix1e/acl_to_text_nfs4.c
  head/lib/libc/sys/getloginclass.2
  head/sbin/mdconfig/tests/mdconfig_test.sh
  head/share/man/man4/cfumass.4
  head/share/man/man4/iscsi.4
  head/share/man/man4/rctl.4
  head/share/man/man5/autofs.5
  head/share/man/man7/development.7
  head/sys/amd64/linux/linux_ptrace.c
  head/sys/cam/ctl/ctl_frontend_iscsi.c
  head/sys/cam/ctl/ctl_frontend_iscsi.h
  head/sys/cddl/compat/opensolaris/kern/opensolaris_acl.c
  head/sys/contrib/openzfs/module/os/freebsd/spl/spl_acl.c
  head/sys/dev/iscsi/icl.c
  head/sys/dev/iscsi/icl.h
  head/sys/dev/iscsi/icl_conn_if.m
  head/sys/dev/iscsi/icl_soft.c
  head/sys/dev/iscsi/icl_soft_proxy.c
  head/sys/dev/iscsi/icl_wrappers.h
  head/sys/dev/iscsi/iscsi.c
  head/sys/dev/iscsi/iscsi.h
  head/sys/dev/iscsi/iscsi_ioctl.h
  head/sys/dev/iscsi/iscsi_proto.h
  head/sys/dev/usb/storage/cfumass.c
  head/sys/fs/autofs/autofs.c
  head/sys/fs/autofs/autofs.h
  head/sys/fs/autofs/autofs_ioctl.h
  head/sys/fs/autofs/autofs_vfsops.c
  head/sys/fs/autofs/autofs_vnops.c
  head/sys/kern/kern_loginclass.c
  head/sys/kern/kern_racct.c
  head/sys/kern/kern_rctl.c
  head/sys/kern/subr_acl_nfs4.c
  head/sys/sys/loginclass.h
  head/sys/sys/racct.h
  head/sys/sys/rctl.h
  head/sys/ufs/ffs/ffs_suspend.c
  head/tests/sys/acl/00.sh
  head/tests/sys/acl/01.sh
  head/tests/sys/acl/02.sh
  head/tests/sys/acl/03.sh
  head/tests/sys/acl/04.sh
  head/tests/sys/acl/aclfuzzer.sh
  head/tests/sys/acl/mktrivial.sh
  head/tests/sys/acl/tools-crossfs.test
  head/tests/sys/acl/tools-nfs4-psarc.test
  head/tests/sys/acl/tools-nfs4-trivial.test
  head/tests/sys/acl/tools-nfs4.test
  head/tests/sys/acl/tools-posix.test
  head/tools/regression/iscsi/iscsi-test.sh
  head/tools/tools/fetchbench/fetchbench
  head/usr.bin/iscsictl/iscsictl.8
  head/usr.bin/iscsictl/iscsictl.c
  head/usr.bin/iscsictl/iscsictl.h
  head/usr.bin/iscsictl/parse.y
  head/usr.bin/iscsictl/token.l
  head/usr.bin/rctl/rctl.8
  head/usr.bin/rctl/rctl.c
  head/usr.sbin/autofs/auto_master.5
  head/usr.sbin/autofs/automount.8
  head/usr.sbin/autofs/automount.c
  head/usr.sbin/autofs/automountd.8
  head/usr.sbin/autofs/automountd.c
  head/usr.sbin/autofs/autounmountd.8
  head/usr.sbin/autofs/autounmountd.c
  head/usr.sbin/autofs/common.c
  head/usr.sbin/autofs/common.h
  head/usr.sbin/autofs/defined.c
  head/usr.sbin/autofs/log.c
  head/usr.sbin/autofs/token.l
  head/usr.sbin/ctld/chap.c
  head/usr.sbin/ctld/ctld.8
  head/usr.sbin/ctld/ctld.c
  head/usr.sbin/ctld/ctld.h
  head/usr.sbin/ctld/discovery.c
  head/usr.sbin/ctld/keys.c
  head/usr.sbin/ctld/log.c
  head/usr.sbin/ctld/login.c
  head/usr.sbin/ctld/parse.y
  head/usr.sbin/ctld/pdu.c
  head/usr.sbin/ctld/token.l
  head/usr.sbin/fstyp/fstyp.8
  head/usr.sbin/fstyp/fstyp.c
  head/usr.sbin/fstyp/fstyp.h
  head/usr.sbin/iscsid/chap.c
  head/usr.sbin/iscsid/discovery.c
  head/usr.sbin/iscsid/iscsid.8
  head/usr.sbin/iscsid/iscsid.c
  head/usr.sbin/iscsid/iscsid.h
  head/usr.sbin/iscsid/keys.c
  head/usr.sbin/iscsid/log.c
  head/usr.sbin/iscsid/login.c
  head/usr.sbin/iscsid/pdu.c
  head/usr.sbin/uefisign/child.c
  head/usr.sbin/uefisign/magic.h
  head/usr.sbin/uefisign/pe.c
  head/usr.sbin/uefisign/uefisign.8
  head/usr.sbin/uefisign/uefisign.c
  head/usr.sbin/uefisign/uefisign.h

Modified: head/lib/geom/mountver/geom_mountver.c
==
--- head/lib/geom/mountver/geom_mountver.c  Wed Oct 28 13:30:24 2020
(r367104)
+++ head/lib/geom/mountver/geom_mountver.c  Wed Oct 28 13:46:11 2020
(r367105)
@@ -2,7 +2,6 @@
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
  * Copyright (c) 2010 Edward Tomasz Napierala 
- * All right

svn commit: r367079 - in head/sys: amd64/linux amd64/linux32 arm64/linux compat/linux i386/linux

2020-10-27 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Oct 27 12:49:40 2020
New Revision: 367079
URL: https://svnweb.freebsd.org/changeset/base/367079

Log:
  Fix misnomer - linux_to_bsd_errno() does the exact opposite.
  
  Reported by:  arichardson
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26965

Modified:
  head/sys/amd64/linux/linux_sysvec.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/arm64/linux/linux_sysvec.c
  head/sys/compat/linux/linux.h
  head/sys/compat/linux/linux_errno.c
  head/sys/compat/linux/linux_socket.c
  head/sys/i386/linux/linux_sysvec.c

Modified: head/sys/amd64/linux/linux_sysvec.c
==
--- head/sys/amd64/linux/linux_sysvec.c Tue Oct 27 12:44:49 2020
(r367078)
+++ head/sys/amd64/linux/linux_sysvec.c Tue Oct 27 12:49:40 2020
(r367079)
@@ -231,7 +231,7 @@ linux_set_syscall_retval(struct thread *td, int error)
break;
 
default:
-   frame->tf_rax = linux_to_bsd_errno(error);
+   frame->tf_rax = bsd_to_linux_errno(error);
frame->tf_r10 = frame->tf_rcx;
break;
}

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Tue Oct 27 12:44:49 2020
(r367078)
+++ head/sys/amd64/linux32/linux32_sysvec.c Tue Oct 27 12:49:40 2020
(r367079)
@@ -678,7 +678,7 @@ linux32_set_syscall_retval(struct thread *td, int erro
 
if (__predict_false(error != 0)) {
if (error != ERESTART && error != EJUSTRETURN)
-   frame->tf_rax = linux_to_bsd_errno(error);
+   frame->tf_rax = bsd_to_linux_errno(error);
}
 }
 

Modified: head/sys/arm64/linux/linux_sysvec.c
==
--- head/sys/arm64/linux/linux_sysvec.c Tue Oct 27 12:44:49 2020
(r367078)
+++ head/sys/arm64/linux/linux_sysvec.c Tue Oct 27 12:49:40 2020
(r367079)
@@ -142,10 +142,8 @@ linux_set_syscall_retval(struct thread *td, int error)
cpu_set_syscall_retval(td, error);
 
if (__predict_false(error != 0)) {
-   if (error != ERESTART && error != EJUSTRETURN) {
-   td->td_frame->tf_x[0] =
-   linux_to_bsd_errno(error);
-   }
+   if (error != ERESTART && error != EJUSTRETURN)
+   td->td_frame->tf_x[0] = bsd_to_linux_errno(error);
}
 }
 

Modified: head/sys/compat/linux/linux.h
==
--- head/sys/compat/linux/linux.h   Tue Oct 27 12:44:49 2020
(r367078)
+++ head/sys/compat/linux/linux.h   Tue Oct 27 12:49:40 2020
(r367079)
@@ -196,6 +196,6 @@ int linux_to_bsd_bits_(int value, struct bsd_to_linux_
}
 #defineBITMAP_1t1_LINUX(_name) BITMAP_EASY_LINUX(_name, LINUX_##_name)
 
-int linux_to_bsd_errno(int error);
+int bsd_to_linux_errno(int error);
 
 #endif /* _LINUX_MI_H_ */

Modified: head/sys/compat/linux/linux_errno.c
==
--- head/sys/compat/linux/linux_errno.c Tue Oct 27 12:44:49 2020
(r367078)
+++ head/sys/compat/linux/linux_errno.c Tue Oct 27 12:49:40 2020
(r367079)
@@ -11,7 +11,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 int
-linux_to_bsd_errno(int error)
+bsd_to_linux_errno(int error)
 {
 
KASSERT(error >= 0 && error <= ELAST,

Modified: head/sys/compat/linux/linux_socket.c
==
--- head/sys/compat/linux/linux_socket.cTue Oct 27 12:44:49 2020
(r367078)
+++ head/sys/compat/linux/linux_socket.cTue Oct 27 12:49:40 2020
(r367079)
@@ -1559,7 +1559,7 @@ linux_getsockopt(struct thread *td, struct linux_getso
name, , UIO_SYSSPACE, );
if (error != 0)
return (error);
-   newval = -linux_to_bsd_errno(newval);
+   newval = -bsd_to_linux_errno(newval);
return (copyout(, PTRIN(args->optval), len));
/* NOTREACHED */
default:

Modified: head/sys/i386/linux/linux_sysvec.c
==
--- head/sys/i386/linux/linux_sysvec.c  Tue Oct 27 12:44:49 2020
(r367078)
+++ head/sys/i386/linux/linux_sysvec.c  Tue Oct 27 12:49:40 2020
(r367079)
@@ -800,7 +800,7 @@ linux_set_syscall_retval(struct thread *td, int error)
 
if (__predict_false(error != 0)) {
if (error != ERESTART && error != EJUSTRETURN)
-   frame->tf_eax = 

Re: svn commit: r367038 - head/sbin/mount_nullfs

2020-10-25 Thread Edward Tomasz Napierala
On 1025T0717, Cy Schubert wrote:
> In message  om>
> , Oliver Pinter writes:
> > On Sunday, October 25, 2020, Edward Tomasz Napierala 
> > wrote:
> >
> > > Author: trasz
> > > Date: Sun Oct 25 14:09:00 2020
> > > New Revision: 367038
> > > URL: https://svnweb.freebsd.org/changeset/base/367038
> > >
> > > Log:
> > >   Remove the check that prevents creating "loops" from mount_nullfs(8).
> > >
> > >
> > The simple question is: why?
> 
> I was about to ask that myself.
> 
> The why is usually more important than the how.

Two reasons.

First, from what I can tell this is an artificial limitation which serves
no purpose.  I thought it was to prevent some kind of deadlock between
vnodes, so I asked kib@, and he mentioned removing that very limitation
from the kernel code; thus, it looks to me like a historical leftover.

Second, I've stumbled upon this when trying to nullfs-mount '/' on
'/compat/ubuntu/bsd/', which would be useful for autochroot functionality,
when (or if) it becomes a thing.

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


svn commit: r367038 - head/sbin/mount_nullfs

2020-10-25 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun Oct 25 14:09:00 2020
New Revision: 367038
URL: https://svnweb.freebsd.org/changeset/base/367038

Log:
  Remove the check that prevents creating "loops" from mount_nullfs(8).
  
  Reviewed by:  kib
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26921

Modified:
  head/sbin/mount_nullfs/mount_nullfs.c

Modified: head/sbin/mount_nullfs/mount_nullfs.c
==
--- head/sbin/mount_nullfs/mount_nullfs.c   Sun Oct 25 10:08:46 2020
(r367037)
+++ head/sbin/mount_nullfs/mount_nullfs.c   Sun Oct 25 14:09:00 2020
(r367038)
@@ -59,7 +59,6 @@ static const char rcsid[] =
 
 #include "mntopts.h"
 
-intsubdir(const char *, const char *);
 static voidusage(void) __dead2;
 
 int
@@ -104,10 +103,6 @@ main(int argc, char *argv[])
if (checkpath(argv[1], source) != 0)
err(EX_USAGE, "%s", source);
 
-   if (subdir(target, source) || subdir(source, target))
-   errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
-   argv[0], target, argv[1]);
-
build_iovec(, , "fstype", nullfs, (size_t)-1);
build_iovec(, , "fspath", source, (size_t)-1);
build_iovec(, , "target", target, (size_t)-1);
@@ -119,21 +114,6 @@ main(int argc, char *argv[])
err(1, "%s", source);
}
exit(0);
-}
-
-int
-subdir(const char *p, const char *dir)
-{
-   int l;
-
-   l = strlen(dir);
-   if (l <= 1)
-   return (1);
-
-   if ((strncmp(p, dir, l) == 0) && (p[l] == '/' || p[l] == '\0'))
-   return (1);
-
-   return (0);
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-10-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Sat Oct 24 14:25:38 2020
New Revision: 367001
URL: https://svnweb.freebsd.org/changeset/base/367001

Log:
  Tweak linux(4) socket(2) debug messages.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26900

Modified:
  head/sys/compat/linux/linux.h
  head/sys/compat/linux/linux_socket.c

Modified: head/sys/compat/linux/linux.h
==
--- head/sys/compat/linux/linux.h   Sat Oct 24 14:23:44 2020
(r367000)
+++ head/sys/compat/linux/linux.h   Sat Oct 24 14:25:38 2020
(r367001)
@@ -58,6 +58,10 @@ struct l_sockaddr {
 #defineLINUX_AF_IPX4
 #defineLINUX_AF_APPLETALK  5
 #defineLINUX_AF_INET6  10
+#defineLINUX_AF_NETLINK16
+
+#defineLINUX_NETLINK_ROUTE 0
+#defineLINUX_NETLINK_UEVENT15
 
 /*
  * net device flags

Modified: head/sys/compat/linux/linux_socket.c
==
--- head/sys/compat/linux/linux_socket.cSat Oct 24 14:23:44 2020
(r367000)
+++ head/sys/compat/linux/linux_socket.cSat Oct 24 14:25:38 2020
(r367001)
@@ -514,6 +514,20 @@ linux_socket(struct thread *td, struct linux_socket_ar
return (retval_socket);
domain = linux_to_bsd_domain(args->domain);
if (domain == -1) {
+   if (args->domain == LINUX_AF_NETLINK &&
+   args->protocol == LINUX_NETLINK_ROUTE) {
+   linux_msg(curthread,
+   "unsupported socket(AF_NETLINK, %d, 
NETLINK_ROUTE)", type);
+   return (EAFNOSUPPORT);
+   }
+   
+   if (args->domain == LINUX_AF_NETLINK &&
+   args->protocol == LINUX_NETLINK_UEVENT) {
+   linux_msg(curthread,
+   "unsupported socket(AF_NETLINK, %d, 
NETLINK_UEVENT)", type);
+   return (EAFNOSUPPORT);
+   }
+   
linux_msg(curthread, "unsupported socket domain %d, type %d, 
protocol %d",
args->domain, args->type & LINUX_SOCK_TYPE_MASK, 
args->protocol);
return (EAFNOSUPPORT);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-10-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Sat Oct 24 14:23:44 2020
New Revision: 367000
URL: https://svnweb.freebsd.org/changeset/base/367000

Log:
  Further improve prctl(2) debug.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26916

Modified:
  head/sys/compat/linux/linux_misc.c
  head/sys/compat/linux/linux_misc.h

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Sat Oct 24 13:31:40 2020
(r366999)
+++ head/sys/compat/linux/linux_misc.c  Sat Oct 24 14:23:44 2020
(r367000)
@@ -1949,6 +1949,10 @@ linux_prctl(struct thread *td, struct linux_prctl_args
(void *)(register_t)args->arg2,
sizeof(pdeath_signal)));
break;
+   case LINUX_PR_SET_DUMPABLE:
+   linux_msg(td, "unsupported prctl PR_SET_DUMPABLE");
+   error = EINVAL;
+   break;
case LINUX_PR_GET_KEEPCAPS:
/*
 * Indicate that we always clear the effective and
@@ -2006,6 +2010,14 @@ linux_prctl(struct thread *td, struct linux_prctl_args
/*
 * Same as returned by Linux without CONFIG_SECCOMP enabled.
 */
+   error = EINVAL;
+   break;
+   case LINUX_PR_SET_NO_NEW_PRIVS:
+   linux_msg(td, "unsupported prctl PR_SET_NO_NEW_PRIVS");
+   error = EINVAL;
+   break;
+   case LINUX_PR_SET_PTRACER:
+   linux_msg(td, "unsupported prctl PR_SET_PTRACER");
error = EINVAL;
break;
default:

Modified: head/sys/compat/linux/linux_misc.h
==
--- head/sys/compat/linux/linux_misc.h  Sat Oct 24 13:31:40 2020
(r366999)
+++ head/sys/compat/linux/linux_misc.h  Sat Oct 24 14:23:44 2020
(r367000)
@@ -50,12 +50,15 @@
 * Second arg is a ptr to return the
 * signal.
 */
+#defineLINUX_PR_SET_DUMPABLE   4
 #defineLINUX_PR_GET_KEEPCAPS   7   /* Get drop capabilities on 
setuid */
 #defineLINUX_PR_SET_KEEPCAPS   8   /* Set drop capabilities on 
setuid */
 #defineLINUX_PR_SET_NAME   15  /* Set process name. */
 #defineLINUX_PR_GET_NAME   16  /* Get process name. */
 #defineLINUX_PR_GET_SECCOMP21
 #defineLINUX_PR_SET_SECCOMP22
+#defineLINUX_PR_SET_NO_NEW_PRIVS   38
+#defineLINUX_PR_SET_PTRACER1499557217
 
 #defineLINUX_MAX_COMM_LEN  16  /* Maximum length of the 
process name. */
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-10-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Oct 23 12:00:30 2020
New Revision: 366967
URL: https://svnweb.freebsd.org/changeset/base/366967

Log:
  Improve prctl(2) debug.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26899

Modified:
  head/sys/compat/linux/linux_misc.c
  head/sys/compat/linux/linux_misc.h

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Fri Oct 23 11:57:55 2020
(r366966)
+++ head/sys/compat/linux/linux_misc.c  Fri Oct 23 12:00:30 2020
(r366967)
@@ -2001,7 +2001,15 @@ linux_prctl(struct thread *td, struct linux_prctl_args
error = copyout(comm, (void *)(register_t)args->arg2,
strlen(comm) + 1);
break;
+   case LINUX_PR_GET_SECCOMP:
+   case LINUX_PR_SET_SECCOMP:
+   /*
+* Same as returned by Linux without CONFIG_SECCOMP enabled.
+*/
+   error = EINVAL;
+   break;
default:
+   linux_msg(td, "unsupported prctl option %d", args->option);
error = EINVAL;
break;
}

Modified: head/sys/compat/linux/linux_misc.h
==
--- head/sys/compat/linux/linux_misc.h  Fri Oct 23 11:57:55 2020
(r366966)
+++ head/sys/compat/linux/linux_misc.h  Fri Oct 23 12:00:30 2020
(r366967)
@@ -54,6 +54,8 @@
 #defineLINUX_PR_SET_KEEPCAPS   8   /* Set drop capabilities on 
setuid */
 #defineLINUX_PR_SET_NAME   15  /* Set process name. */
 #defineLINUX_PR_GET_NAME   16  /* Get process name. */
+#defineLINUX_PR_GET_SECCOMP21
+#defineLINUX_PR_SET_SECCOMP22
 
 #defineLINUX_MAX_COMM_LEN  16  /* Maximum length of the 
process name. */
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366966 - head/sys/compat/linprocfs

2020-10-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Oct 23 11:57:55 2020
New Revision: 366966
URL: https://svnweb.freebsd.org/changeset/base/366966

Log:
  Add /proc/sys/kernel/ngroups_max to linprocfs(4).  The id(1) command
  seems to use it - it works fine without it, but still.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26898

Modified:
  head/sys/compat/linprocfs/linprocfs.c

Modified: head/sys/compat/linprocfs/linprocfs.c
==
--- head/sys/compat/linprocfs/linprocfs.c   Fri Oct 23 10:48:14 2020
(r366965)
+++ head/sys/compat/linprocfs/linprocfs.c   Fri Oct 23 11:57:55 2020
(r366966)
@@ -1453,6 +1453,19 @@ linprocfs_domsgmnb(PFS_FILL_ARGS)
 }
 
 /*
+ * Filler function for proc/sys/kernel/ngroups_max
+ *
+ * Note that in Linux it defaults to 65536, not 1023.
+ */
+static int
+linprocfs_dongroups_max(PFS_FILL_ARGS)
+{
+
+   sbuf_printf(sb, "%d\n", ngroups_max);
+   return (0);
+}
+
+/*
  * Filler function for proc/sys/kernel/pid_max
  */
 static int
@@ -1921,6 +1934,8 @@ linprocfs_init(PFS_INIT_ARGS)
pfs_create_file(dir, "msgmni", _domsgmni,
NULL, NULL, NULL, PFS_RD);
pfs_create_file(dir, "msgmnb", _domsgmnb,
+   NULL, NULL, NULL, PFS_RD);
+   pfs_create_file(dir, "ngroups_max", _dongroups_max,
NULL, NULL, NULL, PFS_RD);
pfs_create_file(dir, "pid_max", _dopid_max,
NULL, NULL, NULL, PFS_RD);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-10-21 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Oct 21 18:45:48 2020
New Revision: 366915
URL: https://svnweb.freebsd.org/changeset/base/366915

Log:
  Make linux(4) warn about unsupported socket(2) types.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D25680

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

Modified: head/sys/compat/linux/linux_socket.c
==
--- head/sys/compat/linux/linux_socket.cWed Oct 21 17:11:57 2020
(r366914)
+++ head/sys/compat/linux/linux_socket.cWed Oct 21 18:45:48 2020
(r366915)
@@ -513,8 +513,11 @@ linux_socket(struct thread *td, struct linux_socket_ar
if (retval_socket != 0)
return (retval_socket);
domain = linux_to_bsd_domain(args->domain);
-   if (domain == -1)
+   if (domain == -1) {
+   linux_msg(curthread, "unsupported socket domain %d, type %d, 
protocol %d",
+   args->domain, args->type & LINUX_SOCK_TYPE_MASK, 
args->protocol);
return (EAFNOSUPPORT);
+   }
 
retval_socket = kern_socket(td, domain, type, args->protocol);
if (retval_socket)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366900 - head/sys/compat/linprocfs

2020-10-20 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Oct 20 17:24:29 2020
New Revision: 366900
URL: https://svnweb.freebsd.org/changeset/base/366900

Log:
  Fix linprocfs(4) /proc/self/mem semantics to more closely match Linux.
  Steam's Anti-Cheat might depend on it.
  
  PR:   248223
  Analyzed by:  Alex S 
  Reviewed by:  kib
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26816

Modified:
  head/sys/compat/linprocfs/linprocfs.c

Modified: head/sys/compat/linprocfs/linprocfs.c
==
--- head/sys/compat/linprocfs/linprocfs.c   Tue Oct 20 17:19:10 2020
(r366899)
+++ head/sys/compat/linprocfs/linprocfs.c   Tue Oct 20 17:24:29 2020
(r366900)
@@ -1276,6 +1276,27 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
 }
 
 /*
+ * Filler function for proc/pid/mem
+ */
+static int
+linprocfs_doprocmem(PFS_FILL_ARGS)
+{
+   ssize_t resid;
+   int error;
+
+   resid = uio->uio_resid;
+   error = procfs_doprocmem(PFS_FILL_ARGNAMES);
+
+   if (uio->uio_rw == UIO_READ && resid != uio->uio_resid)
+   return (0);
+
+   if (error == EFAULT)
+   error = EIO;
+
+   return (error);
+}
+
+/*
  * Criteria for interface name translation
  */
 #define IFP_IS_ETH(ifp) (ifp->if_type == IFT_ETHER)
@@ -1853,7 +1874,7 @@ linprocfs_init(PFS_INIT_ARGS)
NULL, _notsystem, NULL, 0);
pfs_create_file(dir, "maps", _doprocmaps,
NULL, NULL, NULL, PFS_RD);
-   pfs_create_file(dir, "mem", _doprocmem,
+   pfs_create_file(dir, "mem", _doprocmem,
procfs_attr_rw, _candebug, NULL, PFS_RDWR | PFS_RAW);
pfs_create_file(dir, "mounts", _domtab,
NULL, NULL, NULL, PFS_RD);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-10-20 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Oct 20 17:19:10 2020
New Revision: 366899
URL: https://svnweb.freebsd.org/changeset/base/366899

Log:
  Fix potential race condition in linux stat(2).
  
  Reviewed by:  kib
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D25618

Modified:
  head/sys/compat/linux/linux_stats.c
  head/sys/compat/linux/linux_util.c
  head/sys/compat/linux/linux_util.h

Modified: head/sys/compat/linux/linux_stats.c
==
--- head/sys/compat/linux/linux_stats.c Tue Oct 20 17:00:43 2020
(r366898)
+++ head/sys/compat/linux/linux_stats.c Tue Oct 20 17:19:10 2020
(r366899)
@@ -80,11 +80,8 @@ translate_vnhook_major_minor(struct vnode *vp, struct 
if (rootdevmp != NULL && vp->v_mount->mnt_vfc == rootdevmp->mnt_vfc)
sb->st_dev = rootdevmp->mnt_stat.f_fsid.val[0];
 
-   if (vp->v_type == VCHR && vp->v_rdev != NULL &&
-   linux_driver_get_major_minor(devtoname(vp->v_rdev),
-   , ) == 0) {
+   if (linux_vn_get_major_minor(vp, , ) == 0)
sb->st_rdev = (major << 8 | minor);
-   }
 }
 
 static int
@@ -140,9 +137,7 @@ translate_fd_major_minor(struct thread *td, int fd, st
if (mp != NULL && mp->mnt_vfc == rootdevmp->mnt_vfc)
buf->st_dev = rootdevmp->mnt_stat.f_fsid.val[0];
}
-   if (vp != NULL && vp->v_rdev != NULL &&
-   linux_driver_get_major_minor(devtoname(vp->v_rdev),
-, ) == 0) {
+   if (linux_vn_get_major_minor(vp, , ) == 0) {
buf->st_rdev = (major << 8 | minor);
} else if (fp->f_type == DTYPE_PTS) {
struct tty *tp = fp->f_data;

Modified: head/sys/compat/linux/linux_util.c
==
--- head/sys/compat/linux/linux_util.c  Tue Oct 20 17:00:43 2020
(r366898)
+++ head/sys/compat/linux/linux_util.c  Tue Oct 20 17:19:10 2020
(r366899)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -193,6 +194,24 @@ linux_driver_get_major_minor(const char *node, int *ma
}
 
return (1);
+}
+
+int
+linux_vn_get_major_minor(const struct vnode *vp, int *major, int *minor)
+{
+   int error;
+
+   if (vp->v_type != VCHR)
+   return (ENOTBLK);
+   dev_lock();
+   if (vp->v_rdev == NULL) {
+   dev_unlock();
+   return (ENXIO);
+   }
+   error = linux_driver_get_major_minor(devtoname(vp->v_rdev),
+   major, minor);
+   dev_unlock();
+   return (error);
 }
 
 char *

Modified: head/sys/compat/linux/linux_util.h
==
--- head/sys/compat/linux/linux_util.h  Tue Oct 20 17:00:43 2020
(r366898)
+++ head/sys/compat/linux/linux_util.h  Tue Oct 20 17:19:10 2020
(r366899)
@@ -123,6 +123,7 @@ int linux_device_register_handler(struct linux_device_
 intlinux_device_unregister_handler(struct linux_device_handler *h);
 char   *linux_driver_get_name_dev(device_t dev);
 intlinux_driver_get_major_minor(const char *node, int *major, int *minor);
+intlinux_vn_get_major_minor(const struct vnode *vn, int *major, int 
*minor);
 char   *linux_get_char_devices(void);
 void   linux_free_get_char_devices(char *string);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366855 - in head/sys/geom: . uzip

2020-10-19 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Oct 19 20:26:37 2020
New Revision: 366855
URL: https://svnweb.freebsd.org/changeset/base/366855

Log:
  Fix fallout from r366811.
  
  PR:   250442
  Reported by:  lwhsu
  Reviewed by:  mav
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D26855

Modified:
  head/sys/geom/geom_dev.c
  head/sys/geom/uzip/g_uzip.c

Modified: head/sys/geom/geom_dev.c
==
--- head/sys/geom/geom_dev.cMon Oct 19 20:08:50 2020(r366854)
+++ head/sys/geom/geom_dev.cMon Oct 19 20:26:37 2020(r366855)
@@ -346,9 +346,15 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp,
cp->private = sc;
cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
error = g_attach(cp, pp);
-   KASSERT(error == 0 || error == ENXIO,
-   ("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error));
-
+   if (error != 0) {
+   printf("%s: g_dev_taste(%s) failed to g_attach, error=%d\n",
+   __func__, pp->name, error);
+   g_destroy_consumer(cp);
+   g_destroy_geom(gp);
+   mtx_destroy(>sc_mtx);
+   g_free(sc);
+   return (NULL);
+   }
make_dev_args_init();
args.mda_flags = MAKEDEV_CHECKNAME | MAKEDEV_WAITOK;
args.mda_devsw = _dev_cdevsw;

Modified: head/sys/geom/uzip/g_uzip.c
==
--- head/sys/geom/uzip/g_uzip.c Mon Oct 19 20:08:50 2020(r366854)
+++ head/sys/geom/uzip/g_uzip.c Mon Oct 19 20:26:37 2020(r366855)
@@ -707,11 +707,11 @@ g_uzip_taste(struct g_class *mp, struct g_provider *pp
gp = g_new_geomf(mp, GUZ_DEV_NAME("%s"), pp->name);
cp = g_new_consumer(gp);
error = g_attach(cp, pp);
-   if (error == 0)
-   error = g_access(cp, 1, 0, 0);
-   if (error) {
+   if (error != 0)
+   goto e0;
+   error = g_access(cp, 1, 0, 0);
+   if (error)
goto e1;
-   }
g_topology_unlock();
 
/*
@@ -942,6 +942,7 @@ e2:
g_access(cp, -1, 0, 0);
 e1:
g_detach(cp);
+e0:
g_destroy_consumer(cp);
g_destroy_geom(gp);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366812 - head/sys/dev/iscsi

2020-10-18 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun Oct 18 16:30:49 2020
New Revision: 366812
URL: https://svnweb.freebsd.org/changeset/base/366812

Log:
  If the SIM freezes the queue at exactly the wrong moment, after
  another thread has started to send in a CCB and already checked
  the queue wasn't frozen, we would end up with iscsi_action()
  being called despite the queue is now frozen.
  
  Add a check to make sure this doesn't happen . Perhaps this should
  be fixed at the CAM level instead, but given how the send queue and
  SIM are governed by two separate mutexes, it is somewhat hard to do.
  
  Reviewed by:  imp, mav
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D26750

Modified:
  head/sys/dev/iscsi/iscsi.c

Modified: head/sys/dev/iscsi/iscsi.c
==
--- head/sys/dev/iscsi/iscsi.c  Sun Oct 18 16:24:08 2020(r366811)
+++ head/sys/dev/iscsi/iscsi.c  Sun Oct 18 16:30:49 2020(r366812)
@@ -367,8 +367,8 @@ iscsi_session_cleanup(struct iscsi_session *is, bool d
xpt_async(AC_LOST_DEVICE, is->is_path, NULL);
 
if (is->is_simq_frozen) {
-   xpt_release_simq(is->is_sim, 1);
is->is_simq_frozen = false;
+   xpt_release_simq(is->is_sim, 1);
}
 
xpt_free_path(is->is_path);
@@ -1479,8 +1479,8 @@ iscsi_ioctl_daemon_handoff(struct iscsi_softc *sc,
KASSERT(is->is_simq_frozen, ("reconnect without frozen simq"));
ISCSI_SESSION_LOCK(is);
ISCSI_SESSION_DEBUG(is, "releasing");
-   xpt_release_simq(is->is_sim, 1);
is->is_simq_frozen = false;
+   xpt_release_simq(is->is_sim, 1);
ISCSI_SESSION_UNLOCK(is);
 
} else {
@@ -2351,6 +2351,17 @@ iscsi_action(struct cam_sim *sim, union ccb *ccb)
if (is->is_terminating ||
(is->is_connected == false && fail_on_disconnection)) {
ccb->ccb_h.status = CAM_DEV_NOT_THERE;
+   xpt_done(ccb);
+   return;
+   }
+
+   /*
+* Make sure CAM doesn't sneak in a CCB just after freezing the queue.
+*/
+   if (is->is_simq_frozen == true) {
+   ccb->ccb_h.status &= ~(CAM_SIM_QUEUED | CAM_STATUS_MASK);
+   ccb->ccb_h.status |= CAM_REQUEUE_REQ;
+   /* Don't freeze the devq - the SIM queue is already frozen. */
xpt_done(ccb);
return;
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366811 - in head: share/man/man9 sys/geom sys/geom/bde sys/geom/cache sys/geom/concat sys/geom/journal sys/geom/label sys/geom/linux_lvm sys/geom/mirror sys/geom/mountver sys/geom/mult...

2020-10-18 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun Oct 18 16:24:08 2020
New Revision: 366811
URL: https://svnweb.freebsd.org/changeset/base/366811

Log:
  Make g_attach() return ENXIO for orphaned providers; update various
  classes to add missing error checking.
  
  Reviewed by:  imp
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D26658

Modified:
  head/share/man/man9/g_attach.9
  head/sys/geom/bde/g_bde.c
  head/sys/geom/cache/g_cache.c
  head/sys/geom/concat/g_concat.c
  head/sys/geom/geom_dev.c
  head/sys/geom/geom_subr.c
  head/sys/geom/geom_vfs.c
  head/sys/geom/journal/g_journal.c
  head/sys/geom/label/g_label.c
  head/sys/geom/linux_lvm/g_linux_lvm.c
  head/sys/geom/mirror/g_mirror.c
  head/sys/geom/mirror/g_mirror_ctl.c
  head/sys/geom/mountver/g_mountver.c
  head/sys/geom/multipath/g_multipath.c
  head/sys/geom/raid/g_raid.c
  head/sys/geom/raid3/g_raid3.c
  head/sys/geom/shsec/g_shsec.c
  head/sys/geom/stripe/g_stripe.c
  head/sys/geom/virstor/g_virstor.c

Modified: head/share/man/man9/g_attach.9
==
--- head/share/man/man9/g_attach.9  Sun Oct 18 16:16:22 2020
(r366810)
+++ head/share/man/man9/g_attach.9  Sun Oct 18 16:24:08 2020
(r366811)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 16, 2004
+.Dd October 10, 2020
 .Dt G_ATTACH 9
 .Os
 .Sh NAME
@@ -122,6 +122,8 @@ Possible errors:
 .Bl -tag -width Er
 .It Bq Er ELOOP
 The operation creates a topology loop.
+.It Bq Er ENXIO
+Provider got orphaned.
 .El
 .Sh SEE ALSO
 .Xr geom 4 ,

Modified: head/sys/geom/bde/g_bde.c
==
--- head/sys/geom/bde/g_bde.c   Sun Oct 18 16:16:22 2020(r366810)
+++ head/sys/geom/bde/g_bde.c   Sun Oct 18 16:24:08 2020(r366811)
@@ -131,7 +131,13 @@ g_bde_create_geom(struct gctl_req *req, struct g_class
 
gp = g_new_geomf(mp, "%s.bde", pp->name);
cp = g_new_consumer(gp);
-   g_attach(cp, pp);
+   error = g_attach(cp, pp);
+   if (error != 0) {
+   g_destroy_consumer(cp);
+   g_destroy_geom(gp);
+   gctl_error(req, "could not attach consumer");
+   return;
+   }
error = g_access(cp, 1, 1, 1);
if (error) {
g_detach(cp);

Modified: head/sys/geom/cache/g_cache.c
==
--- head/sys/geom/cache/g_cache.c   Sun Oct 18 16:16:22 2020
(r366810)
+++ head/sys/geom/cache/g_cache.c   Sun Oct 18 16:24:08 2020
(r366811)
@@ -673,9 +673,11 @@ g_cache_taste(struct g_class *mp, struct g_provider *p
gp->orphan = g_cache_orphan;
gp->access = g_cache_access;
cp = g_new_consumer(gp);
-   g_attach(cp, pp);
-   error = g_cache_read_metadata(cp, );
-   g_detach(cp);
+   error = g_attach(cp, pp);
+   if (error == 0) {
+   error = g_cache_read_metadata(cp, );
+   g_detach(cp);
+   }
g_destroy_consumer(cp);
g_destroy_geom(gp);
if (error != 0)

Modified: head/sys/geom/concat/g_concat.c
==
--- head/sys/geom/concat/g_concat.c Sun Oct 18 16:16:22 2020
(r366810)
+++ head/sys/geom/concat/g_concat.c Sun Oct 18 16:24:08 2020
(r366811)
@@ -718,9 +718,11 @@ g_concat_taste(struct g_class *mp, struct g_provider *
gp->access = g_concat_access;
gp->orphan = g_concat_orphan;
cp = g_new_consumer(gp);
-   g_attach(cp, pp);
-   error = g_concat_read_metadata(cp, );
-   g_detach(cp);
+   error = g_attach(cp, pp);
+   if (error == 0) {
+   error = g_concat_read_metadata(cp, );
+   g_detach(cp);
+   }
g_destroy_consumer(cp);
g_destroy_geom(gp);
if (error != 0)

Modified: head/sys/geom/geom_dev.c
==
--- head/sys/geom/geom_dev.cSun Oct 18 16:16:22 2020(r366810)
+++ head/sys/geom/geom_dev.cSun Oct 18 16:24:08 2020(r366811)
@@ -346,7 +346,7 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp,
cp->private = sc;
cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
error = g_attach(cp, pp);
-   KASSERT(error == 0,
+   KASSERT(error == 0 || error == ENXIO,
("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error));
 
make_dev_args_init();

Modified: head/sys/geom/geom_subr.c
==
--- head/sys/geom/geom_subr.c   Sun Oct 18 16:16:22 2020(r366810)
+++ head/sys/geom/geom_subr.c   Sun Oct 18 16:24:08 2020(r366811)
@@ -896,6 +896,8 @@ g_attach(struct g_consumer *cp, struct g_provider 

svn commit: r366810 - head/sys/amd64/linux

2020-10-18 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun Oct 18 16:16:22 2020
New Revision: 366810
URL: https://svnweb.freebsd.org/changeset/base/366810

Log:
  Stop calling set_syscall_retval() from linux_set_syscall_retval().
  The former clobbers some registers that shouldn't be touched.
  
  Reviewed by:  kib (earlier version)
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26406

Modified:
  head/sys/amd64/linux/linux_sysvec.c

Modified: head/sys/amd64/linux/linux_sysvec.c
==
--- head/sys/amd64/linux/linux_sysvec.c Sun Oct 18 15:58:16 2020
(r366809)
+++ head/sys/amd64/linux/linux_sysvec.c Sun Oct 18 16:16:22 2020
(r366810)
@@ -206,24 +206,45 @@ linux_fetch_syscall_args(struct thread *td)
 static void
 linux_set_syscall_retval(struct thread *td, int error)
 {
-   struct trapframe *frame = td->td_frame;
+   struct trapframe *frame;
 
-   /*
-* On Linux only %rcx and %r11 values are not preserved across
-* the syscall.  So, do not clobber %rdx and %r10.
-*/
-   td->td_retval[1] = frame->tf_rdx;
-   if (error != EJUSTRETURN)
-   frame->tf_r10 = frame->tf_rcx;
+   frame = td->td_frame;
 
-   cpu_set_syscall_retval(td, error);
+   switch (error) {
+   case 0:
+   frame->tf_rax = td->td_retval[0];
+   frame->tf_r10 = frame->tf_rcx;
+   break;
 
-   if (__predict_false(error != 0)) {
-   if (error != ERESTART && error != EJUSTRETURN)
-   frame->tf_rax = linux_to_bsd_errno(error);
+   case ERESTART:
+   /*
+* Reconstruct pc, we know that 'syscall' is 2 bytes,
+* lcall $X,y is 7 bytes, int 0x80 is 2 bytes.
+* We saved this in tf_err.
+*
+*/
+   frame->tf_rip -= frame->tf_err;
+   frame->tf_r10 = frame->tf_rcx;
+   break;
+ 
+   case EJUSTRETURN:
+   break;
+
+   default:
+   frame->tf_rax = linux_to_bsd_errno(error);
+   frame->tf_r10 = frame->tf_rcx;
+   break;
}
 
-/* Restore all registers. */
+   /*
+* Differently from FreeBSD native ABI, on Linux only %rcx
+* and %r11 values are not preserved across the syscall.
+* Require full context restore to get all registers except
+* those two restored at return to usermode.
+*
+* XXX: Would be great to be able to avoid PCB_FULL_IRET
+*  for the error == 0 case.
+*/
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-10-18 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun Oct 18 15:58:16 2020
New Revision: 366809
URL: https://svnweb.freebsd.org/changeset/base/366809

Log:
  Add compat.linux.dummy_rlimits, and disable by default.
  
  Turns out the dummy rlimits fix prlimit(1), but break su(8)
  (login-1:4.5-1ubuntu2) - although not sudo(8), for some reason.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26814

Modified:
  head/sys/compat/linux/linux_mib.c
  head/sys/compat/linux/linux_mib.h
  head/sys/compat/linux/linux_misc.c

Modified: head/sys/compat/linux/linux_mib.c
==
--- head/sys/compat/linux/linux_mib.c   Sun Oct 18 15:56:47 2020
(r366808)
+++ head/sys/compat/linux/linux_mib.c   Sun Oct 18 15:58:16 2020
(r366809)
@@ -77,6 +77,11 @@ SYSCTL_INT(_compat_linux, OID_AUTO, default_stacksize,
 _default_stacksize, 0,
 "Default soft stack size resource limit, or -1 for unlimited");
 
+int linux_dummy_rlimits = 0;
+SYSCTL_INT(_compat_linux, OID_AUTO, dummy_rlimits, CTLFLAG_RWTUN,
+_dummy_rlimits, 0,
+"Return dummy values for unsupported Linux-specific rlimits");
+
 int linux_ignore_ip_recverr = 1;
 SYSCTL_INT(_compat_linux, OID_AUTO, ignore_ip_recverr, CTLFLAG_RWTUN,
 _ignore_ip_recverr, 0, "Ignore enabling IP_RECVERR");

Modified: head/sys/compat/linux/linux_mib.h
==
--- head/sys/compat/linux/linux_mib.h   Sun Oct 18 15:56:47 2020
(r366808)
+++ head/sys/compat/linux/linux_mib.h   Sun Oct 18 15:58:16 2020
(r366809)
@@ -65,6 +65,7 @@ int   linux_kernver(struct thread *td);
 extern int linux_debug;
 extern int linux_default_openfiles;
 extern int linux_default_stacksize;
+extern int linux_dummy_rlimits;
 extern int linux_ignore_ip_recverr;
 extern int linux_preserve_vstatus;
 extern bool linux_map_sched_prio;

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Sun Oct 18 15:56:47 2020
(r366808)
+++ head/sys/compat/linux/linux_misc.c  Sun Oct 18 15:58:16 2020
(r366809)
@@ -1377,6 +1377,9 @@ static bool
 linux_get_dummy_limit(l_uint resource, struct rlimit *rlim)
 {
 
+   if (linux_dummy_rlimits == 0)
+   return (false);
+
switch (resource) {
case LINUX_RLIMIT_LOCKS:
case LINUX_RLIMIT_SIGPENDING:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366808 - head/sys/amd64/linux

2020-10-18 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun Oct 18 15:56:47 2020
New Revision: 366808
URL: https://svnweb.freebsd.org/changeset/base/366808

Log:
  Slightly tweak linux ptrace(2) debug message; no functional changes.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26815

Modified:
  head/sys/amd64/linux/linux_ptrace.c

Modified: head/sys/amd64/linux/linux_ptrace.c
==
--- head/sys/amd64/linux/linux_ptrace.c Sun Oct 18 12:03:36 2020
(r366807)
+++ head/sys/amd64/linux/linux_ptrace.c Sun Oct 18 15:56:47 2020
(r366808)
@@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$");
 #defineLINUX_PTRACE_GETSIGINFO 0x4202
 #defineLINUX_PTRACE_GETREGSET  0x4204
 #defineLINUX_PTRACE_SEIZE  0x4206
+#defineLINUX_PTRACE_GET_SYSCALL_INFO   0x420e
 
 #defineLINUX_PTRACE_EVENT_EXIT 6
 
@@ -557,6 +558,14 @@ linux_ptrace_seize(struct thread *td, pid_t pid, l_ulo
return (EINVAL);
 }
 
+static int
+linux_ptrace_get_syscall_info(struct thread *td, pid_t pid, l_ulong addr, 
l_ulong data)
+{
+
+   linux_msg(td, "PTRACE_GET_SYSCALL_INFO not implemented; returning 
EINVAL");
+   return (EINVAL);
+}
+
 int
 linux_ptrace(struct thread *td, struct linux_ptrace_args *uap)
 {
@@ -641,6 +650,9 @@ linux_ptrace(struct thread *td, struct linux_ptrace_ar
break;
case LINUX_PTRACE_SEIZE:
error = linux_ptrace_seize(td, pid, uap->addr, uap->data);
+   break;
+   case LINUX_PTRACE_GET_SYSCALL_INFO:
+   error = linux_ptrace_get_syscall_info(td, pid, uap->addr, 
uap->data);
break;
default:
linux_msg(td, "ptrace(%ld, ...) not implemented; "
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-10-16 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Oct 16 11:23:30 2020
New Revision: 366756
URL: https://svnweb.freebsd.org/changeset/base/366756

Log:
  Set default stack size for Linux apps to 8MB.  This matches Linux'
  defaults, makes core files smaller, and fixes applications which use
  pthread_join(3) in a wrong way, namely Steam.
  
  This is based on a patch submitted by Jason Yang, which I've reworked
  to set the limit instead of only changing the value reported (which
  is enough to fix the bug for Linux pthreads, but could be confusing).
  
  PR:   248225
  Submitted by: Jason_YH_Yang at wistron.com (earlier version)
  Analyzed by:  Alex S 
  Reviewed by:  emaste
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26778

Modified:
  head/sys/compat/linux/linux_emul.c
  head/sys/compat/linux/linux_mib.c
  head/sys/compat/linux/linux_mib.h

Modified: head/sys/compat/linux/linux_emul.c
==
--- head/sys/compat/linux/linux_emul.c  Fri Oct 16 11:22:29 2020
(r366755)
+++ head/sys/compat/linux/linux_emul.c  Fri Oct 16 11:23:30 2020
(r366756)
@@ -115,6 +115,29 @@ linux_set_default_openfiles(struct thread *td, struct 
KASSERT(error == 0, ("kern_proc_setrlimit failed"));
 }
 
+/*
+ * The default stack size limit in Linux is 8MB.
+ */
+static void
+linux_set_default_stacksize(struct thread *td, struct proc *p)
+{
+   struct rlimit rlim;
+   int error;
+
+   if (linux_default_stacksize < 0)
+   return;
+
+   PROC_LOCK(p);
+   lim_rlimit_proc(p, RLIMIT_STACK, );
+   PROC_UNLOCK(p);
+   if (rlim.rlim_cur != rlim.rlim_max ||
+   rlim.rlim_cur <= linux_default_stacksize)
+   return;
+   rlim.rlim_cur = linux_default_stacksize;
+   error = kern_proc_setrlimit(td, p, RLIMIT_STACK, );
+   KASSERT(error == 0, ("kern_proc_setrlimit failed"));
+}
+
 void
 linux_proc_init(struct thread *td, struct thread *newtd, int flags)
 {
@@ -145,6 +168,7 @@ linux_proc_init(struct thread *td, struct thread *newt
newtd->td_emuldata = em;
 
linux_set_default_openfiles(td, p);
+   linux_set_default_stacksize(td, p);
} else {
p = td->td_proc;
 

Modified: head/sys/compat/linux/linux_mib.c
==
--- head/sys/compat/linux/linux_mib.c   Fri Oct 16 11:22:29 2020
(r366755)
+++ head/sys/compat/linux/linux_mib.c   Fri Oct 16 11:23:30 2020
(r366756)
@@ -72,6 +72,11 @@ SYSCTL_INT(_compat_linux, OID_AUTO, default_openfiles,
 _default_openfiles, 0,
 "Default soft openfiles resource limit, or -1 for unlimited");
 
+int linux_default_stacksize = 8 * 1024 * 1024;
+SYSCTL_INT(_compat_linux, OID_AUTO, default_stacksize, CTLFLAG_RWTUN,
+_default_stacksize, 0,
+"Default soft stack size resource limit, or -1 for unlimited");
+
 int linux_ignore_ip_recverr = 1;
 SYSCTL_INT(_compat_linux, OID_AUTO, ignore_ip_recverr, CTLFLAG_RWTUN,
 _ignore_ip_recverr, 0, "Ignore enabling IP_RECVERR");

Modified: head/sys/compat/linux/linux_mib.h
==
--- head/sys/compat/linux/linux_mib.h   Fri Oct 16 11:22:29 2020
(r366755)
+++ head/sys/compat/linux/linux_mib.h   Fri Oct 16 11:23:30 2020
(r366756)
@@ -64,6 +64,7 @@ int   linux_kernver(struct thread *td);
 
 extern int linux_debug;
 extern int linux_default_openfiles;
+extern int linux_default_stacksize;
 extern int linux_ignore_ip_recverr;
 extern int linux_preserve_vstatus;
 extern bool linux_map_sched_prio;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2020-10-16 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Oct 16 10:10:09 2020
New Revision: 366749
URL: https://svnweb.freebsd.org/changeset/base/366749

Log:
  Make linux getrlimit(2) and prlimit(2) return something reasonable
  for linux-specific limits.  Fixes prlimit (util-linux-2.31.1-0.4ubuntu3.7).
  
  Reviewed by:  emaste
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26777

Modified:
  head/sys/compat/linux/linux_misc.c
  head/sys/compat/linux/linux_misc.h

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Fri Oct 16 09:58:10 2020
(r366748)
+++ head/sys/compat/linux/linux_misc.c  Fri Oct 16 10:10:09 2020
(r366749)
@@ -1373,6 +1373,28 @@ linux_getgroups(struct thread *td, struct linux_getgro
return (0);
 }
 
+static bool
+linux_get_dummy_limit(l_uint resource, struct rlimit *rlim)
+{
+
+   switch (resource) {
+   case LINUX_RLIMIT_LOCKS:
+   case LINUX_RLIMIT_SIGPENDING:
+   case LINUX_RLIMIT_MSGQUEUE:
+   case LINUX_RLIMIT_RTTIME:
+   rlim->rlim_cur = LINUX_RLIM_INFINITY;
+   rlim->rlim_max = LINUX_RLIM_INFINITY;
+   return (true);
+   case LINUX_RLIMIT_NICE:
+   case LINUX_RLIMIT_RTPRIO:
+   rlim->rlim_cur = 0;
+   rlim->rlim_max = 0;
+   return (true);
+   default:
+   return (false);
+   }
+}
+
 int
 linux_setrlimit(struct thread *td, struct linux_setrlimit_args *args)
 {
@@ -1405,6 +1427,12 @@ linux_old_getrlimit(struct thread *td, struct linux_ol
struct rlimit bsd_rlim;
u_int which;
 
+   if (linux_get_dummy_limit(args->resource, _rlim)) {
+   rlim.rlim_cur = bsd_rlim.rlim_cur;
+   rlim.rlim_max = bsd_rlim.rlim_max;
+   return (copyout(, args->rlim, sizeof(rlim)));
+   }
+
if (args->resource >= LINUX_RLIM_NLIMITS)
return (EINVAL);
 
@@ -1440,6 +1468,12 @@ linux_getrlimit(struct thread *td, struct linux_getrli
struct rlimit bsd_rlim;
u_int which;
 
+   if (linux_get_dummy_limit(args->resource, _rlim)) {
+   rlim.rlim_cur = bsd_rlim.rlim_cur;
+   rlim.rlim_max = bsd_rlim.rlim_max;
+   return (copyout(, args->rlim, sizeof(rlim)));
+   }
+
if (args->resource >= LINUX_RLIM_NLIMITS)
return (EINVAL);
 
@@ -2137,6 +2171,14 @@ linux_prlimit64(struct thread *td, struct linux_prlimi
u_int which;
int flags;
int error;
+
+   if (args->new == NULL && args->old != NULL) {
+   if (linux_get_dummy_limit(args->resource, )) {
+   lrlim.rlim_cur = rlim.rlim_cur;
+   lrlim.rlim_max = rlim.rlim_max;
+   return (copyout(, args->old, sizeof(lrlim)));
+   }
+   }
 
if (args->resource >= LINUX_RLIM_NLIMITS)
return (EINVAL);

Modified: head/sys/compat/linux/linux_misc.h
==
--- head/sys/compat/linux/linux_misc.h  Fri Oct 16 09:58:10 2020
(r366748)
+++ head/sys/compat/linux/linux_misc.h  Fri Oct 16 10:10:09 2020
(r366749)
@@ -137,12 +137,12 @@ extern int stclohz;
 #defineLINUX_P_PID 1
 #defineLINUX_P_PGID2
 
-#defineLINUX_RLIMIT_LOCKS  RLIM_NLIMITS + 1
-#defineLINUX_RLIMIT_SIGPENDING RLIM_NLIMITS + 2
-#defineLINUX_RLIMIT_MSGQUEUE   RLIM_NLIMITS + 3
-#defineLINUX_RLIMIT_NICE   RLIM_NLIMITS + 4
-#defineLINUX_RLIMIT_RTPRIO RLIM_NLIMITS + 5
-#defineLINUX_RLIMIT_RTTIME RLIM_NLIMITS + 6
+#defineLINUX_RLIMIT_LOCKS  10
+#defineLINUX_RLIMIT_SIGPENDING 11
+#defineLINUX_RLIMIT_MSGQUEUE   12
+#defineLINUX_RLIMIT_NICE   13
+#defineLINUX_RLIMIT_RTPRIO 14
+#defineLINUX_RLIMIT_RTTIME 15
 
 #defineLINUX_RLIM_INFINITY (~0UL)
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366748 - head/sys/fs/pseudofs

2020-10-16 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Oct 16 09:58:10 2020
New Revision: 366748
URL: https://svnweb.freebsd.org/changeset/base/366748

Log:
  Bump pseudofs size limit from 128kB to 1MB.  The old limit could result
  in process' memory maps being truncated.
  
  PR:   237883
  Submitted by: dchagin
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D20575

Modified:
  head/sys/fs/pseudofs/pseudofs_vnops.c

Modified: head/sys/fs/pseudofs/pseudofs_vnops.c
==
--- head/sys/fs/pseudofs/pseudofs_vnops.c   Fri Oct 16 08:56:20 2020
(r366747)
+++ head/sys/fs/pseudofs/pseudofs_vnops.c   Fri Oct 16 09:58:10 2020
(r366748)
@@ -68,6 +68,8 @@ __FBSDID("$FreeBSD$");
KASSERT((pn)->pn_type == pfstype_symlink,   \
("%s(): VLNK vnode refers to non-link pfs_node", __func__))
 
+#definePFS_MAXBUFSIZ   1024 * 1024
+
 /*
  * Returns the fileno, adjusted for target pid
  */
@@ -677,8 +679,8 @@ pfs_read(struct vop_read_args *va)
goto ret;
}
buflen = uio->uio_offset + uio->uio_resid;
-   if (buflen > MAXPHYS)
-   buflen = MAXPHYS;
+   if (buflen > PFS_MAXBUFSIZ)
+   buflen = PFS_MAXBUFSIZ;
 
sb = sbuf_new(sb, NULL, buflen + 1, 0);
if (sb == NULL) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366722 - head/sys/compat/linprocfs

2020-10-15 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Oct 15 12:48:30 2020
New Revision: 366722
URL: https://svnweb.freebsd.org/changeset/base/366722

Log:
  With some popular multiplayer games (such as Counter-Strike: Global
  Offensive) the Linux Steam client likes to occasionally scan the game
  process memory, presumably as part anti-cheat measures. Turns out
  the client also expects each inode entry to be followed by a space
  character, otherwise the parsing code crashes.
  
  PR:   248216
  Submitted by: Alex S 
  MFC after:2 weeks

Modified:
  head/sys/compat/linprocfs/linprocfs.c

Modified: head/sys/compat/linprocfs/linprocfs.c
==
--- head/sys/compat/linprocfs/linprocfs.c   Thu Oct 15 11:44:28 2020
(r366721)
+++ head/sys/compat/linprocfs/linprocfs.c   Thu Oct 15 12:48:30 2020
(r366722)
@@ -1249,7 +1249,7 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
0,
0,
(u_long)ino,
-   *name ? " " : "",
+   *name ? " " : " ",
name
);
if (freename)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366534 - head/sys/riscv/riscv

2020-10-08 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Oct  8 11:04:32 2020
New Revision: 366534
URL: https://svnweb.freebsd.org/changeset/base/366534

Log:
  Remove yet another useless assignment, adding a KASSERT just in case.
  
  Reviewed by:  kp
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26698

Modified:
  head/sys/riscv/riscv/trap.c

Modified: head/sys/riscv/riscv/trap.c
==
--- head/sys/riscv/riscv/trap.c Thu Oct  8 10:59:49 2020(r366533)
+++ head/sys/riscv/riscv/trap.c Thu Oct  8 11:04:32 2020(r366534)
@@ -158,15 +158,12 @@ dump_regs(struct trapframe *frame)
 }
 
 static void
-ecall_handler(struct trapframe *frame)
+ecall_handler(void)
 {
struct thread *td;
 
td = curthread;
 
-   KASSERT(td->td_frame == frame,
-   ("%s: td_frame %p != frame %p", __func__, td->td_frame, frame));
-
syscallenter(td);
syscallret(td);
 }
@@ -324,9 +321,11 @@ do_trap_user(struct trapframe *frame)
struct pcb *pcb;
 
td = curthread;
-   td->td_frame = frame;
pcb = td->td_pcb;
 
+   KASSERT(td->td_frame == frame,
+   ("%s: td_frame %p != frame %p", __func__, td->td_frame, frame));
+
/* Ensure we came from usermode, interrupts disabled */
KASSERT((csr_read(sstatus) & (SSTATUS_SPP | SSTATUS_SIE)) == 0,
("Came from U mode with interrupts enabled"));
@@ -357,7 +356,7 @@ do_trap_user(struct trapframe *frame)
break;
case EXCP_USER_ECALL:
frame->tf_sepc += 4;/* Next instruction */
-   ecall_handler(frame);
+   ecall_handler();
break;
case EXCP_ILLEGAL_INSTRUCTION:
 #ifdef FPE
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366515 - head/sys/riscv/riscv

2020-10-07 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Oct  7 12:11:11 2020
New Revision: 366515
URL: https://svnweb.freebsd.org/changeset/base/366515

Log:
  Don't use critical section when calling intr_irq_handler() - that function
  enters critical section by itself anyway.
  
  Reviewed by:  kp
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26694

Modified:
  head/sys/riscv/riscv/intr_machdep.c

Modified: head/sys/riscv/riscv/intr_machdep.c
==
--- head/sys/riscv/riscv/intr_machdep.c Wed Oct  7 10:58:56 2020
(r366514)
+++ head/sys/riscv/riscv/intr_machdep.c Wed Oct  7 12:11:11 2020
(r366515)
@@ -158,8 +158,6 @@ riscv_cpu_intr(struct trapframe *frame)
struct intr_irqsrc *isrc;
int active_irq;
 
-   critical_enter();
-
KASSERT(frame->tf_scause & EXCP_INTR,
("riscv_cpu_intr: wrong frame passed"));
 
@@ -169,18 +167,16 @@ riscv_cpu_intr(struct trapframe *frame)
case IRQ_SOFTWARE_USER:
case IRQ_SOFTWARE_SUPERVISOR:
case IRQ_TIMER_SUPERVISOR:
+   critical_enter();
isrc = [active_irq].isrc;
if (intr_isrc_dispatch(isrc, frame) != 0)
printf("stray interrupt %d\n", active_irq);
+   critical_exit();
break;
case IRQ_EXTERNAL_SUPERVISOR:
intr_irq_handler(frame);
break;
-   default:
-   break;
}
-
-   critical_exit();
 }
 
 #ifdef SMP
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366456 - head/sys/arm64/arm64

2020-10-05 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Oct  5 18:46:14 2020
New Revision: 366456
URL: https://svnweb.freebsd.org/changeset/base/366456

Log:
  Tweak arm64's cpu_fetch_syscall_args().  This should make it possible
  for the compiler to inline the memcpy().
  
  Reviewed by:  andrew
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26629

Modified:
  head/sys/arm64/arm64/trap.c

Modified: head/sys/arm64/arm64/trap.c
==
--- head/sys/arm64/arm64/trap.c Mon Oct  5 18:45:32 2020(r366455)
+++ head/sys/arm64/arm64/trap.c Mon Oct  5 18:46:14 2020(r366456)
@@ -123,30 +123,31 @@ int
 cpu_fetch_syscall_args(struct thread *td)
 {
struct proc *p;
-   register_t *ap;
+   register_t *ap, *dst_ap;
struct syscall_args *sa;
-   int nap;
 
-   nap = MAXARGS;
p = td->td_proc;
-   ap = td->td_frame->tf_x;
sa = >td_sa;
+   ap = td->td_frame->tf_x;
+   dst_ap = >args[0];
 
sa->code = td->td_frame->tf_x[8];
 
-   if (sa->code == SYS_syscall || sa->code == SYS___syscall) {
+   if (__predict_false(sa->code == SYS_syscall || sa->code == 
SYS___syscall)) {
sa->code = *ap++;
-   nap--;
+   } else {
+   *dst_ap++ = *ap++;
}
 
-   if (sa->code >= p->p_sysent->sv_size)
+   if (__predict_false(sa->code >= p->p_sysent->sv_size))
sa->callp = >p_sysent->sv_table[0];
else
sa->callp = >p_sysent->sv_table[sa->code];
 
-   memcpy(sa->args, ap, nap * sizeof(register_t));
-   if (sa->callp->sy_narg > nap)
-   panic("ARM64TODO: Could we have more than %d args?", MAXARGS);
+   KASSERT(sa->callp->sy_narg <= nitems(sa->args),
+   ("Syscall %d takes too many arguments", sa->code));
+
+   memcpy(dst_ap, ap, (MAXARGS - 1) * sizeof(register_t));
 
td->td_retval[0] = 0;
td->td_retval[1] = 0;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366454 - head/sys/riscv/riscv

2020-10-05 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Oct  5 18:41:35 2020
New Revision: 366454
URL: https://svnweb.freebsd.org/changeset/base/366454

Log:
  Drop useless assignment, and add a KASSERT to make sure it really was useless.
  
  Reviewed by:  nick, jhb
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26649

Modified:
  head/sys/riscv/riscv/trap.c

Modified: head/sys/riscv/riscv/trap.c
==
--- head/sys/riscv/riscv/trap.c Mon Oct  5 18:17:50 2020(r366453)
+++ head/sys/riscv/riscv/trap.c Mon Oct  5 18:41:35 2020(r366454)
@@ -163,7 +163,9 @@ svc_handler(struct trapframe *frame)
struct thread *td;
 
td = curthread;
-   td->td_frame = frame;
+
+   KASSERT(td->td_frame == frame,
+   ("%s: td_frame %p != frame %p", __func__, td->td_frame, frame));
 
syscallenter(td);
syscallret(td);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366392 - head/sys/riscv/riscv

2020-10-03 Thread Edward Tomasz Napierala
Author: trasz
Date: Sat Oct  3 13:01:07 2020
New Revision: 366392
URL: https://svnweb.freebsd.org/changeset/base/366392

Log:
  Optimize riscv's cpu_fetch_syscall_args(), making it possible
  for the compiler to inline the memcpy.
  
  Reviewed by:  arichardson, mhorne
  MFC after:2 weeks
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26528

Modified:
  head/sys/riscv/riscv/trap.c

Modified: head/sys/riscv/riscv/trap.c
==
--- head/sys/riscv/riscv/trap.c Sat Oct  3 12:03:08 2020(r366391)
+++ head/sys/riscv/riscv/trap.c Sat Oct  3 13:01:07 2020(r366392)
@@ -96,30 +96,31 @@ int
 cpu_fetch_syscall_args(struct thread *td)
 {
struct proc *p;
-   register_t *ap;
+   register_t *ap, *dst_ap;
struct syscall_args *sa;
-   int nap;
 
-   nap = NARGREG;
p = td->td_proc;
sa = >td_sa;
ap = >td_frame->tf_a[0];
+   dst_ap = >args[0];
 
sa->code = td->td_frame->tf_t[0];
 
-   if (sa->code == SYS_syscall || sa->code == SYS___syscall) {
+   if (__predict_false(sa->code == SYS_syscall || sa->code == 
SYS___syscall)) {
sa->code = *ap++;
-   nap--;
+   } else {
+   *dst_ap++ = *ap++;
}
 
-   if (sa->code >= p->p_sysent->sv_size)
+   if (__predict_false(sa->code >= p->p_sysent->sv_size))
sa->callp = >p_sysent->sv_table[0];
else
sa->callp = >p_sysent->sv_table[sa->code];
 
-   memcpy(sa->args, ap, nap * sizeof(register_t));
-   if (sa->callp->sy_narg > nap)
-   panic("TODO: Could we have more then %d args?", NARGREG);
+   KASSERT(sa->callp->sy_narg <= nitems(sa->args),
+   ("Syscall %d takes too many arguments", sa->code));
+
+   memcpy(dst_ap, ap, (NARGREG - 1) * sizeof(register_t));
 
td->td_retval[0] = 0;
td->td_retval[1] = 0;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366391 - head/sys/kern

2020-10-03 Thread Edward Tomasz Napierala
Author: trasz
Date: Sat Oct  3 12:03:08 2020
New Revision: 366391
URL: https://svnweb.freebsd.org/changeset/base/366391

Log:
  Move KTRUSERRET() from userret() to ast().  It's a really long
  detour - it writes ktrace entries to the filesystem - so the overhead
  of ast() won't make any difference.
  
  Reviewed by:  kib
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26404

Modified:
  head/sys/kern/kern_ktrace.c
  head/sys/kern/subr_trap.c

Modified: head/sys/kern/kern_ktrace.c
==
--- head/sys/kern/kern_ktrace.c Sat Oct  3 10:47:17 2020(r366390)
+++ head/sys/kern/kern_ktrace.c Sat Oct  3 12:03:08 2020(r366391)
@@ -347,6 +347,9 @@ ktr_enqueuerequest(struct thread *td, struct ktr_reque
mtx_lock(_mtx);
STAILQ_INSERT_TAIL(>td_proc->p_ktr, req, ktr_list);
mtx_unlock(_mtx);
+   thread_lock(td);
+   td->td_flags |= TDF_ASTPENDING;
+   thread_unlock(td);
 }
 
 /*

Modified: head/sys/kern/subr_trap.c
==
--- head/sys/kern/subr_trap.c   Sat Oct  3 10:47:17 2020(r366390)
+++ head/sys/kern/subr_trap.c   Sat Oct  3 12:03:08 2020(r366391)
@@ -130,9 +130,6 @@ userret(struct thread *td, struct trapframe *frame)
PROC_UNLOCK(p);
}
 #endif
-#ifdef KTRACE
-   KTRUSERRET(td);
-#endif
 
/*
 * Charge system time if profiling.
@@ -340,6 +337,10 @@ ast(struct trapframe *framep)
 */
if (td->td_pflags & TDP_SIGFASTPENDING)
sigfastblock_setpend(td, false);
+
+#ifdef KTRACE
+   KTRUSERRET(td);
+#endif
 
/*
 * We need to check to see if we have to exit or wait due to a
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366337 - head/usr.sbin/ctld

2020-10-01 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Oct  1 18:56:44 2020
New Revision: 366337
URL: https://svnweb.freebsd.org/changeset/base/366337

Log:
  Don't ignore the return value from gethostname(3).  It probably
  cannot happen, but it silences Coverity.
  
  Reviewed by:  mav
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D26606

Modified:
  head/usr.sbin/ctld/ctld.c

Modified: head/usr.sbin/ctld/ctld.c
==
--- head/usr.sbin/ctld/ctld.c   Thu Oct  1 18:45:31 2020(r366336)
+++ head/usr.sbin/ctld/ctld.c   Thu Oct  1 18:56:44 2020(r366337)
@@ -931,7 +931,7 @@ void
 isns_register(struct isns *isns, struct isns *oldisns)
 {
struct conf *conf = isns->i_conf;
-   int s;
+   int error, s;
char hostname[256];
 
if (TAILQ_EMPTY(>conf_targets) ||
@@ -943,8 +943,10 @@ isns_register(struct isns *isns, struct isns *oldisns)
set_timeout(0, false);
return;
}
-   gethostname(hostname, sizeof(hostname));
-
+   error = gethostname(hostname, sizeof(hostname));
+   if (error != 0)
+   log_err(1, "gethostname");
+ 
if (oldisns == NULL || TAILQ_EMPTY(>i_conf->conf_targets))
oldisns = isns;
isns_do_deregister(oldisns, s, hostname);
@@ -957,7 +959,7 @@ void
 isns_check(struct isns *isns)
 {
struct conf *conf = isns->i_conf;
-   int s, res;
+   int error, s, res;
char hostname[256];
 
if (TAILQ_EMPTY(>conf_targets) ||
@@ -969,8 +971,10 @@ isns_check(struct isns *isns)
set_timeout(0, false);
return;
}
-   gethostname(hostname, sizeof(hostname));
-
+   error = gethostname(hostname, sizeof(hostname));
+   if (error != 0)
+   log_err(1, "gethostname");
+ 
res = isns_do_check(isns, s, hostname);
if (res < 0) {
isns_do_deregister(isns, s, hostname);
@@ -984,7 +988,7 @@ void
 isns_deregister(struct isns *isns)
 {
struct conf *conf = isns->i_conf;
-   int s;
+   int error, s;
char hostname[256];
 
if (TAILQ_EMPTY(>conf_targets) ||
@@ -994,8 +998,10 @@ isns_deregister(struct isns *isns)
s = isns_do_connect(isns);
if (s < 0)
return;
-   gethostname(hostname, sizeof(hostname));
-
+   error = gethostname(hostname, sizeof(hostname));
+   if (error != 0)
+   log_err(1, "gethostname");
+ 
isns_do_deregister(isns, s, hostname);
close(s);
set_timeout(0, false);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366336 - head/sys/kern

2020-10-01 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Oct  1 18:45:31 2020
New Revision: 366336
URL: https://svnweb.freebsd.org/changeset/base/366336

Log:
  Only clear TDP_NERRNO when needed, ie when it's previously been set.
  
  Reviewed by:  kib
  Tested by:pho
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26612

Modified:
  head/sys/kern/subr_syscall.c

Modified: head/sys/kern/subr_syscall.c
==
--- head/sys/kern/subr_syscall.cThu Oct  1 18:17:56 2020
(r366335)
+++ head/sys/kern/subr_syscall.cThu Oct  1 18:45:31 2020
(r366336)
@@ -138,7 +138,8 @@ syscallenter(struct thread *td)
(void)sigfastblock_fetch(td);
 
/* Let system calls set td_errno directly. */
-   td->td_pflags &= ~TDP_NERRNO;
+   KASSERT((td->td_pflags & TDP_NERRNO) == 0,
+   ("%s: TDP_NERRNO set", __func__));
 
if (__predict_false(SYSTRACE_ENABLED() ||
AUDIT_SYSCALL_ENTER(sa->code, td))) {
@@ -149,7 +150,9 @@ syscallenter(struct thread *td)
 #endif
error = (sa->callp->sy_call)(td, sa->args);
/* Save the latest error return value. */
-   if (__predict_false((td->td_pflags & TDP_NERRNO) == 0))
+   if (__predict_false((td->td_pflags & TDP_NERRNO) != 0))
+   td->td_pflags &= ~TDP_NERRNO;
+   else
td->td_errno = error;
AUDIT_SYSCALL_EXIT(error, td);
 #ifdef KDTRACE_HOOKS
@@ -161,7 +164,9 @@ syscallenter(struct thread *td)
} else {
error = (sa->callp->sy_call)(td, sa->args);
/* Save the latest error return value. */
-   if (__predict_false((td->td_pflags & TDP_NERRNO) == 0))
+   if (__predict_false((td->td_pflags & TDP_NERRNO) != 0))
+   td->td_pflags &= ~TDP_NERRNO;
+   else
td->td_errno = error;
}
syscall_thread_exit(td, sa->callp);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366251 - head/sys/conf

2020-09-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Sep 29 11:48:22 2020
New Revision: 366251
URL: https://svnweb.freebsd.org/changeset/base/366251

Log:
  Build debug kernels with -O2.
  
  LLVM 11 changed the meaning of '-O' from '-O2' to '-O1', which resulted
  in debug kernels (with 'makeoptions DEBUG=-g') being built with inlining
  disabled, causing severe performance hit.
  
  The -O2 was already being used for building amd64, powerpc, and powerpcspe.
  
  Discussed with:   jrtc27, arichardson, bdragon, jhibbits
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26471

Modified:
  head/sys/conf/kern.pre.mk

Modified: head/sys/conf/kern.pre.mk
==
--- head/sys/conf/kern.pre.mk   Tue Sep 29 11:18:48 2020(r366250)
+++ head/sys/conf/kern.pre.mk   Tue Sep 29 11:48:22 2020(r366251)
@@ -51,25 +51,14 @@ OBJCOPY?=   objcopy
 SIZE?= size
 
 .if defined(DEBUG)
-.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpcspe"
-# Work around clang 11 miscompile on 32 bit powerpc.
-_MINUS_O=  -O2
-.else
-_MINUS_O=  -O
-.endif
 CTFFLAGS+= -g
-.else
-_MINUS_O=  -O2
 .endif
-.if ${MACHINE_CPUARCH} == "amd64"
-.if ${COMPILER_TYPE} == "clang"
-COPTFLAGS?=-O2 -pipe
+.if ${MACHINE_CPUARCH} == "amd64" && ${COMPILER_TYPE} != "clang"
+_COPTFLAGS_EXTRA=-frename-registers
 .else
-COPTFLAGS?=-O2 -frename-registers -pipe
+_COPTFLAGS_EXTRA=
 .endif
-.else
-COPTFLAGS?=${_MINUS_O} -pipe
-.endif
+COPTFLAGS?=-O2 -pipe ${_COPTFLAGS_EXTRA}
 .if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
 COPTFLAGS+= -fno-strict-aliasing
 .endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366250 - head/sys/kern

2020-09-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Sep 29 11:18:48 2020
New Revision: 366250
URL: https://svnweb.freebsd.org/changeset/base/366250

Log:
  Use the 'traced' variable instead of comparing p->p_flag again.
  
  Reviewed by:  kib
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26577

Modified:
  head/sys/kern/subr_syscall.c

Modified: head/sys/kern/subr_syscall.c
==
--- head/sys/kern/subr_syscall.cTue Sep 29 10:07:46 2020
(r366249)
+++ head/sys/kern/subr_syscall.cTue Sep 29 11:18:48 2020
(r366250)
@@ -90,7 +90,7 @@ syscallenter(struct thread *td)
goto retval;
}
 
-   if (__predict_false((p->p_flag & P_TRACED) != 0)) {
+   if (__predict_false(traced)) {
PROC_LOCK(p);
if (p->p_ptevents & PTRACE_SCE)
ptracestop((td), SIGTRAP, NULL);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366205 - in head/sys: amd64/amd64 amd64/cloudabi32 amd64/cloudabi64 amd64/ia32 amd64/include amd64/linux amd64/linux32 arm/arm arm/cloudabi32 arm/include arm64/arm64 arm64/cloudabi32 a...

2020-09-27 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun Sep 27 18:47:06 2020
New Revision: 366205
URL: https://svnweb.freebsd.org/changeset/base/366205

Log:
  Get rid of sa->narg.  It serves no purpose; use sa->callp->sy_narg instead.
  
  Reviewed by:  kib
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26458

Modified:
  head/sys/amd64/amd64/trap.c
  head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
  head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
  head/sys/amd64/ia32/ia32_syscall.c
  head/sys/amd64/include/proc.h
  head/sys/amd64/linux/linux_sysvec.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/arm/arm/syscall.c
  head/sys/arm/cloudabi32/cloudabi32_sysvec.c
  head/sys/arm/include/proc.h
  head/sys/arm64/arm64/elf32_machdep.c
  head/sys/arm64/arm64/trap.c
  head/sys/arm64/cloudabi32/cloudabi32_sysvec.c
  head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
  head/sys/arm64/include/proc.h
  head/sys/arm64/linux/linux_sysvec.c
  head/sys/i386/cloudabi32/cloudabi32_sysvec.c
  head/sys/i386/i386/trap.c
  head/sys/i386/include/proc.h
  head/sys/i386/linux/linux_sysvec.c
  head/sys/kern/kern_thread.c
  head/sys/kern/subr_syscall.c
  head/sys/kern/sys_process.c
  head/sys/mips/include/proc.h
  head/sys/mips/mips/trap.c
  head/sys/powerpc/include/proc.h
  head/sys/powerpc/powerpc/trap.c
  head/sys/riscv/include/proc.h
  head/sys/riscv/riscv/trap.c

Modified: head/sys/amd64/amd64/trap.c
==
--- head/sys/amd64/amd64/trap.c Sun Sep 27 18:39:15 2020(r366204)
+++ head/sys/amd64/amd64/trap.c Sun Sep 27 18:47:06 2020(r366205)
@@ -999,15 +999,15 @@ cpu_fetch_syscall_args_fallback(struct thread *td, str
else
sa->callp = >p_sysent->sv_table[sa->code];
 
-   sa->narg = sa->callp->sy_narg;
-   KASSERT(sa->narg <= nitems(sa->args), ("Too many syscall arguments!"));
+   KASSERT(sa->callp->sy_narg <= nitems(sa->args),
+   ("Too many syscall arguments!"));
argp = >tf_rdi;
argp += reg;
memcpy(sa->args, argp, sizeof(sa->args[0]) * NARGREGS);
-   if (sa->narg > regcnt) {
+   if (sa->callp->sy_narg > regcnt) {
params = (caddr_t)frame->tf_rsp + sizeof(register_t);
error = copyin(params, >args[regcnt],
-   (sa->narg - regcnt) * sizeof(sa->args[0]));
+   (sa->callp->sy_narg - regcnt) * sizeof(sa->args[0]));
if (__predict_false(error != 0))
return (error);
}
@@ -1037,10 +1037,10 @@ cpu_fetch_syscall_args(struct thread *td)
return (cpu_fetch_syscall_args_fallback(td, sa));
 
sa->callp = >p_sysent->sv_table[sa->code];
-   sa->narg = sa->callp->sy_narg;
-   KASSERT(sa->narg <= nitems(sa->args), ("Too many syscall arguments!"));
+   KASSERT(sa->callp->sy_narg <= nitems(sa->args),
+   ("Too many syscall arguments!"));
 
-   if (__predict_false(sa->narg > NARGREGS))
+   if (__predict_false(sa->callp->sy_narg > NARGREGS))
return (cpu_fetch_syscall_args_fallback(td, sa));
 
memcpy(sa->args, >tf_rdi, sizeof(sa->args[0]) * NARGREGS);

Modified: head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
==
--- head/sys/amd64/cloudabi32/cloudabi32_sysvec.c   Sun Sep 27 18:39:15 
2020(r366204)
+++ head/sys/amd64/cloudabi32/cloudabi32_sysvec.c   Sun Sep 27 18:47:06 
2020(r366205)
@@ -104,7 +104,6 @@ cloudabi32_fetch_syscall_args(struct thread *td)
if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL)
return (ENOSYS);
sa->callp = _sysent[sa->code];
-   sa->narg = sa->callp->sy_narg;
 
/*
 * Fetch system call arguments.
@@ -117,7 +116,7 @@ cloudabi32_fetch_syscall_args(struct thread *td)
 * implementation used by 64-bit processes.
 */
error = copyin((void *)frame->tf_rcx, sa->args,
-   sa->narg * sizeof(sa->args[0]));
+   sa->callp->sy_narg * sizeof(sa->args[0]));
if (error != 0)
return (error);
 

Modified: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Sun Sep 27 18:39:15 
2020(r366204)
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Sun Sep 27 18:47:06 
2020(r366205)
@@ -101,7 +101,6 @@ cloudabi64_fetch_syscall_args(struct thread *td)
if (sa->code >= CLOUDABI64_SYS_MAXSYSCALL)
return (ENOSYS);
sa->callp = _sysent[sa->code];
-   sa->narg = sa->callp->sy_narg;
 
/* Fetch system call arguments. */
sa->args[0] = frame->tf_rdi;

Modified: head/sys/amd64/ia32/ia32_syscall.c
==
--- head/sys/amd64/ia32/ia32_syscall.c  Sun Sep 27 18:39:15 

svn commit: r366201 - head/sys/sys

2020-09-27 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun Sep 27 18:14:01 2020
New Revision: 366201
URL: https://svnweb.freebsd.org/changeset/base/366201

Log:
  Shrink struct sysent from 48 to 32 bytes (on LP64; on ILP32 its probably
  from 32 to 28) by shrinking some entries and reordering them.
  
  Reviewed by:  kib
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26508

Modified:
  head/sys/sys/sysent.h

Modified: head/sys/sys/sysent.h
==
--- head/sys/sys/sysent.h   Sun Sep 27 16:15:03 2020(r366200)
+++ head/sys/sys/sysent.h   Sun Sep 27 18:14:01 2020(r366201)
@@ -65,14 +65,14 @@ extern bool systrace_enabled;
 #endif /* _KERNEL */
 
 struct sysent {/* system call table */
-   int sy_narg;/* number of arguments */
sy_call_t *sy_call; /* implementing function */
-   au_event_t sy_auevent;  /* audit event associated with syscall */
systrace_args_func_t sy_systrace_args_func;
/* optional argument conversion function. */
+   u_int8_t sy_narg;   /* number of arguments */
+   u_int8_t sy_flags;  /* General flags for system calls. */
+   au_event_t sy_auevent;  /* audit event associated with syscall */
u_int32_t sy_entry; /* DTrace entry ID for systrace. */
u_int32_t sy_return;/* DTrace return ID for systrace. */
-   u_int32_t sy_flags; /* General flags for system calls. */
u_int32_t sy_thrcnt;
 };
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r366147 - in head/sys: amd64/linux amd64/linux32 arm/linux arm64/linux compat/cloudabi32 compat/cloudabi64 compat/freebsd32 i386/linux kern sys

2020-09-25 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Sep 25 10:05:38 2020
New Revision: 366147
URL: https://svnweb.freebsd.org/changeset/base/366147

Log:
  Regen after r366145.
  
  Sponsored by: DARPA

Modified:
  head/sys/amd64/linux/linux_proto.h
  head/sys/amd64/linux/linux_sysent.c
  head/sys/amd64/linux32/linux32_proto.h
  head/sys/amd64/linux32/linux32_sysent.c
  head/sys/arm/linux/linux_proto.h
  head/sys/arm/linux/linux_sysent.c
  head/sys/arm64/linux/linux_proto.h
  head/sys/arm64/linux/linux_sysent.c
  head/sys/compat/cloudabi32/cloudabi32_proto.h
  head/sys/compat/cloudabi32/cloudabi32_sysent.c
  head/sys/compat/cloudabi64/cloudabi64_proto.h
  head/sys/compat/cloudabi64/cloudabi64_sysent.c
  head/sys/compat/freebsd32/freebsd32_proto.h
  head/sys/compat/freebsd32/freebsd32_sysent.c
  head/sys/i386/linux/linux_proto.h
  head/sys/i386/linux/linux_sysent.c
  head/sys/kern/init_sysent.c
  head/sys/sys/sysproto.h

Modified: head/sys/amd64/linux/linux_proto.h
==
--- head/sys/amd64/linux/linux_proto.h  Fri Sep 25 09:56:50 2020
(r366146)
+++ head/sys/amd64/linux/linux_proto.h  Fri Sep 25 10:05:38 2020
(r366147)
@@ -1615,35 +1615,41 @@ int linux_io_uring_register(struct thread *, struct 
li
 
 #endif /* COMPAT_43 */
 
+
 #ifdef COMPAT_FREEBSD4
 
 #definenosys   linux_nosys
 
 #endif /* COMPAT_FREEBSD4 */
 
+
 #ifdef COMPAT_FREEBSD6
 
 #definenosys   linux_nosys
 
 #endif /* COMPAT_FREEBSD6 */
 
+
 #ifdef COMPAT_FREEBSD7
 
 #definenosys   linux_nosys
 
 #endif /* COMPAT_FREEBSD7 */
 
+
 #ifdef COMPAT_FREEBSD10
 
 #definenosys   linux_nosys
 
 #endif /* COMPAT_FREEBSD10 */
 
+
 #ifdef COMPAT_FREEBSD11
 
 #definenosys   linux_nosys
 
 #endif /* COMPAT_FREEBSD11 */
+
 
 #ifdef COMPAT_FREEBSD12
 

Modified: head/sys/amd64/linux/linux_sysent.c
==
--- head/sys/amd64/linux/linux_sysent.c Fri Sep 25 09:56:50 2020
(r366146)
+++ head/sys/amd64/linux/linux_sysent.c Fri Sep 25 10:05:38 2020
(r366147)
@@ -17,433 +17,433 @@
 /* The casts are bogus but will do for now. */
 struct sysent linux_sysent[] = {
 #definenosys   linux_nosys
-   { AS(read_args), (sy_call_t *)sys_read, AUE_NULL, NULL, 0, 0, 0, 
SY_THR_STATIC },   /* 0 = read */
-   { AS(write_args), (sy_call_t *)sys_write, AUE_NULL, NULL, 0, 0, 0, 
SY_THR_STATIC }, /* 1 = write */
-   { AS(linux_open_args), (sy_call_t *)linux_open, AUE_OPEN_RWTC, NULL, 0, 
0, 0, SY_THR_STATIC },  /* 2 = linux_open */
-   { AS(close_args), (sy_call_t *)sys_close, AUE_CLOSE, NULL, 0, 0, 0, 
SY_THR_STATIC },/* 3 = close */
-   { AS(linux_newstat_args), (sy_call_t *)linux_newstat, AUE_STAT, NULL, 
0, 0, 0, SY_THR_STATIC }, /* 4 = linux_newstat */
-   { AS(linux_newfstat_args), (sy_call_t *)linux_newfstat, AUE_FSTAT, 
NULL, 0, 0, 0, SY_THR_STATIC },  /* 5 = linux_newfstat */
-   { AS(linux_newlstat_args), (sy_call_t *)linux_newlstat, AUE_LSTAT, 
NULL, 0, 0, 0, SY_THR_STATIC },  /* 6 = linux_newlstat */
-   { AS(poll_args), (sy_call_t *)sys_poll, AUE_POLL, NULL, 0, 0, 0, 
SY_THR_STATIC },   /* 7 = poll */
-   { AS(linux_lseek_args), (sy_call_t *)linux_lseek, AUE_LSEEK, NULL, 0, 
0, 0, SY_THR_STATIC },/* 8 = linux_lseek */
-   { AS(linux_mmap2_args), (sy_call_t *)linux_mmap2, AUE_MMAP, NULL, 0, 0, 
0, SY_THR_STATIC }, /* 9 = linux_mmap2 */
-   { AS(linux_mprotect_args), (sy_call_t *)linux_mprotect, AUE_MPROTECT, 
NULL, 0, 0, 0, SY_THR_STATIC },   /* 10 = linux_mprotect */
-   { AS(munmap_args), (sy_call_t *)sys_munmap, AUE_MUNMAP, NULL, 0, 0, 0, 
SY_THR_STATIC }, /* 11 = munmap */
-   { AS(linux_brk_args), (sy_call_t *)linux_brk, AUE_NULL, NULL, 0, 0, 0, 
SY_THR_STATIC }, /* 12 = linux_brk */
-   { AS(linux_rt_sigaction_args), (sy_call_t *)linux_rt_sigaction, 
AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC },   /* 13 = linux_rt_sigaction */
-   { AS(linux_rt_sigprocmask_args), (sy_call_t *)linux_rt_sigprocmask, 
AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC },   /* 14 = linux_rt_sigprocmask */
-   { AS(linux_rt_sigreturn_args), (sy_call_t *)linux_rt_sigreturn, 
AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC },   /* 15 = linux_rt_sigreturn */
-   { AS(linux_ioctl_args), (sy_call_t *)linux_ioctl, AUE_IOCTL, NULL, 0, 
0, 0, SY_THR_STATIC },/* 16 = linux_ioctl */
-   { AS(linux_pread_args), (sy_call_t *)linux_pread, AUE_PREAD, NULL, 0, 
0, 0, SY_THR_STATIC },/* 17 = linux_pread */
-   { AS(linux_pwrite_args), (sy_call_t *)linux_pwrite, AUE_PWRITE, NULL, 
0, 0, 0, SY_THR_STATIC }, /* 18 = linux_pwrite */
-   { AS(readv_args), (sy_call_t *)sys_readv, AUE_READV, NULL, 0, 0, 0, 
SY_THR_STATIC },/* 19 = readv */
-   { AS(writev_args), (sy_call_t *)sys_writev, AUE_WRITEV, NULL, 0, 0, 0, 
SY_THR_STATIC }, /* 20 = writev */
-   { AS(linux_access_args), (sy_call_t *)linux_access, 

svn commit: r366145 - head/sys/tools

2020-09-25 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Sep 25 09:34:00 2020
New Revision: 366145
URL: https://svnweb.freebsd.org/changeset/base/366145

Log:
  Make makesyscalls.lua initialize 'struct sysent' entries using c99
  designated initializers.  This makes it easier to modify 'struct sysent'
  layout.
  
  Reviewed by:  kevans
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26530

Modified:
  head/sys/tools/makesyscalls.lua

Modified: head/sys/tools/makesyscalls.lua
==
--- head/sys/tools/makesyscalls.lua Fri Sep 25 07:55:08 2020
(r366144)
+++ head/sys/tools/makesyscalls.lua Fri Sep 25 09:34:00 2020
(r366145)
@@ -740,12 +740,14 @@ local function handle_noncompat(sysnum, thr_flag, flag
config['syscallprefix'], funcalias, auditev))
end
 
-   write_line("sysent", string.format("\t{ %s, (sy_call_t *)", argssize))
+   write_line("sysent",
+   string.format("\t{ .sy_narg = %s, .sy_call = (sy_call_t *)", 
argssize))
local column = 8 + 2 + #argssize + 15
 
if flags & known_flags["NOSTD"] ~= 0 then
write_line("sysent", string.format(
-   "lkmressys, AUE_NULL, NULL, 0, 0, %s, SY_THR_ABSENT },",
+   "lkmressys, .sy_auevent = AUE_NULL, " ..
+   ".sy_flags = %s, .sy_thrcnt = SY_THR_ABSENT },",
sysflags))
column = column + #"lkmressys" + #"AUE_NULL" + 3
else
@@ -754,12 +756,12 @@ local function handle_noncompat(sysnum, thr_flag, flag
funcname:find("^linux") or
funcname:find("^cloudabi") then
write_line("sysent", string.format(
-   "%s, %s, NULL, 0, 0, %s, %s },",
+   "%s, .sy_auevent = %s, .sy_flags = %s, .sy_thrcnt = 
%s },",
funcname, auditev, sysflags, thr_flag))
column = column + #funcname + #auditev + #sysflags + 3
else
write_line("sysent", string.format(
-   "sys_%s, %s, NULL, 0, 0, %s, %s },",
+   "sys_%s, .sy_auevent = %s, .sy_flags = %s, 
.sy_thrcnt = %s },",
funcname, auditev, sysflags, thr_flag))
column = column + #funcname + #auditev + #sysflags + 7
end
@@ -781,7 +783,8 @@ end
 
 local function handle_obsol(sysnum, funcname, comment)
write_line("sysent",
-   "\t{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT 
},")
+   "\t{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, " ..
+   ".sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT 
},")
align_sysent_comment(34)
 
write_line("sysent", string.format("/* %d = obsolete %s */\n",
@@ -849,13 +852,15 @@ local function handle_compat(sysnum, thr_flag, flags, 
 
if flags & known_flags['NOSTD'] ~= 0 then
write_line("sysent", string.format(
-   "\t{ %s, (sy_call_t *)%s, %s, NULL, 0, 0, 0, SY_THR_ABSENT 
},",
+   "\t{ .sy_narg = %s, .sy_call = (sy_call_t *)%s, " ..
+   ".sy_auevent = %s, .sy_flags = 0, " ..
+   ".sy_thrcnt = SY_THR_ABSENT },",
"0", "lkmressys", "AUE_NULL"))
align_sysent_comment(8 + 2 + #"0" + 15 + #"lkmressys" +
#"AUE_NULL" + 3)
else
write_line("sysent", string.format(
-   "\t{ %s(%s,%s), %s, NULL, 0, 0, %s, %s },",
+   "\t{ %s(%s,%s), .sy_auevent = %s, .sy_flags = %s, 
.sy_thrcnt = %s },",
wrap, argssize, funcname, auditev, sysflags, thr_flag))
align_sysent_comment(8 + 9 + #argssize + 1 + #funcname +
#auditev + #sysflags + 4)
@@ -889,7 +894,9 @@ local function handle_unimpl(sysnum, sysstart, sysend,
sysnum = sysstart
while sysnum <= sysend do
write_line("sysent", string.format(
-   "\t{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, 
SY_THR_ABSENT },\t\t\t/* %d = %s */\n",
+   "\t{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, " ..
+   ".sy_auevent = AUE_NULL, .sy_flags = 0, " ..
+   ".sy_thrcnt = SY_THR_ABSENT },\t\t\t/* %d = %s */\n",
sysnum, comment))
write_line("sysnames", string.format(
"\t\"#%d\",\t\t\t/* %d = %s */\n",
@@ -1302,9 +1309,9 @@ for _, v in pairs(compat_options) do
write_line("sysinc", string.format([[
 
 #ifdef %s
-#define %s(n, name) n, (sy_call_t *)__CONCAT(%s,name)
+#define %s(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(%s,name)
 #else
-#define %s(n, name) 0, (sy_call_t *)nosys
+#define %s(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys

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

2020-09-17 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Sep 17 12:14:24 2020
New Revision: 365834
URL: https://svnweb.freebsd.org/changeset/base/365834

Log:
  Reduce code duplication by introducing linux_copyout_sockaddr()
  helper function.  No functional changes.
  
  Reviewed by:  emaste
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D25804

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

Modified: head/sys/compat/linux/linux_socket.c
==
--- head/sys/compat/linux/linux_socket.cThu Sep 17 11:44:45 2020
(r365833)
+++ head/sys/compat/linux/linux_socket.cThu Sep 17 12:14:24 2020
(r365834)
@@ -394,6 +394,22 @@ linux_set_socket_flags(int lflags, int *flags)
 }
 
 static int
+linux_copyout_sockaddr(const struct sockaddr *sa, void *uaddr, size_t len)
+{
+   struct l_sockaddr *lsa;
+   int error;
+
+   error = bsd_to_linux_sockaddr(sa, , len);
+   if (error != 0)
+   return (error);
+   
+   error = copyout(lsa, uaddr, len);
+   free(lsa, M_SONAME);
+
+   return (error);
+}
+
+static int
 linux_sendit(struct thread *td, int s, struct msghdr *mp, int flags,
 struct mbuf *control, enum uio_seg segflg)
 {
@@ -609,7 +625,6 @@ static int
 linux_accept_common(struct thread *td, int s, l_uintptr_t addr,
 l_uintptr_t namelen, int flags)
 {
-   struct l_sockaddr *lsa;
struct sockaddr *sa;
struct file *fp, *fp1;
int bflags, len;
@@ -665,10 +680,7 @@ linux_accept_common(struct thread *td, int s, l_uintpt
}
 
if (len != 0) {
-   error = bsd_to_linux_sockaddr(sa, , len);
-   if (error == 0)
-   error = copyout(lsa, PTRIN(addr), len);
-   free(lsa, M_SONAME);
+   error = linux_copyout_sockaddr(sa, PTRIN(addr), len);
 
/*
 * XXX: We should also copyout the len, shouldn't we?
@@ -704,7 +716,6 @@ linux_accept4(struct thread *td, struct linux_accept4_
 int
 linux_getsockname(struct thread *td, struct linux_getsockname_args *args)
 {
-   struct l_sockaddr *lsa;
struct sockaddr *sa;
int len, error;
 
@@ -716,13 +727,8 @@ linux_getsockname(struct thread *td, struct linux_gets
if (error != 0)
return (error);
 
-   if (len != 0) {
-   error = bsd_to_linux_sockaddr(sa, , len);
-   if (error == 0)
-   error = copyout(lsa, PTRIN(args->addr),
-   len);
-   free(lsa, M_SONAME);
-   }
+   if (len != 0)
+   error = linux_copyout_sockaddr(sa, PTRIN(args->addr), len);
 
free(sa, M_SONAME);
if (error == 0)
@@ -733,7 +739,6 @@ linux_getsockname(struct thread *td, struct linux_gets
 int
 linux_getpeername(struct thread *td, struct linux_getpeername_args *args)
 {
-   struct l_sockaddr *lsa;
struct sockaddr *sa;
int len, error;
 
@@ -747,13 +752,8 @@ linux_getpeername(struct thread *td, struct linux_getp
if (error != 0)
return (error);
 
-   if (len != 0) {
-   error = bsd_to_linux_sockaddr(sa, , len);
-   if (error == 0)
-   error = copyout(lsa, PTRIN(args->addr),
-   len);
-   free(lsa, M_SONAME);
-   }
+   if (len != 0)
+   error = linux_copyout_sockaddr(sa, PTRIN(args->addr), len);
 
free(sa, M_SONAME);
if (error == 0)
@@ -895,7 +895,6 @@ linux_sendto(struct thread *td, struct linux_sendto_ar
 int
 linux_recvfrom(struct thread *td, struct linux_recvfrom_args *args)
 {
-   struct l_sockaddr *lsa;
struct sockaddr *sa;
struct msghdr msg;
struct iovec aiov;
@@ -927,13 +926,8 @@ linux_recvfrom(struct thread *td, struct linux_recvfro
if (error != 0)
goto out;
 
-   if (PTRIN(args->from) != NULL) {
-   error = bsd_to_linux_sockaddr(sa, , msg.msg_namelen);
-   if (error == 0)
-   error = copyout(lsa, PTRIN(args->from),
-   msg.msg_namelen);
-   free(lsa, M_SONAME);
-   }
+   if (PTRIN(args->from) != NULL)
+   error = linux_copyout_sockaddr(sa, PTRIN(args->from), 
msg.msg_namelen);
 
if (error == 0 && PTRIN(args->fromlen) != NULL)
error = copyout(_namelen, PTRIN(args->fromlen),
@@ -1170,7 +1164,6 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
struct mbuf *control = NULL;
struct mbuf **controlp;
struct timeval *ftmvl;
-   struct l_sockaddr *lsa;
struct sockaddr *sa;
l_timeval ltmvl;
caddr_t outbuf;
@@ -1216,11 +1209,8 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
 */
if (msg->msg_name != NULL && msg->msg_namelen > 0) {
  

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

2020-09-17 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Sep 17 11:44:45 2020
New Revision: 365833
URL: https://svnweb.freebsd.org/changeset/base/365833

Log:
  Add support for SOUND_MIXER_WRITE_MONITOR ioctl.  Fixes alsamixer(1)
  on my x220.
  
  Reviewed by:  emaste
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D25806

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

Modified: head/sys/compat/linux/linux_ioctl.c
==
--- head/sys/compat/linux/linux_ioctl.c Thu Sep 17 11:39:33 2020
(r365832)
+++ head/sys/compat/linux/linux_ioctl.c Thu Sep 17 11:44:45 2020
(r365833)
@@ -1794,6 +1794,10 @@ linux_ioctl_sound(struct thread *td, struct linux_ioct
args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE3);
return (sys_ioctl(td, (struct ioctl_args *)args));
 
+   case LINUX_SOUND_MIXER_WRITE_MONITOR:
+   args->cmd = SETDIR(SOUND_MIXER_WRITE_MONITOR);
+   return (sys_ioctl(td, (struct ioctl_args *)args));
+
case LINUX_SOUND_MIXER_INFO: {
/* Key on encoded length */
switch ((args->cmd >> 16) & 0x1fff) {

Modified: head/sys/compat/linux/linux_ioctl.h
==
--- head/sys/compat/linux/linux_ioctl.h Thu Sep 17 11:39:33 2020
(r365832)
+++ head/sys/compat/linux/linux_ioctl.h Thu Sep 17 11:44:45 2020
(r365833)
@@ -278,6 +278,7 @@
 #defineLINUX_SOUND_MIXER_WRITE_LINE1   0x4d0E
 #defineLINUX_SOUND_MIXER_WRITE_LINE2   0x4d0F
 #defineLINUX_SOUND_MIXER_WRITE_LINE3   0x4d10
+#defineLINUX_SOUND_MIXER_WRITE_MONITOR 0x4d18
 #defineLINUX_SOUND_MIXER_INFO  0x4d65
 #defineLINUX_OSS_GETVERSION0x4d76
 #defineLINUX_SOUND_MIXER_READ_STEREODEVS   0x4dfb
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365832 - in head/sys: amd64/amd64 amd64/linux amd64/linux32 arm/arm arm64/arm64 arm64/linux compat/ia32 compat/linux i386/i386 i386/linux kern mips/mips powerpc/powerpc riscv/riscv sys

2020-09-17 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Sep 17 11:39:33 2020
New Revision: 365832
URL: https://svnweb.freebsd.org/changeset/base/365832

Log:
  Get rid of sv_errtbl and SV_ABI_ERRNO().
  
  Reviewed by:  kib
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26388

Modified:
  head/sys/amd64/amd64/elf_machdep.c
  head/sys/amd64/linux/linux_sysvec.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/arm/arm/elf_machdep.c
  head/sys/arm64/arm64/elf32_machdep.c
  head/sys/arm64/arm64/elf_machdep.c
  head/sys/arm64/linux/linux_sysvec.c
  head/sys/compat/ia32/ia32_sysvec.c
  head/sys/compat/linux/linux.h
  head/sys/compat/linux/linux_errno.c
  head/sys/compat/linux/linux_socket.c
  head/sys/i386/i386/elf_machdep.c
  head/sys/i386/linux/linux_sysvec.c
  head/sys/kern/imgact_aout.c
  head/sys/kern/init_main.c
  head/sys/mips/mips/elf_machdep.c
  head/sys/mips/mips/freebsd32_machdep.c
  head/sys/powerpc/powerpc/elf32_machdep.c
  head/sys/powerpc/powerpc/elf64_machdep.c
  head/sys/riscv/riscv/elf_machdep.c
  head/sys/sys/sysent.h

Modified: head/sys/amd64/amd64/elf_machdep.c
==
--- head/sys/amd64/amd64/elf_machdep.c  Thu Sep 17 07:13:41 2020
(r365831)
+++ head/sys/amd64/amd64/elf_machdep.c  Thu Sep 17 11:39:33 2020
(r365832)
@@ -52,8 +52,6 @@ __FBSDID("$FreeBSD$");
 struct sysentvec elf64_freebsd_sysvec_la48 = {
.sv_size= SYS_MAXSYSCALL,
.sv_table   = sysent,
-   .sv_errsize = 0,
-   .sv_errtbl  = NULL,
.sv_transtrap   = NULL,
.sv_fixup   = __elfN(freebsd_fixup),
.sv_sendsig = sendsig,
@@ -89,8 +87,6 @@ struct sysentvec elf64_freebsd_sysvec_la48 = {
 struct sysentvec elf64_freebsd_sysvec_la57 = {
.sv_size= SYS_MAXSYSCALL,
.sv_table   = sysent,
-   .sv_errsize = 0,
-   .sv_errtbl  = NULL,
.sv_transtrap   = NULL,
.sv_fixup   = __elfN(freebsd_fixup),
.sv_sendsig = sendsig,

Modified: head/sys/amd64/linux/linux_sysvec.c
==
--- head/sys/amd64/linux/linux_sysvec.c Thu Sep 17 07:13:41 2020
(r365831)
+++ head/sys/amd64/linux/linux_sysvec.c Thu Sep 17 11:39:33 2020
(r365832)
@@ -221,7 +221,7 @@ linux_set_syscall_retval(struct thread *td, int error)
 
if (__predict_false(error != 0)) {
if (error != ERESTART && error != EJUSTRETURN)
-   frame->tf_rax = SV_ABI_ERRNO(td->td_proc, error);
+   frame->tf_rax = linux_to_bsd_errno(error);
}
 
 /* Restore all registers. */
@@ -732,8 +732,6 @@ linux_vsyscall(struct thread *td)
 struct sysentvec elf_linux_sysvec = {
.sv_size= LINUX_SYS_MAXSYSCALL,
.sv_table   = linux_sysent,
-   .sv_errsize = ELAST + 1,
-   .sv_errtbl  = linux_errtbl,
.sv_transtrap   = linux_translate_traps,
.sv_fixup   = linux_fixup_elf,
.sv_sendsig = linux_rt_sendsig,

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Thu Sep 17 07:13:41 2020
(r365831)
+++ head/sys/amd64/linux32/linux32_sysvec.c Thu Sep 17 11:39:33 2020
(r365832)
@@ -679,7 +679,7 @@ linux32_set_syscall_retval(struct thread *td, int erro
 
if (__predict_false(error != 0)) {
if (error != ERESTART && error != EJUSTRETURN)
-   frame->tf_rax = SV_ABI_ERRNO(td->td_proc, error);
+   frame->tf_rax = linux_to_bsd_errno(error);
}
 }
 
@@ -898,8 +898,6 @@ linux32_fixlimit(struct rlimit *rl, int which)
 struct sysentvec elf_linux_sysvec = {
.sv_size= LINUX32_SYS_MAXSYSCALL,
.sv_table   = linux32_sysent,
-   .sv_errsize = ELAST + 1,
-   .sv_errtbl  = linux_errtbl,
.sv_transtrap   = linux_translate_traps,
.sv_fixup   = linux_fixup_elf,
.sv_sendsig = linux_sendsig,

Modified: head/sys/arm/arm/elf_machdep.c
==
--- head/sys/arm/arm/elf_machdep.c  Thu Sep 17 07:13:41 2020
(r365831)
+++ head/sys/arm/arm/elf_machdep.c  Thu Sep 17 11:39:33 2020
(r365832)
@@ -65,8 +65,6 @@ u_long elf_hwcap2;
 struct sysentvec elf32_freebsd_sysvec = {
.sv_size= SYS_MAXSYSCALL,
.sv_table   = sysent,
-   .sv_errsize = 0,
-   .sv_errtbl  = NULL,
.sv_transtrap   = NULL,
.sv_fixup   = __elfN(freebsd_fixup),
.sv_sendsig = sendsig,

Modified: head/sys/arm64/arm64/elf32_machdep.c
==
--- head/sys/arm64/arm64/elf32_machdep.cThu Sep 17 07:13:41 2020   

svn commit: r365755 - in head/sys: amd64/amd64 amd64/linux amd64/linux32 arm/arm arm64/arm64 arm64/linux i386/i386 i386/linux powerpc/powerpc

2020-09-15 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Sep 15 16:41:21 2020
New Revision: 365755
URL: https://svnweb.freebsd.org/changeset/base/365755

Log:
  Move SV_ABI_ERRNO translation into linux-specific code, to simplify
  the syscall path and declutter it a bit.  No functional changes intended.
  
  Reviewed by:  kib (earlier version)
  MFC after:2 weeks
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26378

Modified:
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/amd64/linux/linux_sysvec.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/arm/arm/vm_machdep.c
  head/sys/arm64/arm64/vm_machdep.c
  head/sys/arm64/linux/linux_sysvec.c
  head/sys/i386/i386/vm_machdep.c
  head/sys/i386/linux/linux_sysvec.c
  head/sys/powerpc/powerpc/exec_machdep.c

Modified: head/sys/amd64/amd64/vm_machdep.c
==
--- head/sys/amd64/amd64/vm_machdep.c   Tue Sep 15 16:38:44 2020
(r365754)
+++ head/sys/amd64/amd64/vm_machdep.c   Tue Sep 15 16:41:21 2020
(r365755)
@@ -543,7 +543,7 @@ cpu_set_syscall_retval(struct thread *td, int error)
break;
 
default:
-   frame->tf_rax = SV_ABI_ERRNO(td->td_proc, error);
+   frame->tf_rax = error;
frame->tf_rflags |= PSL_C;
break;
}

Modified: head/sys/amd64/linux/linux_sysvec.c
==
--- head/sys/amd64/linux/linux_sysvec.c Tue Sep 15 16:38:44 2020
(r365754)
+++ head/sys/amd64/linux/linux_sysvec.c Tue Sep 15 16:41:21 2020
(r365755)
@@ -219,6 +219,11 @@ linux_set_syscall_retval(struct thread *td, int error)
 
cpu_set_syscall_retval(td, error);
 
+   if (__predict_false(error != 0)) {
+   if (error != ERESTART && error != EJUSTRETURN)
+   frame->tf_rax = SV_ABI_ERRNO(td->td_proc, error);
+   }
+
 /* Restore all registers. */
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
 }

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Tue Sep 15 16:38:44 2020
(r365754)
+++ head/sys/amd64/linux32/linux32_sysvec.c Tue Sep 15 16:41:21 2020
(r365755)
@@ -112,6 +112,7 @@ static void linux32_fixlimit(struct rlimit *rl, int wh
 static boollinux32_trans_osrel(const Elf_Note *note, int32_t *osrel);
 static voidlinux_vdso_install(void *param);
 static voidlinux_vdso_deinstall(void *param);
+static voidlinux32_set_syscall_retval(struct thread *td, int error);
 
 #define LINUX_T_UNKNOWN  255
 static int _bsd_to_linux_trapcode[] = {
@@ -669,6 +670,19 @@ linux32_fetch_syscall_args(struct thread *td)
return (0);
 }
 
+static void
+linux32_set_syscall_retval(struct thread *td, int error)
+{
+   struct trapframe *frame = td->td_frame;
+
+   cpu_set_syscall_retval(td, error);
+
+   if (__predict_false(error != 0)) {
+   if (error != ERESTART && error != EJUSTRETURN)
+   frame->tf_rax = SV_ABI_ERRNO(td->td_proc, error);
+   }
+}
+
 /*
  * Clear registers on exec
  * XXX copied from ia32_signal.c.
@@ -906,7 +920,7 @@ struct sysentvec elf_linux_sysvec = {
.sv_fixlimit= linux32_fixlimit,
.sv_maxssiz = _maxssiz,
.sv_flags   = SV_ABI_LINUX | SV_ILP32 | SV_IA32 | SV_SHP,
-   .sv_set_syscall_retval = cpu_set_syscall_retval,
+   .sv_set_syscall_retval = linux32_set_syscall_retval,
.sv_fetch_syscall_args = linux32_fetch_syscall_args,
.sv_syscallnames = NULL,
.sv_shared_page_base = LINUX32_SHAREDPAGE,

Modified: head/sys/arm/arm/vm_machdep.c
==
--- head/sys/arm/arm/vm_machdep.c   Tue Sep 15 16:38:44 2020
(r365754)
+++ head/sys/arm/arm/vm_machdep.c   Tue Sep 15 16:41:21 2020
(r365755)
@@ -219,7 +219,7 @@ cpu_set_syscall_retval(struct thread *td, int error)
/* nothing to do */
break;
default:
-   frame->tf_r0 = SV_ABI_ERRNO(td->td_proc, error);
+   frame->tf_r0 = error;
frame->tf_spsr |= PSR_C;/* carry bit */
break;
}

Modified: head/sys/arm64/arm64/vm_machdep.c
==
--- head/sys/arm64/arm64/vm_machdep.c   Tue Sep 15 16:38:44 2020
(r365754)
+++ head/sys/arm64/arm64/vm_machdep.c   Tue Sep 15 16:41:21 2020
(r365755)
@@ -153,7 +153,7 @@ cpu_set_syscall_retval(struct thread *td, int error)
break;
default:
frame->tf_spsr |= PSR_C;/* carry bit */
-   frame->tf_x[0] = SV_ABI_ERRNO(td->td_proc, error);
+   frame->tf_x[0] = error;
break;
}
 

svn commit: r365713 - in head: lib/libbe/tests sbin/bectl/tests

2020-09-14 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Sep 14 10:35:39 2020
New Revision: 365713
URL: https://svnweb.freebsd.org/changeset/base/365713

Log:
  Skip armv7 bectl tests on CI; they deadlock (""KSTACK_PAGES is 2").
  
  PR:   249229
  Sponsored by: DARPA

Modified:
  head/lib/libbe/tests/be_create.sh
  head/sbin/bectl/tests/bectl_test.sh

Modified: head/lib/libbe/tests/be_create.sh
==
--- head/lib/libbe/tests/be_create.sh   Mon Sep 14 10:17:07 2020
(r365712)
+++ head/lib/libbe/tests/be_create.sh   Mon Sep 14 10:35:39 2020
(r365713)
@@ -93,6 +93,11 @@ libbe_create_body()
atf_skip "https://bugs.freebsd.org/249055;
fi
 
+   if [ "$(atf_config_get ci false)" = "true" ] && \
+   [ "$(uname -p)" = "armv7" ]; then
+   atf_skip "https://bugs.freebsd.org/249229;
+   fi
+
cwd=$(atf_get_srcdir)
zpool=$(make_zpool_name)
disk=${cwd}/disk.img

Modified: head/sbin/bectl/tests/bectl_test.sh
==
--- head/sbin/bectl/tests/bectl_test.sh Mon Sep 14 10:17:07 2020
(r365712)
+++ head/sbin/bectl/tests/bectl_test.sh Mon Sep 14 10:35:39 2020
(r365713)
@@ -98,6 +98,11 @@ bectl_create_body()
atf_skip "https://bugs.freebsd.org/249055;
fi
 
+   if [ "$(atf_config_get ci false)" = "true" ] && \
+   [ "$(uname -p)" = "armv7" ]; then
+   atf_skip "https://bugs.freebsd.org/249229;
+   fi
+
cwd=$(realpath .)
zpool=$(make_zpool_name)
disk=${cwd}/disk.img
@@ -153,6 +158,11 @@ bectl_destroy_body()
atf_skip "https://bugs.freebsd.org/249055;
fi
 
+   if [ "$(atf_config_get ci false)" = "true" ] && \
+   [ "$(uname -p)" = "armv7" ]; then
+   atf_skip "https://bugs.freebsd.org/249229;
+   fi
+
cwd=$(realpath .)
zpool=$(make_zpool_name)
disk=${cwd}/disk.img
@@ -238,6 +248,11 @@ bectl_export_import_body()
atf_skip "https://bugs.freebsd.org/249055;
fi
 
+   if [ "$(atf_config_get ci false)" = "true" ] && \
+   [ "$(uname -p)" = "armv7" ]; then
+   atf_skip "https://bugs.freebsd.org/249229;
+   fi
+
cwd=$(realpath .)
zpool=$(make_zpool_name)
disk=${cwd}/disk.img
@@ -271,6 +286,11 @@ bectl_list_body()
atf_skip "https://bugs.freebsd.org/249055;
fi
 
+   if [ "$(atf_config_get ci false)" = "true" ] && \
+   [ "$(uname -p)" = "armv7" ]; then
+   atf_skip "https://bugs.freebsd.org/249229;
+   fi
+
cwd=$(realpath .)
zpool=$(make_zpool_name)
disk=${cwd}/disk.img
@@ -311,6 +331,11 @@ bectl_mount_body()
atf_skip "https://bugs.freebsd.org/249055;
fi
 
+   if [ "$(atf_config_get ci false)" = "true" ] && \
+   [ "$(uname -p)" = "armv7" ]; then
+   atf_skip "https://bugs.freebsd.org/249229;
+   fi
+
cwd=$(realpath .)
zpool=$(make_zpool_name)
disk=${cwd}/disk.img
@@ -350,6 +375,11 @@ bectl_rename_body()
atf_skip "https://bugs.freebsd.org/249055;
fi
 
+   if [ "$(atf_config_get ci false)" = "true" ] && \
+   [ "$(uname -p)" = "armv7" ]; then
+   atf_skip "https://bugs.freebsd.org/249229;
+   fi
+
cwd=$(realpath .)
zpool=$(make_zpool_name)
disk=${cwd}/disk.img
@@ -382,6 +412,11 @@ bectl_jail_body()
atf_skip "https://bugs.freebsd.org/249055;
fi
 
+   if [ "$(atf_config_get ci false)" = "true" ] && \
+   [ "$(uname -p)" = "armv7" ]; then
+   atf_skip "https://bugs.freebsd.org/249229;
+   fi
+
cwd=$(realpath .)
zpool=$(make_zpool_name)
disk=${cwd}/disk.img
@@ -455,6 +490,11 @@ bectl_jail_cleanup()
if [ "$(atf_config_get ci false)" = "true" ] && \
[ "$(uname -p)" = "i386" ]; then
atf_skip "https://bugs.freebsd.org/249055;
+   fi
+
+   if [ "$(atf_config_get ci false)" = "true" ] && \
+   [ "$(uname -p)" = "armv7" ]; then
+   atf_skip "https://bugs.freebsd.org/249229;
fi
 
zpool=$(get_zpool_name)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365712 - head/sys/kern

2020-09-14 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Sep 14 10:17:07 2020
New Revision: 365712
URL: https://svnweb.freebsd.org/changeset/base/365712

Log:
  Move td_softdep_cleanup() from userret() to ast(); it's infrequent
  at best.  The schedule_cleanup() function already sets TDF_ASTPENDING.
  
  Reviewed by:  kib, mckusick
  Tested by:pho
  MFC after:2 weeks
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26375

Modified:
  head/sys/kern/subr_trap.c

Modified: head/sys/kern/subr_trap.c
==
--- head/sys/kern/subr_trap.c   Mon Sep 14 10:14:03 2020(r365711)
+++ head/sys/kern/subr_trap.c   Mon Sep 14 10:17:07 2020(r365712)
@@ -134,9 +134,6 @@ userret(struct thread *td, struct trapframe *frame)
KTRUSERRET(td);
 #endif
 
-   td_softdep_cleanup(td);
-   MPASS(td->td_su == NULL);
-
/*
 * Charge system time if profiling.
 */
@@ -188,8 +185,6 @@ userret(struct thread *td, struct trapframe *frame)
("userret: Returning with preallocated vnode"));
KASSERT((td->td_flags & (TDF_SBDRY | TDF_SEINTR | TDF_SERESTART)) == 0,
("userret: Returning with stop signals deferred"));
-   KASSERT(td->td_su == NULL,
-   ("userret: Returning with SU cleanup request not handled"));
KASSERT(td->td_vslock_sz == 0,
("userret: Returning with vslock-wired space"));
 #ifdef VIMAGE
@@ -278,6 +273,9 @@ ast(struct trapframe *framep)
ktrcsw(0, 1, __func__);
 #endif
}
+
+   td_softdep_cleanup(td);
+   MPASS(td->td_su == NULL);
 
/*
 * If this thread tickled GEOM, we need to wait for the giggling to
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365711 - in head/sys: geom kern

2020-09-14 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Sep 14 10:14:03 2020
New Revision: 365711
URL: https://svnweb.freebsd.org/changeset/base/365711

Log:
  Move TDP_GEOM check from userret() to ast(); this code path is quite
  infrequent.
  
  Reviewed by:  kib
  No objections:mav
  Tested by:pho
  MFC after:2 weeks
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26374

Modified:
  head/sys/geom/geom_event.c
  head/sys/kern/subr_trap.c

Modified: head/sys/geom/geom_event.c
==
--- head/sys/geom/geom_event.c  Mon Sep 14 09:44:24 2020(r365710)
+++ head/sys/geom/geom_event.c  Mon Sep 14 10:14:03 2020(r365711)
@@ -374,6 +374,9 @@ g_post_event_x(g_event_t *func, void *arg, int flag, i
if (epp != NULL)
*epp = ep;
curthread->td_pflags |= TDP_GEOM;
+   thread_lock(curthread);
+   curthread->td_flags |= TDF_ASTPENDING;
+   thread_unlock(curthread);
return (0);
 }
 

Modified: head/sys/kern/subr_trap.c
==
--- head/sys/kern/subr_trap.c   Mon Sep 14 09:44:24 2020(r365710)
+++ head/sys/kern/subr_trap.c   Mon Sep 14 10:14:03 2020(r365711)
@@ -138,13 +138,6 @@ userret(struct thread *td, struct trapframe *frame)
MPASS(td->td_su == NULL);
 
/*
-* If this thread tickled GEOM, we need to wait for the giggling to
-* stop before we return to userland
-*/
-   if (__predict_false(td->td_pflags & TDP_GEOM))
-   g_waitidle();
-
-   /*
 * Charge system time if profiling.
 */
if (__predict_false(p->p_flag & P_PROFIL))
@@ -285,6 +278,13 @@ ast(struct trapframe *framep)
ktrcsw(0, 1, __func__);
 #endif
}
+
+   /*
+* If this thread tickled GEOM, we need to wait for the giggling to
+* stop before we return to userland
+*/
+   if (__predict_false(td->td_pflags & TDP_GEOM))
+   g_waitidle();
 
 #ifdef DIAGNOSTIC
if (p->p_numthreads == 1 && (flags & TDF_NEEDSIGCHK) == 0) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365710 - head/sys/kern

2020-09-14 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Sep 14 09:44:24 2020
New Revision: 365710
URL: https://svnweb.freebsd.org/changeset/base/365710

Log:
  Move racct/rctl throttling from userret() to ast().  There's no reason
  for it to sit in the syscall fast path.
  
  Reviewed by:  kib
  MFC after:2 weeks
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D26368

Modified:
  head/sys/kern/kern_racct.c
  head/sys/kern/subr_trap.c

Modified: head/sys/kern/kern_racct.c
==
--- head/sys/kern/kern_racct.c  Mon Sep 14 08:59:16 2020(r365709)
+++ head/sys/kern/kern_racct.c  Mon Sep 14 09:44:24 2020(r365710)
@@ -1146,6 +1146,8 @@ racct_proc_throttle(struct proc *p, int timeout)
 
FOREACH_THREAD_IN_PROC(p, td) {
thread_lock(td);
+   td->td_flags |= TDF_ASTPENDING;
+
switch (td->td_state) {
case TDS_RUNQ:
/*

Modified: head/sys/kern/subr_trap.c
==
--- head/sys/kern/subr_trap.c   Mon Sep 14 08:59:16 2020(r365709)
+++ head/sys/kern/subr_trap.c   Mon Sep 14 09:44:24 2020(r365710)
@@ -206,10 +206,6 @@ userret(struct thread *td, struct trapframe *frame)
__func__, td, p->p_pid, td->td_name, curvnet,
(td->td_vnet_lpush != NULL) ? td->td_vnet_lpush : "N/A"));
 #endif
-#ifdef RACCT
-   if (__predict_false(racct_enable && p->p_throttled != 0))
-   racct_proc_throttled(p);
-#endif
 }
 
 /*
@@ -361,6 +357,11 @@ ast(struct trapframe *framep)
td->td_pflags &= ~TDP_OLDMASK;
kern_sigprocmask(td, SIG_SETMASK, >td_oldsigmask, NULL, 0);
}
+
+#ifdef RACCT
+   if (__predict_false(racct_enable && p->p_throttled != 0))
+   racct_proc_throttled(p);
+#endif
 
userret(td, framep);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365042 - head/usr.sbin/ctld

2020-09-01 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Sep  1 14:58:57 2020
New Revision: 365042
URL: https://svnweb.freebsd.org/changeset/base/365042

Log:
  Make sure not to pass NULL to strtoul(3).  The values come
  from the kernel, but let's try to be on the safe side.
  
  Reviewed by:  mav
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D26246

Modified:
  head/usr.sbin/ctld/kernel.c

Modified: head/usr.sbin/ctld/kernel.c
==
--- head/usr.sbin/ctld/kernel.c Tue Sep  1 14:52:39 2020(r365041)
+++ head/usr.sbin/ctld/kernel.c Tue Sep  1 14:58:57 2020(r365042)
@@ -238,10 +238,16 @@ cctl_end_element(void *user_data, const char *name)
cur_lun->backend_type = str;
str = NULL;
} else if (strcmp(name, "lun_type") == 0) {
+   if (str == NULL)
+   log_errx(1, "%s: %s missing its argument", __func__, 
name);
cur_lun->device_type = strtoull(str, NULL, 0);
} else if (strcmp(name, "size") == 0) {
+   if (str == NULL)
+   log_errx(1, "%s: %s missing its argument", __func__, 
name);
cur_lun->size_blocks = strtoull(str, NULL, 0);
} else if (strcmp(name, "blocksize") == 0) {
+   if (str == NULL)
+   log_errx(1, "%s: %s missing its argument", __func__, 
name);
cur_lun->blocksize = strtoul(str, NULL, 0);
} else if (strcmp(name, "serial_number") == 0) {
cur_lun->serial_number = str;
@@ -357,15 +363,23 @@ cctl_end_pelement(void *user_data, const char *name)
cur_port->port_name = str;
str = NULL;
} else if (strcmp(name, "physical_port") == 0) {
+   if (str == NULL)
+   log_errx(1, "%s: %s missing its argument", __func__, 
name);
cur_port->pp = strtoul(str, NULL, 0);
} else if (strcmp(name, "virtual_port") == 0) {
+   if (str == NULL)
+   log_errx(1, "%s: %s missing its argument", __func__, 
name);
cur_port->vp = strtoul(str, NULL, 0);
} else if (strcmp(name, "cfiscsi_target") == 0) {
cur_port->cfiscsi_target = str;
str = NULL;
} else if (strcmp(name, "cfiscsi_state") == 0) {
+   if (str == NULL)
+   log_errx(1, "%s: %s missing its argument", __func__, 
name);
cur_port->cfiscsi_state = strtoul(str, NULL, 0);
} else if (strcmp(name, "cfiscsi_portal_group_tag") == 0) {
+   if (str == NULL)
+   log_errx(1, "%s: %s missing its argument", __func__, 
name);
cur_port->cfiscsi_portal_group_tag = strtoul(str, NULL, 0);
} else if (strcmp(name, "ctld_portal_group_name") == 0) {
cur_port->ctld_portal_group_name = str;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365040 - head/usr.sbin/iscsid

2020-09-01 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Sep  1 14:52:35 2020
New Revision: 365040
URL: https://svnweb.freebsd.org/changeset/base/365040

Log:
  Fix string overflow that could occur during redirection due to passing
  the wrong length to strlcpy(3). It looks like it could overflow into
  the next field, isc_user, which is properly long to accomodate for it;
  I don't think it could cause any harm other than breaking the connection.
  
  Reviewed by:  mav
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Sponsored by: Klara, Inc.
  Differential Revision:https://reviews.freebsd.org/D26247

Modified:
  head/usr.sbin/iscsid/login.c

Modified: head/usr.sbin/iscsid/login.c
==
--- head/usr.sbin/iscsid/login.cTue Sep  1 14:50:43 2020
(r365039)
+++ head/usr.sbin/iscsid/login.cTue Sep  1 14:52:35 2020
(r365040)
@@ -170,7 +170,7 @@ kernel_modify(const struct connection *conn, const cha
ism.ism_session_id = conn->conn_session_id;
memcpy(_conf, >conn_conf, sizeof(ism.ism_conf));
strlcpy(ism.ism_conf.isc_target_addr, target_address,
-   sizeof(ism.ism_conf.isc_target));
+   sizeof(ism.ism_conf.isc_target_addr));
error = ioctl(conn->conn_iscsi_fd, ISCSISMODIFY, );
if (error != 0) {
log_err(1, "failed to redirect to %s: ISCSISMODIFY",
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r365035 - in stable/12/sys: amd64/linux amd64/linux32 arm64/linux i386/linux

2020-09-01 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Sep  1 12:11:59 2020
New Revision: 365035
URL: https://svnweb.freebsd.org/changeset/base/365035

Log:
  MFC r363305:
  
  Regen after r363304.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/amd64/linux/linux_proto.h
  stable/12/sys/amd64/linux/linux_sysent.c
  stable/12/sys/amd64/linux/linux_systrace_args.c
  stable/12/sys/amd64/linux32/linux32_proto.h
  stable/12/sys/amd64/linux32/linux32_sysent.c
  stable/12/sys/amd64/linux32/linux32_systrace_args.c
  stable/12/sys/arm64/linux/linux_proto.h
  stable/12/sys/arm64/linux/linux_sysent.c
  stable/12/sys/arm64/linux/linux_systrace_args.c
  stable/12/sys/i386/linux/linux_proto.h
  stable/12/sys/i386/linux/linux_sysent.c
  stable/12/sys/i386/linux/linux_systrace_args.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/linux/linux_proto.h
==
--- stable/12/sys/amd64/linux/linux_proto.h Tue Sep  1 12:09:13 2020
(r365034)
+++ stable/12/sys/amd64/linux/linux_proto.h Tue Sep  1 12:11:59 2020
(r365035)
@@ -966,7 +966,12 @@ struct linux_get_robust_list_args {
char len_l_[PADL_(l_size_t *)]; l_size_t * len; char 
len_r_[PADR_(l_size_t *)];
 };
 struct linux_splice_args {
-   register_t dummy;
+   char fd_in_l_[PADL_(int)]; int fd_in; char fd_in_r_[PADR_(int)];
+   char off_in_l_[PADL_(l_loff_t *)]; l_loff_t * off_in; char 
off_in_r_[PADR_(l_loff_t *)];
+   char fd_out_l_[PADL_(int)]; int fd_out; char fd_out_r_[PADR_(int)];
+   char off_out_l_[PADL_(l_loff_t *)]; l_loff_t * off_out; char 
off_out_r_[PADR_(l_loff_t *)];
+   char len_l_[PADL_(l_size_t)]; l_size_t len; char 
len_r_[PADR_(l_size_t)];
+   char flags_l_[PADL_(l_uint)]; l_uint flags; char 
flags_r_[PADR_(l_uint)];
 };
 struct linux_tee_args {
register_t dummy;

Modified: stable/12/sys/amd64/linux/linux_sysent.c
==
--- stable/12/sys/amd64/linux/linux_sysent.cTue Sep  1 12:09:13 2020
(r365034)
+++ stable/12/sys/amd64/linux/linux_sysent.cTue Sep  1 12:11:59 2020
(r365035)
@@ -292,7 +292,7 @@ struct sysent linux_sysent[] = {
{ 0, (sy_call_t *)linux_unshare, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC 
},  /* 272 = linux_unshare */
{ AS(linux_set_robust_list_args), (sy_call_t *)linux_set_robust_list, 
AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 273 = linux_set_robust_list */
{ AS(linux_get_robust_list_args), (sy_call_t *)linux_get_robust_list, 
AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 274 = linux_get_robust_list */
-   { 0, (sy_call_t *)linux_splice, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC 
},   /* 275 = linux_splice */
+   { AS(linux_splice_args), (sy_call_t *)linux_splice, AUE_NULL, NULL, 0, 
0, 0, SY_THR_STATIC },   /* 275 = linux_splice */
{ 0, (sy_call_t *)linux_tee, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC },  
/* 276 = linux_tee */
{ AS(linux_sync_file_range_args), (sy_call_t *)linux_sync_file_range, 
AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 277 = linux_sync_file_range */
{ 0, (sy_call_t *)linux_vmsplice, AUE_NULL, NULL, 0, 0, 0, 
SY_THR_STATIC }, /* 278 = linux_vmsplice */

Modified: stable/12/sys/amd64/linux/linux_systrace_args.c
==
--- stable/12/sys/amd64/linux/linux_systrace_args.c Tue Sep  1 12:09:13 
2020(r365034)
+++ stable/12/sys/amd64/linux/linux_systrace_args.c Tue Sep  1 12:11:59 
2020(r365035)
@@ -2012,7 +2012,14 @@ systrace_args(int sysnum, void *params, uint64_t *uarg
}
/* linux_splice */
case 275: {
-   *n_args = 0;
+   struct linux_splice_args *p = params;
+   iarg[0] = p->fd_in; /* int */
+   uarg[1] = (intptr_t) p->off_in; /* l_loff_t * */
+   iarg[2] = p->fd_out; /* int */
+   uarg[3] = (intptr_t) p->off_out; /* l_loff_t * */
+   iarg[4] = p->len; /* l_size_t */
+   iarg[5] = p->flags; /* l_uint */
+   *n_args = 6;
break;
}
/* linux_tee */
@@ -5624,6 +5631,28 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d
break;
/* linux_splice */
case 275:
+   switch(ndx) {
+   case 0:
+   p = "int";
+   break;
+   case 1:
+   p = "userland l_loff_t *";
+   break;
+   case 2:
+   p = "int";
+   break;
+   case 3:
+   p = "userland l_loff_t *";
+   break;
+   case 4:
+   p = "l_size_t";
+   break;
+   case 5:
+   p 

svn commit: r365034 - in stable/12/sys: amd64/linux amd64/linux32 arm64/linux compat/linux i386/linux

2020-09-01 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Sep  1 12:09:13 2020
New Revision: 365034
URL: https://svnweb.freebsd.org/changeset/base/365034

Log:
  MFC r363304:
  
  Add a trivial linux(4) splice(2) implementation, which simply
  returns EINVAL.  Fixes grep (grep-3.1-2build1).
  
  PR:   218699
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/amd64/linux/linux_dummy.c
  stable/12/sys/amd64/linux/syscalls.master
  stable/12/sys/amd64/linux32/linux32_dummy.c
  stable/12/sys/amd64/linux32/syscalls.master
  stable/12/sys/arm64/linux/linux_dummy.c
  stable/12/sys/arm64/linux/syscalls.master
  stable/12/sys/compat/linux/linux_file.c
  stable/12/sys/i386/linux/linux_dummy.c
  stable/12/sys/i386/linux/syscalls.master
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/linux/linux_dummy.c
==
--- stable/12/sys/amd64/linux/linux_dummy.c Tue Sep  1 11:34:05 2020
(r365033)
+++ stable/12/sys/amd64/linux/linux_dummy.c Tue Sep  1 12:09:13 2020
(r365034)
@@ -106,7 +106,6 @@ DUMMY(inotify_rm_watch);
 DUMMY(migrate_pages);
 DUMMY(unshare);
 /* Linux 2.6.17: */
-DUMMY(splice);
 DUMMY(tee);
 DUMMY(vmsplice);
 /* Linux 2.6.18: */

Modified: stable/12/sys/amd64/linux/syscalls.master
==
--- stable/12/sys/amd64/linux/syscalls.master   Tue Sep  1 11:34:05 2020
(r365033)
+++ stable/12/sys/amd64/linux/syscalls.master   Tue Sep  1 12:09:13 2020
(r365034)
@@ -465,7 +465,8 @@
l_size_t len); }
 274AUE_NULLSTD { int linux_get_robust_list(l_int pid, \
struct linux_robust_list_head **head, 
l_size_t *len); }
-275AUE_NULLSTD { int linux_splice(void); }
+275AUE_NULLSTD { int linux_splice(int fd_in, l_loff_t *off_in, 
\
+   int fd_out, l_loff_t *off_out, l_size_t 
len, l_uint flags); }
 276AUE_NULLSTD { int linux_tee(void); }
 277AUE_NULLSTD { int linux_sync_file_range(l_int fd, l_loff_t 
offset,
l_loff_t nbytes, unsigned int flags); }

Modified: stable/12/sys/amd64/linux32/linux32_dummy.c
==
--- stable/12/sys/amd64/linux32/linux32_dummy.c Tue Sep  1 11:34:05 2020
(r365033)
+++ stable/12/sys/amd64/linux32/linux32_dummy.c Tue Sep  1 12:09:13 2020
(r365034)
@@ -103,7 +103,6 @@ DUMMY(inotify_rm_watch);
 DUMMY(migrate_pages);
 DUMMY(unshare);
 /* Linux 2.6.17: */
-DUMMY(splice);
 DUMMY(tee);
 DUMMY(vmsplice);
 /* Linux 2.6.18: */

Modified: stable/12/sys/amd64/linux32/syscalls.master
==
--- stable/12/sys/amd64/linux32/syscalls.master Tue Sep  1 11:34:05 2020
(r365033)
+++ stable/12/sys/amd64/linux32/syscalls.master Tue Sep  1 12:09:13 2020
(r365034)
@@ -524,7 +524,8 @@
l_size_t len); }
 312AUE_NULLSTD { int linux_get_robust_list(l_int pid, \
struct linux_robust_list_head **head, 
l_size_t *len); }
-313AUE_NULLSTD { int linux_splice(void); }
+313AUE_NULLSTD { int linux_splice(int fd_in, l_loff_t *off_in, 
\
+   int fd_out, l_loff_t *off_out, l_size_t 
len, l_uint flags); }
 314AUE_NULLSTD { int linux_sync_file_range(l_int fd, uint32_t 
offset1,
uint32_t offset2, uint32_t nbytes1, 
uint32_t nbytes2,
unsigned int flags); }

Modified: stable/12/sys/arm64/linux/linux_dummy.c
==
--- stable/12/sys/arm64/linux/linux_dummy.c Tue Sep  1 11:34:05 2020
(r365033)
+++ stable/12/sys/arm64/linux/linux_dummy.c Tue Sep  1 12:09:13 2020
(r365034)
@@ -99,7 +99,6 @@ DUMMY(inotify_rm_watch);
 DUMMY(migrate_pages);
 DUMMY(unshare);
 /* Linux 2.6.17: */
-DUMMY(splice);
 DUMMY(tee);
 DUMMY(vmsplice);
 /* Linux 2.6.18: */

Modified: stable/12/sys/arm64/linux/syscalls.master
==
--- stable/12/sys/arm64/linux/syscalls.master   Tue Sep  1 11:34:05 2020
(r365033)
+++ stable/12/sys/arm64/linux/syscalls.master   Tue Sep  1 12:09:13 2020
(r365034)
@@ -413,7 +413,14 @@
int linux_vmsplice(void);
}
 76 AUE_NULLSTD {
-   int linux_splice(void);
+   int linux_splice(
+   int fd_in,
+   l_loff_t *off_in,
+   int fd_out,
+   l_loff_t *off_out,
+   l_size_t len,
+   l_uint flags
+   

svn commit: r364985 - stable/12/libexec/rc/rc.d

2020-08-31 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 31 12:14:20 2020
New Revision: 364985
URL: https://svnweb.freebsd.org/changeset/base/364985

Log:
  In 13-CURRENT, the linux rc script uses "nocover" mount option to avoid
  mounting required filesystems twice.  However, this option hasn't been MFC'd.
  Implement its functionality in a different way, by stating the mount point.
  
  Submitted by: sig...@gmail.com
  Differential Revision:https://reviews.freebsd.org/D26217

Modified:
  stable/12/libexec/rc/rc.d/linux

Modified: stable/12/libexec/rc/rc.d/linux
==
--- stable/12/libexec/rc/rc.d/linux Mon Aug 31 09:05:45 2020
(r364984)
+++ stable/12/libexec/rc/rc.d/linux Mon Aug 31 12:14:20 2020
(r364985)
@@ -15,6 +15,12 @@ rcvar="linux_enable"
 start_cmd="${name}_start"
 stop_cmd=":"
 
+unmounted()
+{
+   [ `stat -f "%d" "$1"` == `stat -f "%d" "$1/.."` -a \
+ `stat -f "%i" "$1"` != `stat -f "%i" "$1/.."` ]
+}
+
 linux_start()
 {
local _emul_path _tmpdir
@@ -48,11 +54,12 @@ linux_start()
 
if checkyesno linux_mounts_enable; then 
_emul_path="/compat/linux"
-   mount -t linprocfs linprocfs "${_emul_path}/proc"
-   mount -t linsysfs linsysfs "${_emul_path}/sys"
-   mount -t devfs devfs "${_emul_path}/dev"
-   mount -o linrdlnk -t fdescfs fdescfs "${_emul_path}/dev/fd"
-   mount -o mode=1777 -t tmpfs tmpfs "${_emul_path}/dev/shm"
+   unmounted "${_emul_path}/proc" && mount -t linprocfs linprocfs 
"${_emul_path}/proc"
+   unmounted "${_emul_path}/sys" && mount -t linsysfs linsysfs 
"${_emul_path}/sys"
+   unmounted "${_emul_path}/dev" && mount -t devfs devfs 
"${_emul_path}/dev"
+   unmounted "${_emul_path}/dev/fd" && mount -o linrdlnk -t 
fdescfs fdescfs "${_emul_path}/dev/fd"
+   unmounted "${_emul_path}/dev/shm" && mount -o mode=1777 -t 
tmpfs tmpfs "${_emul_path}/dev/shm"
+   true
fi
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364955 - stable/12/libexec/rc/rc.d

2020-08-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Sat Aug 29 12:54:17 2020
New Revision: 364955
URL: https://svnweb.freebsd.org/changeset/base/364955

Log:
  Drop the "nocover" option from the linux rc script; the option
  is not yet supported in 12-STABLE.
  
  This is a direct commit intended as a temporary workaround.
  
  Reported by:  scf@
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/libexec/rc/rc.d/linux

Modified: stable/12/libexec/rc/rc.d/linux
==
--- stable/12/libexec/rc/rc.d/linux Sat Aug 29 12:04:13 2020
(r364954)
+++ stable/12/libexec/rc/rc.d/linux Sat Aug 29 12:54:17 2020
(r364955)
@@ -48,11 +48,11 @@ linux_start()
 
if checkyesno linux_mounts_enable; then 
_emul_path="/compat/linux"
-   mount -o nocover -t linprocfs linprocfs "${_emul_path}/proc"
-   mount -o nocover -t linsysfs linsysfs "${_emul_path}/sys"
-   mount -o nocover -t devfs devfs "${_emul_path}/dev"
-   mount -o nocover,linrdlnk -t fdescfs fdescfs 
"${_emul_path}/dev/fd"
-   mount -o nocover,mode=1777 -t tmpfs tmpfs 
"${_emul_path}/dev/shm"
+   mount -t linprocfs linprocfs "${_emul_path}/proc"
+   mount -t linsysfs linsysfs "${_emul_path}/sys"
+   mount -t devfs devfs "${_emul_path}/dev"
+   mount -o linrdlnk -t fdescfs fdescfs "${_emul_path}/dev/fd"
+   mount -o mode=1777 -t tmpfs tmpfs "${_emul_path}/dev/shm"
fi
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364885 - stable/12/share/man/man4

2020-08-27 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Aug 27 19:44:08 2020
New Revision: 364885
URL: https://svnweb.freebsd.org/changeset/base/364885

Log:
  MFC r362943:
  
  Make linux(4) man page also mention /compat/linux/dev.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/share/man/man4/linux.4
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/linux.4
==
--- stable/12/share/man/man4/linux.4Thu Aug 27 19:42:52 2020
(r364884)
+++ stable/12/share/man/man4/linux.4Thu Aug 27 19:44:08 2020
(r364885)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 4, 2020
+.Dd July 5, 2020
 .Dt LINUX 4
 .Os
 .Sh NAME
@@ -129,6 +129,9 @@ Defaults to 0.
 .Bl -tag -width /compat/linux/dev/shm -compact
 .It Pa /compat/linux
 minimal Linux run-time environment
+.It Pa /compat/linux/dev
+device file system, see
+.Xr devfs 5
 .It Pa /compat/linux/dev/fd
 file descriptor file system mounted with the
 .Cm linrdlnk
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364884 - in stable/12: libexec/rc/rc.d share/man/man4

2020-08-27 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Aug 27 19:42:52 2020
New Revision: 364884
URL: https://svnweb.freebsd.org/changeset/base/364884

Log:
  MFC r362935:
  
  Make the linux rc script use linrdlnk by default.
  
  This fixes Linux gettyname(3), with caveats (see PR).
  
  PR:   kern/240767
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/libexec/rc/rc.d/linux
  stable/12/share/man/man4/linux.4
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/rc/rc.d/linux
==
--- stable/12/libexec/rc/rc.d/linux Thu Aug 27 19:41:31 2020
(r364883)
+++ stable/12/libexec/rc/rc.d/linux Thu Aug 27 19:42:52 2020
(r364884)
@@ -51,7 +51,7 @@ linux_start()
mount -o nocover -t linprocfs linprocfs "${_emul_path}/proc"
mount -o nocover -t linsysfs linsysfs "${_emul_path}/sys"
mount -o nocover -t devfs devfs "${_emul_path}/dev"
-   mount -o nocover -t fdescfs fdescfs "${_emul_path}/dev/fd"
+   mount -o nocover,linrdlnk -t fdescfs fdescfs 
"${_emul_path}/dev/fd"
mount -o nocover,mode=1777 -t tmpfs tmpfs 
"${_emul_path}/dev/shm"
fi
 }

Modified: stable/12/share/man/man4/linux.4
==
--- stable/12/share/man/man4/linux.4Thu Aug 27 19:41:31 2020
(r364883)
+++ stable/12/share/man/man4/linux.4Thu Aug 27 19:42:52 2020
(r364884)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 12, 2020
+.Dd July 4, 2020
 .Dt LINUX 4
 .Os
 .Sh NAME
@@ -130,7 +130,9 @@ Defaults to 0.
 .It Pa /compat/linux
 minimal Linux run-time environment
 .It Pa /compat/linux/dev/fd
-file-descriptor file system, see
+file descriptor file system mounted with the
+.Cm linrdlnk
+option, see
 .Xr fdescfs 5
 .It Pa /compat/linux/dev/shm
 in-memory file system, see
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364883 - in stable/12/libexec/rc: . rc.d

2020-08-27 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Aug 27 19:41:31 2020
New Revision: 364883
URL: https://svnweb.freebsd.org/changeset/base/364883

Log:
  MFC r354690:
  
  Add 'linux_mounts_enable' rc.conf(5) variable, to make it possible
  to disable mounting Linux-specific filesystems under /compat/linux
  when 'linux_enable' is set to YES.
  
  Relnotes: yes
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/libexec/rc/rc.conf
  stable/12/libexec/rc/rc.d/linux
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/rc/rc.conf
==
--- stable/12/libexec/rc/rc.confThu Aug 27 19:40:33 2020
(r364882)
+++ stable/12/libexec/rc/rc.confThu Aug 27 19:41:31 2020
(r364883)
@@ -642,6 +642,8 @@ firstboot_sentinel="/firstboot" # Scripts with "firstb
# the file can be deleted after the boot completes.
 sysvipc_enable="NO"# Load System V IPC primitives at startup (or NO).
 linux_enable="NO"  # Linux binary compatibility loaded at startup (or NO).
+linux_mounts_enable="YES" # If linux_enable is set to YES, mount Linux-specific
+   # filesystems at startup.
 clear_tmp_enable="NO"  # Clear /tmp at startup.
 clear_tmp_X="YES"  # Clear and recreate X11-related directories in /tmp
 ldconfig_insecure="NO" # Set to YES to disable ldconfig security checks

Modified: stable/12/libexec/rc/rc.d/linux
==
--- stable/12/libexec/rc/rc.d/linux Thu Aug 27 19:40:33 2020
(r364882)
+++ stable/12/libexec/rc/rc.d/linux Thu Aug 27 19:41:31 2020
(r364883)
@@ -46,12 +46,14 @@ linux_start()
sysctl kern.elf32.fallback_brand=3 > /dev/null
fi
 
-   _emul_path="/compat/linux"
-   mount -o nocover -t linprocfs linprocfs "${_emul_path}/proc"
-   mount -o nocover -t linsysfs linsysfs "${_emul_path}/sys"
-   mount -o nocover -t devfs devfs "${_emul_path}/dev"
-   mount -o nocover -t fdescfs fdescfs "${_emul_path}/dev/fd"
-   mount -o nocover,mode=1777 -t tmpfs tmpfs "${_emul_path}/dev/shm"
+   if checkyesno linux_mounts_enable; then 
+   _emul_path="/compat/linux"
+   mount -o nocover -t linprocfs linprocfs "${_emul_path}/proc"
+   mount -o nocover -t linsysfs linsysfs "${_emul_path}/sys"
+   mount -o nocover -t devfs devfs "${_emul_path}/dev"
+   mount -o nocover -t fdescfs fdescfs "${_emul_path}/dev/fd"
+   mount -o nocover,mode=1777 -t tmpfs tmpfs 
"${_emul_path}/dev/shm"
+   fi
 }
 
 load_rc_config $name
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364882 - stable/12/libexec/rc/rc.d

2020-08-27 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Aug 27 19:40:33 2020
New Revision: 364882
URL: https://svnweb.freebsd.org/changeset/base/364882

Log:
  MFC r354458:
  
  Extend the linux rc script to mount the neccessary file systems,
  set ELF fallback brand, and load pty(4).
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/libexec/rc/rc.d/linux
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/rc/rc.d/linux
==
--- stable/12/libexec/rc/rc.d/linux Thu Aug 27 19:37:28 2020
(r364881)
+++ stable/12/libexec/rc/rc.d/linux Thu Aug 27 19:40:33 2020
(r364882)
@@ -17,7 +17,7 @@ stop_cmd=":"
 
 linux_start()
 {
-   local _tmpdir
+   local _emul_path _tmpdir
 
load_kld -e 'linux(aout|elf)' linux
case `sysctl -n hw.machine_arch` in
@@ -33,6 +33,25 @@ linux_start()
fi
rm -rf ${_tmpdir}
fi
+
+   # Linux uses the pre-pts(4) tty naming scheme.
+   load_kld pty
+
+   # Handle unbranded ELF executables by defaulting to ELFOSABI_LINUX.
+   if [ `sysctl -ni kern.elf64.fallback_brand` -eq "-1" ]; then
+   sysctl kern.elf64.fallback_brand=3 > /dev/null
+   fi
+
+   if [ `sysctl -ni kern.elf32.fallback_brand` -eq "-1" ]; then
+   sysctl kern.elf32.fallback_brand=3 > /dev/null
+   fi
+
+   _emul_path="/compat/linux"
+   mount -o nocover -t linprocfs linprocfs "${_emul_path}/proc"
+   mount -o nocover -t linsysfs linsysfs "${_emul_path}/sys"
+   mount -o nocover -t devfs devfs "${_emul_path}/dev"
+   mount -o nocover -t fdescfs fdescfs "${_emul_path}/dev/fd"
+   mount -o nocover,mode=1777 -t tmpfs tmpfs "${_emul_path}/dev/shm"
 }
 
 load_rc_config $name
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364881 - stable/12/libexec/rc/rc.d

2020-08-27 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Aug 27 19:37:28 2020
New Revision: 364881
URL: https://svnweb.freebsd.org/changeset/base/364881

Log:
  MFC r352999:
  
  Rename etc/rc.d/abi to etc/rc.d/linux; after moving out the SysV IPC stuff
  it's entirely linux-specific.
  
  MFC r353054:
  
  Add rcvar back to the linux rc script.  Without it it was enabled
  unconditionally.
  
  Sponsored by: The FreeBSD Foundation

Added:
  stable/12/libexec/rc/rc.d/linux
 - copied, changed from r352999, head/libexec/rc/rc.d/linux
Deleted:
  stable/12/libexec/rc/rc.d/abi
Modified:
  stable/12/libexec/rc/rc.d/Makefile
  stable/12/libexec/rc/rc.d/SERVERS
  stable/12/libexec/rc/rc.d/localpkg
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/rc/rc.d/Makefile
==
--- stable/12/libexec/rc/rc.d/Makefile  Thu Aug 27 19:35:02 2020
(r364880)
+++ stable/12/libexec/rc/rc.d/Makefile  Thu Aug 27 19:37:28 2020
(r364881)
@@ -11,7 +11,6 @@ CONFS=DAEMON \
LOGIN \
NETWORKING \
SERVERS \
-   abi \
addswap \
adjkerntz \
archdep \
@@ -54,6 +53,7 @@ CONFS=DAEMON \
kldxref \
${_kpasswdd} \
ldconfig \
+   linux \
local \
localpkg \
lockd \

Modified: stable/12/libexec/rc/rc.d/SERVERS
==
--- stable/12/libexec/rc/rc.d/SERVERS   Thu Aug 27 19:35:02 2020
(r364880)
+++ stable/12/libexec/rc/rc.d/SERVERS   Thu Aug 27 19:37:28 2020
(r364881)
@@ -4,7 +4,7 @@
 #
 
 # PROVIDE: SERVERS
-# REQUIRE: mountcritremote sysvipc abi ldconfig savecore watchdogd
+# REQUIRE: mountcritremote sysvipc linux ldconfig savecore watchdogd
 
 #  This is a dummy dependency, for early-start servers relying on
 #  some basic configuration.

Copied and modified: stable/12/libexec/rc/rc.d/linux (from r352999, 
head/libexec/rc/rc.d/linux)
==
--- head/libexec/rc/rc.d/linux  Wed Oct  2 11:40:40 2019(r352999, copy 
source)
+++ stable/12/libexec/rc/rc.d/linux Thu Aug 27 19:37:28 2020
(r364881)
@@ -11,6 +11,7 @@
 
 name="linux"
 desc="Enable Linux ABI"
+rcvar="linux_enable"
 start_cmd="${name}_start"
 stop_cmd=":"
 

Modified: stable/12/libexec/rc/rc.d/localpkg
==
--- stable/12/libexec/rc/rc.d/localpkg  Thu Aug 27 19:35:02 2020
(r364880)
+++ stable/12/libexec/rc/rc.d/localpkg  Thu Aug 27 19:37:28 2020
(r364881)
@@ -4,7 +4,7 @@
 #
 
 # PROVIDE: localpkg
-# REQUIRE: sysvipc abi
+# REQUIRE: sysvipc linux
 # BEFORE:  securelevel
 # KEYWORD: shutdown
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364880 - in stable/12/libexec/rc: . rc.d

2020-08-27 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Aug 27 19:35:02 2020
New Revision: 364880
URL: https://svnweb.freebsd.org/changeset/base/364880

Log:
  MFC r352836:
  
  Move the SysV IPC stuff out of the 'abi' rc script, into a new one:
  'sysvipc' - it has nothing to do with ABIs, and I'd like to later
  rename 'abi' to 'linux', which better describes its purpose and also
  matches the rcvar name.
  
  Sponsored by: The FreeBSD Foundation

Added:
  stable/12/libexec/rc/rc.d/sysvipc
 - copied unchanged from r352836, head/libexec/rc/rc.d/sysvipc
Modified:
  stable/12/libexec/rc/rc.conf
  stable/12/libexec/rc/rc.d/Makefile
  stable/12/libexec/rc/rc.d/SERVERS
  stable/12/libexec/rc/rc.d/abi
  stable/12/libexec/rc/rc.d/localpkg
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/rc/rc.conf
==
--- stable/12/libexec/rc/rc.confThu Aug 27 19:15:09 2020
(r364879)
+++ stable/12/libexec/rc/rc.confThu Aug 27 19:35:02 2020
(r364880)
@@ -640,8 +640,6 @@ ibcs2_loaders="coff"# List of additional Ibcs2 
loader
 firstboot_sentinel="/firstboot"# Scripts with "firstboot" keyword are 
run if
# this file exists.  Should be on a R/W filesystem so
# the file can be deleted after the boot completes.
-
-# Emulation/compatibility services provided by /etc/rc.d/abi
 sysvipc_enable="NO"# Load System V IPC primitives at startup (or NO).
 linux_enable="NO"  # Linux binary compatibility loaded at startup (or NO).
 clear_tmp_enable="NO"  # Clear /tmp at startup.

Modified: stable/12/libexec/rc/rc.d/Makefile
==
--- stable/12/libexec/rc/rc.d/Makefile  Thu Aug 27 19:15:09 2020
(r364879)
+++ stable/12/libexec/rc/rc.d/Makefile  Thu Aug 27 19:35:02 2020
(r364880)
@@ -111,6 +111,7 @@ CONFS=  DAEMON \
swaplate \
sysctl \
syslogd \
+   sysvipc \
tmp \
${_ubthidhci} \
ugidfw \

Modified: stable/12/libexec/rc/rc.d/SERVERS
==
--- stable/12/libexec/rc/rc.d/SERVERS   Thu Aug 27 19:15:09 2020
(r364879)
+++ stable/12/libexec/rc/rc.d/SERVERS   Thu Aug 27 19:35:02 2020
(r364880)
@@ -4,7 +4,7 @@
 #
 
 # PROVIDE: SERVERS
-# REQUIRE: mountcritremote abi ldconfig savecore watchdogd
+# REQUIRE: mountcritremote sysvipc abi ldconfig savecore watchdogd
 
 #  This is a dummy dependency, for early-start servers relying on
 #  some basic configuration.

Modified: stable/12/libexec/rc/rc.d/abi
==
--- stable/12/libexec/rc/rc.d/abi   Thu Aug 27 19:15:09 2020
(r364879)
+++ stable/12/libexec/rc/rc.d/abi   Thu Aug 27 19:35:02 2020
(r364880)
@@ -14,14 +14,6 @@ desc="Enable foreign ABIs"
 start_cmd="${name}_start"
 stop_cmd=":"
 
-sysv_start()
-{
-   echo -n ' sysvipc'
-   load_kld sysvmsg
-   load_kld sysvsem
-   load_kld sysvshm
-}
-
 linux_start()
 {
local _tmpdir
@@ -48,12 +40,11 @@ abi_start()
local _echostop
 
_echostop=
-   if checkyesno sysvipc_enable || checkyesno linux_enable; then
+   if checkyesno linux_enable; then
echo -n 'Additional ABI support:'
_echostop=yes
fi
 
-   checkyesno sysvipc_enable && sysv_start
checkyesno linux_enable && linux_start
 
[ -n "${_echostop}" ] && echo '.'

Modified: stable/12/libexec/rc/rc.d/localpkg
==
--- stable/12/libexec/rc/rc.d/localpkg  Thu Aug 27 19:15:09 2020
(r364879)
+++ stable/12/libexec/rc/rc.d/localpkg  Thu Aug 27 19:35:02 2020
(r364880)
@@ -4,7 +4,7 @@
 #
 
 # PROVIDE: localpkg
-# REQUIRE: abi
+# REQUIRE: sysvipc abi
 # BEFORE:  securelevel
 # KEYWORD: shutdown
 

Copied: stable/12/libexec/rc/rc.d/sysvipc (from r352836, 
head/libexec/rc/rc.d/sysvipc)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/12/libexec/rc/rc.d/sysvipc   Thu Aug 27 19:35:02 2020
(r364880, copy of r352836, head/libexec/rc/rc.d/sysvipc)
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: sysvipc
+# REQUIRE: archdep
+# KEYWORD: nojail
+
+. /etc/rc.subr
+
+name="sysvipc"
+desc="Load SysV IPC modules"
+rcvar="sysvipc_enable"
+start_cmd="${name}_start"
+stop_cmd=":"
+
+sysvipc_start()
+{
+   load_kld sysvmsg
+   load_kld sysvsem
+   load_kld sysvshm
+}
+
+load_rc_config $name
+run_rc_command "$1"
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to 

svn commit: r364717 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 17:31:17 2020
New Revision: 364717
URL: https://svnweb.freebsd.org/changeset/base/364717

Log:
  MFC r363087:
  
  Don't emit warnings on MADV_HUGEPAGE; Firefox uses it a lot.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/compat/linux/linux_mmap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_mmap.c
==
--- stable/12/sys/compat/linux/linux_mmap.c Mon Aug 24 17:29:37 2020
(r364716)
+++ stable/12/sys/compat/linux/linux_mmap.c Mon Aug 24 17:31:17 2020
(r364717)
@@ -267,7 +267,13 @@ linux_madvise_common(struct thread *td, uintptr_t addr
/* Ignored; on FreeBSD huge pages are always on. */
return (0);
case LINUX_MADV_NOHUGEPAGE:
+#if 0
+   /*
+* Don't warn - Firefox uses it a lot, and in real Linux it's
+* an optional feature.
+*/
linux_msg(curthread, "unsupported madvise MADV_NOHUGEPAGE");
+#endif
return (EINVAL);
case LINUX_MADV_DONTDUMP:
return (kern_madvise(td, addr, len, MADV_NOCORE));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364716 - in stable/12/sys: amd64/linux amd64/linux32 arm64/linux i386/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 17:29:37 2020
New Revision: 364716
URL: https://svnweb.freebsd.org/changeset/base/364716

Log:
  MFC r362441:
  
  Regen after r362440.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/amd64/linux/linux_proto.h
  stable/12/sys/amd64/linux/linux_syscall.h
  stable/12/sys/amd64/linux/linux_syscalls.c
  stable/12/sys/amd64/linux/linux_sysent.c
  stable/12/sys/amd64/linux/linux_systrace_args.c
  stable/12/sys/amd64/linux32/linux32_proto.h
  stable/12/sys/amd64/linux32/linux32_syscall.h
  stable/12/sys/amd64/linux32/linux32_syscalls.c
  stable/12/sys/amd64/linux32/linux32_sysent.c
  stable/12/sys/amd64/linux32/linux32_systrace_args.c
  stable/12/sys/arm64/linux/linux_proto.h
  stable/12/sys/arm64/linux/linux_syscall.h
  stable/12/sys/arm64/linux/linux_syscalls.c
  stable/12/sys/arm64/linux/linux_sysent.c
  stable/12/sys/arm64/linux/linux_systrace_args.c
  stable/12/sys/i386/linux/linux_proto.h
  stable/12/sys/i386/linux/linux_syscall.h
  stable/12/sys/i386/linux/linux_syscalls.c
  stable/12/sys/i386/linux/linux_sysent.c
  stable/12/sys/i386/linux/linux_systrace_args.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/linux/linux_proto.h
==
--- stable/12/sys/amd64/linux/linux_proto.h Mon Aug 24 17:25:26 2020
(r364715)
+++ stable/12/sys/amd64/linux/linux_proto.h Mon Aug 24 17:29:37 2020
(r364716)
@@ -136,6 +136,11 @@ struct linux_mincore_args {
char len_l_[PADL_(l_size_t)]; l_size_t len; char 
len_r_[PADR_(l_size_t)];
char vec_l_[PADL_(u_char *)]; u_char * vec; char vec_r_[PADR_(u_char 
*)];
 };
+struct linux_madvise_args {
+   char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)];
+   char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
+   char behav_l_[PADL_(int)]; int behav; char behav_r_[PADR_(int)];
+};
 struct linux_shmget_args {
char key_l_[PADL_(l_key_t)]; l_key_t key; char key_r_[PADR_(l_key_t)];
char size_l_[PADL_(l_size_t)]; l_size_t size; char 
size_r_[PADR_(l_size_t)];
@@ -1292,6 +1297,7 @@ int   linux_select(struct thread *, struct 
linux_select_
 intlinux_mremap(struct thread *, struct linux_mremap_args *);
 intlinux_msync(struct thread *, struct linux_msync_args *);
 intlinux_mincore(struct thread *, struct linux_mincore_args *);
+intlinux_madvise(struct thread *, struct linux_madvise_args *);
 intlinux_shmget(struct thread *, struct linux_shmget_args *);
 intlinux_shmat(struct thread *, struct linux_shmat_args *);
 intlinux_shmctl(struct thread *, struct linux_shmctl_args *);
@@ -1615,6 +1621,7 @@ int   linux_io_uring_register(struct thread *, struct 
li
 #defineLINUX_SYS_AUE_linux_mremap  AUE_NULL
 #defineLINUX_SYS_AUE_linux_msync   AUE_MSYNC
 #defineLINUX_SYS_AUE_linux_mincore AUE_MINCORE
+#defineLINUX_SYS_AUE_linux_madvise AUE_MADVISE
 #defineLINUX_SYS_AUE_linux_shmget  AUE_NULL
 #defineLINUX_SYS_AUE_linux_shmat   AUE_NULL
 #defineLINUX_SYS_AUE_linux_shmctl  AUE_NULL

Modified: stable/12/sys/amd64/linux/linux_syscall.h
==
--- stable/12/sys/amd64/linux/linux_syscall.h   Mon Aug 24 17:25:26 2020
(r364715)
+++ stable/12/sys/amd64/linux/linux_syscall.h   Mon Aug 24 17:29:37 2020
(r364716)
@@ -33,7 +33,7 @@
 #defineLINUX_SYS_linux_mremap  25
 #defineLINUX_SYS_linux_msync   26
 #defineLINUX_SYS_linux_mincore 27
-#defineLINUX_SYS_madvise   28
+#defineLINUX_SYS_linux_madvise 28
 #defineLINUX_SYS_linux_shmget  29
 #defineLINUX_SYS_linux_shmat   30
 #defineLINUX_SYS_linux_shmctl  31

Modified: stable/12/sys/amd64/linux/linux_syscalls.c
==
--- stable/12/sys/amd64/linux/linux_syscalls.c  Mon Aug 24 17:25:26 2020
(r364715)
+++ stable/12/sys/amd64/linux/linux_syscalls.c  Mon Aug 24 17:29:37 2020
(r364716)
@@ -35,7 +35,7 @@ const char *linux_syscallnames[] = {
"linux_mremap", /* 25 = linux_mremap */
"linux_msync",  /* 26 = linux_msync */
"linux_mincore",/* 27 = linux_mincore */
-   "madvise",  /* 28 = madvise */
+   "linux_madvise",/* 28 = linux_madvise */
"linux_shmget", /* 29 = linux_shmget */
"linux_shmat",  /* 30 = linux_shmat */
"linux_shmctl", /* 31 = linux_shmctl */

Modified: stable/12/sys/amd64/linux/linux_sysent.c
==
--- stable/12/sys/amd64/linux/linux_sysent.cMon Aug 24 17:25:26 2020

svn commit: r364715 - in stable/12/sys: amd64/linux amd64/linux32 arm64/linux compat/linux i386/linux sys vm

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 17:25:26 2020
New Revision: 364715
URL: https://svnweb.freebsd.org/changeset/base/364715

Log:
  MFC r362440:
  
  Add linux_madvise(2) instead of having Linux apps call the native
  FreeBSD madvise(2) directly.  While some of the flag values match,
  most don't.
  
  PR:   kern/230160
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/amd64/linux/linux_machdep.c
  stable/12/sys/amd64/linux/syscalls.master
  stable/12/sys/amd64/linux32/linux32_machdep.c
  stable/12/sys/amd64/linux32/syscalls.master
  stable/12/sys/arm64/linux/linux_machdep.c
  stable/12/sys/arm64/linux/syscalls.master
  stable/12/sys/compat/linux/linux_mmap.c
  stable/12/sys/compat/linux/linux_mmap.h
  stable/12/sys/i386/linux/linux_machdep.c
  stable/12/sys/i386/linux/syscalls.master
  stable/12/sys/sys/syscallsubr.h
  stable/12/sys/vm/vm_mmap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/linux/linux_machdep.c
==
--- stable/12/sys/amd64/linux/linux_machdep.c   Mon Aug 24 17:21:26 2020
(r364714)
+++ stable/12/sys/amd64/linux/linux_machdep.c   Mon Aug 24 17:25:26 2020
(r364715)
@@ -141,6 +141,13 @@ linux_mprotect(struct thread *td, struct linux_mprotec
 }
 
 int
+linux_madvise(struct thread *td, struct linux_madvise_args *uap)
+{
+
+   return (linux_madvise_common(td, PTROUT(uap->addr), uap->len, 
uap->behav));
+}
+
+int
 linux_iopl(struct thread *td, struct linux_iopl_args *args)
 {
int error;

Modified: stable/12/sys/amd64/linux/syscalls.master
==
--- stable/12/sys/amd64/linux/syscalls.master   Mon Aug 24 17:21:26 2020
(r364714)
+++ stable/12/sys/amd64/linux/syscalls.master   Mon Aug 24 17:25:26 2020
(r364715)
@@ -94,7 +94,7 @@
l_size_t len, l_int fl); }
 27 AUE_MINCORE STD { int linux_mincore(l_ulong start, \
l_size_t len, u_char *vec); }
-28 AUE_MADVISE NOPROTO { int madvise(void *addr, size_t len, \
+28 AUE_MADVISE STD { int linux_madvise(void *addr, size_t len, \
int behav); }
 29 AUE_NULLSTD { int linux_shmget(l_key_t key, l_size_t size, \
l_int shmflg); }

Modified: stable/12/sys/amd64/linux32/linux32_machdep.c
==
--- stable/12/sys/amd64/linux32/linux32_machdep.c   Mon Aug 24 17:21:26 
2020(r364714)
+++ stable/12/sys/amd64/linux32/linux32_machdep.c   Mon Aug 24 17:25:26 
2020(r364715)
@@ -469,6 +469,13 @@ linux_mprotect(struct thread *td, struct linux_mprotec
 }
 
 int
+linux_madvise(struct thread *td, struct linux_madvise_args *uap)
+{
+
+   return (linux_madvise_common(td, PTROUT(uap->addr), uap->len, 
uap->behav));
+}
+
+int
 linux_iopl(struct thread *td, struct linux_iopl_args *args)
 {
int error;

Modified: stable/12/sys/amd64/linux32/syscalls.master
==
--- stable/12/sys/amd64/linux32/syscalls.master Mon Aug 24 17:21:26 2020
(r364714)
+++ stable/12/sys/amd64/linux32/syscalls.master Mon Aug 24 17:25:26 2020
(r364715)
@@ -389,7 +389,7 @@
char *put_old); }
 218AUE_MINCORE STD { int linux_mincore(l_ulong start, \
l_size_t len, u_char *vec); }
-219AUE_MADVISE NOPROTO { int madvise(void *addr, size_t len, \
+219AUE_MADVISE STD { int linux_madvise(void *addr, size_t len, \
int behav); }
 220AUE_GETDIRENTRIES   STD { int linux_getdents64(l_uint fd, \
void *dirent, l_uint count); }

Modified: stable/12/sys/arm64/linux/linux_machdep.c
==
--- stable/12/sys/arm64/linux/linux_machdep.c   Mon Aug 24 17:21:26 2020
(r364714)
+++ stable/12/sys/arm64/linux/linux_machdep.c   Mon Aug 24 17:25:26 2020
(r364715)
@@ -104,6 +104,13 @@ linux_mprotect(struct thread *td, struct linux_mprotec
uap->prot));
 }
 
+int
+linux_madvise(struct thread *td, struct linux_madvise_args *uap)
+{
+
+   return (linux_madvise_common(td, PTROUT(uap->addr), uap->len, 
uap->behav));
+}
+
 /* LINUXTODO: implement arm64 linux_rt_sigsuspend */
 int
 linux_rt_sigsuspend(struct thread *td, struct linux_rt_sigsuspend_args *uap)

Modified: stable/12/sys/arm64/linux/syscalls.master
==
--- stable/12/sys/arm64/linux/syscalls.master   Mon Aug 24 17:21:26 2020
(r364714)
+++ stable/12/sys/arm64/linux/syscalls.master   Mon Aug 24 17:25:26 2020   

svn commit: r364712 - in stable/12/sys: amd64/linux amd64/linux32 arm64/linux compat/linux i386/linux modules/linux modules/linux64 modules/linux_common

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 17:06:34 2020
New Revision: 364712
URL: https://svnweb.freebsd.org/changeset/base/364712

Log:
  MFC r347538 by dchagin:
  
  Linuxulator depends on a fundamental kernel settings such as SMP. Many
  of them listed in opt_global.h which is not generated while building
  modules outside of a kernel and such modules never match real cofigured
  kernel.
  
  So, we should prevent our users from building obviously defective modules.
  
  Therefore, remove the root cause of the building of modules outside of a
  kernel - the possibility of building modules with DEBUG or KTR flags.
  And remove all of DEBUG printfs as it is incomplete and in threaded
  programms not informative, also a half of system call does not have DEBUG
  printf. For debuging Linux programms we have dtrace, ktr and ktrace ability.
  
  PR:   222861

Modified:
  stable/12/sys/amd64/linux/linux.h
  stable/12/sys/amd64/linux/linux_sysvec.c
  stable/12/sys/amd64/linux32/linux.h
  stable/12/sys/amd64/linux32/linux32_machdep.c
  stable/12/sys/amd64/linux32/linux32_sysvec.c
  stable/12/sys/arm64/linux/linux.h
  stable/12/sys/arm64/linux/linux_sysvec.c
  stable/12/sys/compat/linux/linux_file.c
  stable/12/sys/compat/linux/linux_fork.c
  stable/12/sys/compat/linux/linux_getcwd.c
  stable/12/sys/compat/linux/linux_ioctl.c
  stable/12/sys/compat/linux/linux_misc.c
  stable/12/sys/compat/linux/linux_misc.h
  stable/12/sys/compat/linux/linux_signal.c
  stable/12/sys/compat/linux/linux_stats.c
  stable/12/sys/i386/linux/linux.h
  stable/12/sys/i386/linux/linux_machdep.c
  stable/12/sys/i386/linux/linux_sysvec.c
  stable/12/sys/modules/linux/Makefile
  stable/12/sys/modules/linux64/Makefile
  stable/12/sys/modules/linux_common/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/linux/linux.h
==
--- stable/12/sys/amd64/linux/linux.h   Mon Aug 24 16:45:23 2020
(r364711)
+++ stable/12/sys/amd64/linux/linux.h   Mon Aug 24 17:06:34 2020
(r364712)
@@ -39,15 +39,6 @@
 
 #defineLINUX_LEGACY_SYSCALLS
 
-/*
- * debugging support
- */
-extern u_char linux_debug_map[];
-#defineldebug(name)isclr(linux_debug_map, LINUX_SYS_linux_ ## name)
-#defineARGS(nm, fmt)   "linux(%ld/%ld): "#nm"("fmt")\n",   
\
-   (long)td->td_proc->p_pid, (long)td->td_tid
-#defineLMSG(fmt)   "linux(%ld/%ld): "fmt"\n",  
\
-   (long)td->td_proc->p_pid, (long)td->td_tid
 #defineLINUX_DTRACElinuxulator
 
 /*

Modified: stable/12/sys/amd64/linux/linux_sysvec.c
==
--- stable/12/sys/amd64/linux/linux_sysvec.cMon Aug 24 16:45:23 2020
(r364711)
+++ stable/12/sys/amd64/linux/linux_sysvec.cMon Aug 24 17:06:34 2020
(r364712)
@@ -85,20 +85,6 @@ __FBSDID("$FreeBSD$");
 
 MODULE_VERSION(linux64, 1);
 
-#if defined(DEBUG)
-SYSCTL_PROC(_compat_linux, OID_AUTO, debug,
-   CTLTYPE_STRING | CTLFLAG_RW,
-   0, 0, linux_sysctl_debug, "A",
-   "Linux 64 debugging control");
-#endif
-
-/*
- * Allow the sendsig functions to use the ldebug() facility even though they
- * are not syscalls themselves.  Map them to syscall 0.  This is slightly less
- * bogus than using ldebug(sigreturn).
- */
-#defineLINUX_SYS_linux_rt_sendsig  0
-
 const char *linux_kplatform;
 static int linux_szsigcode;
 static vm_object_t linux_shared_page_obj;
@@ -650,9 +636,6 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigse
 
/* Copy the sigframe out to the user's stack. */
if (copyout(, sfp, sizeof(*sfp)) != 0) {
-#ifdef DEBUG
-   printf("process %ld has trashed its stack\n", (long)p->p_pid);
-#endif
PROC_LOCK(p);
sigexit(td, SIGILL);
}

Modified: stable/12/sys/amd64/linux32/linux.h
==
--- stable/12/sys/amd64/linux32/linux.h Mon Aug 24 16:45:23 2020
(r364711)
+++ stable/12/sys/amd64/linux32/linux.h Mon Aug 24 17:06:34 2020
(r364712)
@@ -42,15 +42,6 @@
 
 #defineLINUX_LEGACY_SYSCALLS
 
-/*
- * debugging support
- */
-extern u_char linux_debug_map[];
-#defineldebug(name)isclr(linux_debug_map, LINUX32_SYS_linux_ ## 
name)
-#defineARGS(nm, fmt)   "linux(%ld/%ld): "#nm"("fmt")\n",   
\
-   (long)td->td_proc->p_pid, (long)td->td_tid
-#defineLMSG(fmt)   "linux(%ld/%ld): "fmt"\n",  
\
-   (long)td->td_proc->p_pid, (long)td->td_tid
 #defineLINUX_DTRACElinuxulator32
 
 #defineLINUX32_MAXUSER ((1ul << 32) - PAGE_SIZE)

Modified: stable/12/sys/amd64/linux32/linux32_machdep.c

svn commit: r364710 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 16:44:17 2020
New Revision: 364710
URL: https://svnweb.freebsd.org/changeset/base/364710

Log:
  MFC r362101:
  
  Minor code cleanup; no functional changes.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/compat/linux/linux_socket.c
  stable/12/sys/compat/linux/linux_socket.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:41:10 2020
(r364709)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:44:17 2020
(r364710)
@@ -89,10 +89,9 @@ static int
 linux_to_bsd_sockopt_level(int level)
 {
 
-   switch (level) {
-   case LINUX_SOL_SOCKET:
+   if (level == LINUX_SOL_SOCKET)
return (SOL_SOCKET);
-   }
+   /* Remaining values are RFC-defined protocol numbers. */
return (level);
 }
 
@@ -100,10 +99,8 @@ static int
 bsd_to_linux_sockopt_level(int level)
 {
 
-   switch (level) {
-   case SOL_SOCKET:
+   if (level == SOL_SOCKET)
return (LINUX_SOL_SOCKET);
-   }
return (level);
 }
 

Modified: stable/12/sys/compat/linux/linux_socket.h
==
--- stable/12/sys/compat/linux/linux_socket.h   Mon Aug 24 16:41:10 2020
(r364709)
+++ stable/12/sys/compat/linux/linux_socket.h   Mon Aug 24 16:44:17 2020
(r364710)
@@ -166,12 +166,6 @@ int linux_accept(struct thread *td, struct linux_accep
 
 /* Socket defines */
 #defineLINUX_SOL_SOCKET1
-#defineLINUX_SOL_IP0
-#defineLINUX_SOL_TCP   6
-#defineLINUX_SOL_UDP   17
-#defineLINUX_SOL_IPV6  41
-#defineLINUX_SOL_IPX   256
-#defineLINUX_SOL_AX25  257
 
 #defineLINUX_SO_DEBUG  1
 #defineLINUX_SO_REUSEADDR  2
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364709 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 16:41:10 2020
New Revision: 364709
URL: https://svnweb.freebsd.org/changeset/base/364709

Log:
  MFC r356729:
  
  Make linux(4) use kern_setsockopt(9) instead of going through
  sys_setsockopt.  Just a cleanup; no functional changes.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:36:35 2020
(r364708)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:41:10 2020
(r364709)
@@ -1428,22 +1428,14 @@ linux_shutdown(struct thread *td, struct linux_shutdow
 int
 linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args)
 {
-   struct setsockopt_args /* {
-   int s;
-   int level;
-   int name;
-   caddr_t val;
-   int valsize;
-   } */ bsd_args;
l_timeval linux_tv;
struct sockaddr *sa;
struct timeval tv;
socklen_t len;
-   int error, name;
+   int error, level, name;
 
-   bsd_args.s = args->s;
-   bsd_args.level = linux_to_bsd_sockopt_level(args->level);
-   switch (bsd_args.level) {
+   level = linux_to_bsd_sockopt_level(args->level);
+   switch (level) {
case SOL_SOCKET:
name = linux_to_bsd_so_sockopt(args->optname);
switch (name) {
@@ -1456,7 +1448,7 @@ linux_setsockopt(struct thread *td, struct linux_setso
return (error);
tv.tv_sec = linux_tv.tv_sec;
tv.tv_usec = linux_tv.tv_usec;
-   return (kern_setsockopt(td, args->s, bsd_args.level,
+   return (kern_setsockopt(td, args->s, level,
name, , UIO_SYSSPACE, sizeof(tv)));
/* NOTREACHED */
default:
@@ -1489,20 +1481,17 @@ linux_setsockopt(struct thread *td, struct linux_setso
 
 
if (name == IPV6_NEXTHOP) {
-
len = args->optlen;
error = linux_to_bsd_sockaddr(PTRIN(args->optval), , );
if (error != 0)
return (error);
 
-   error = kern_setsockopt(td, args->s, bsd_args.level,
+   error = kern_setsockopt(td, args->s, level,
name, sa, UIO_SYSSPACE, len);
free(sa, M_SONAME);
} else {
-   bsd_args.name = name;
-   bsd_args.val = PTRIN(args->optval);
-   bsd_args.valsize = args->optlen;
-   error = sys_setsockopt(td, _args);
+   error = kern_setsockopt(td, args->s, level,
+   name, PTRIN(args->optval), UIO_USERSPACE, args->optlen);
}
 
return (error);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364708 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 16:36:35 2020
New Revision: 364708
URL: https://svnweb.freebsd.org/changeset/base/364708

Log:
  MFC r356728:
  
  Make linux(4) use kern_getsockopt(9) instead of going through
  sys_getsockopt().  It's a cleanup; no functional changes.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:27:51 2020
(r364707)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:36:35 2020
(r364708)
@@ -1511,13 +1511,6 @@ linux_setsockopt(struct thread *td, struct linux_setso
 int
 linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args)
 {
-   struct getsockopt_args /* {
-   int s;
-   int level;
-   int name;
-   caddr_t val;
-   int *avalsize;
-   } */ bsd_args;
l_timeval linux_tv;
struct timeval tv;
socklen_t tv_len, xulen, len;
@@ -1525,11 +1518,10 @@ linux_getsockopt(struct thread *td, struct linux_getso
struct sockaddr *sa;
struct xucred xu;
struct l_ucred lxu;
-   int error, name, newval;
+   int error, level, name, newval;
 
-   bsd_args.s = args->s;
-   bsd_args.level = linux_to_bsd_sockopt_level(args->level);
-   switch (bsd_args.level) {
+   level = linux_to_bsd_sockopt_level(args->level);
+   switch (level) {
case SOL_SOCKET:
name = linux_to_bsd_so_sockopt(args->optname);
switch (name) {
@@ -1537,7 +1529,7 @@ linux_getsockopt(struct thread *td, struct linux_getso
/* FALLTHROUGH */
case SO_SNDTIMEO:
tv_len = sizeof(tv);
-   error = kern_getsockopt(td, args->s, bsd_args.level,
+   error = kern_getsockopt(td, args->s, level,
name, , UIO_SYSSPACE, _len);
if (error != 0)
return (error);
@@ -1553,9 +1545,9 @@ linux_getsockopt(struct thread *td, struct linux_getso
 * LOCAL_PEERCRED is not served at the SOL_SOCKET level,
 * but by the Unix socket's level 0.
 */
-   bsd_args.level = 0;
+   level = 0;
xulen = sizeof(xu);
-   error = kern_getsockopt(td, args->s, bsd_args.level,
+   error = kern_getsockopt(td, args->s, level,
name, , UIO_SYSSPACE, );
if (error != 0)
return (error);
@@ -1569,7 +1561,7 @@ linux_getsockopt(struct thread *td, struct linux_getso
/* NOTREACHED */
case SO_ERROR:
len = sizeof(newval);
-   error = kern_getsockopt(td, args->s, bsd_args.level,
+   error = kern_getsockopt(td, args->s, level,
name, , UIO_SYSSPACE, );
if (error != 0)
return (error);
@@ -1596,16 +1588,13 @@ linux_getsockopt(struct thread *td, struct linux_getso
if (name == -1)
return (EINVAL);
 
-   bsd_args.name = name;
-   bsd_args.avalsize = PTRIN(args->optlen);
-
if (name == IPV6_NEXTHOP) {
error = copyin(PTRIN(args->optlen), , sizeof(len));
 if (error != 0)
 return (error);
sa = malloc(len, M_SONAME, M_WAITOK);
 
-   error = kern_getsockopt(td, args->s, bsd_args.level,
+   error = kern_getsockopt(td, args->s, level,
name, sa, UIO_SYSSPACE, );
if (error != 0)
goto out;
@@ -1620,8 +1609,16 @@ linux_getsockopt(struct thread *td, struct linux_getso
 out:
free(sa, M_SONAME);
} else {
-   bsd_args.val = PTRIN(args->optval);
-   error = sys_getsockopt(td, _args);
+   if (args->optval) {
+   error = copyin(PTRIN(args->optlen), , sizeof(len));
+   if (error != 0)
+   return (error);
+   }
+   error = kern_getsockopt(td, args->s, level,
+   name, PTRIN(args->optval), UIO_USERSPACE, );
+   if (error == 0)
+   error = copyout(, PTRIN(args->optlen),
+   sizeof(len));
}
 
return (error);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to 

svn commit: r364707 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 16:27:51 2020
New Revision: 364707
URL: https://svnweb.freebsd.org/changeset/base/364707

Log:
  MFC r362941:
  
  Fix Linux recvmsg(2) when msg_namelen returned is 0.  Previously
  it would fail with EINVAL, breaking some of the Python regression
  tests.
  
  While here, cap the user-controlled message length.
  
  Note that the code doesn't seem to be copying out the new length
  in either (success or failure) case. This will be addressed separately.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:25:27 2020
(r364706)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:27:51 2020
(r364707)
@@ -1195,11 +1195,14 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
if (error != 0)
return (error);
 
-   if (msg->msg_name) {
+   if (msg->msg_name != NULL && msg->msg_namelen > 0) {
+   msg->msg_namelen = min(msg->msg_namelen, SOCK_MAXADDRLEN);
sa = malloc(msg->msg_namelen, M_SONAME, M_WAITOK);
msg->msg_name = sa;
-   } else
+   } else {
sa = NULL;
+   msg->msg_name = NULL;
+   }
 
uiov = msg->msg_iov;
msg->msg_iov = iov;
@@ -1209,7 +1212,10 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
if (error != 0)
goto bad;
 
-   if (msg->msg_name) {
+   /*
+* Note that kern_recvit() updates msg->msg_namelen.
+*/
+   if (msg->msg_name != NULL && msg->msg_namelen > 0) {
msg->msg_name = PTRIN(linux_msghdr.msg_name);
error = bsd_to_linux_sockaddr(sa, , msg->msg_namelen);
if (error == 0)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364706 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 16:25:27 2020
New Revision: 364706
URL: https://svnweb.freebsd.org/changeset/base/364706

Log:
  MFC r362833:
  
  Rework linux accept(2).  This makes the code flow easier to follow,
  and fixes a bug where calling accept(2) could result in closing fd 0.
  
  Note that the code still contains a number of problems: it makes
  assumptions about l_sockaddr_in being the same as sockaddr_in,
  the EFAULT-related code looks like it doesn't work at all, and the
  socket type check is racy.  Those will be addressed later on;
  I'm trying to work in small steps to avoid breaking one thing while
  fixing another.
  
  It fixes Redis, among other things.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:23:27 2020
(r364705)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:25:27 2020
(r364706)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -610,17 +611,19 @@ linux_accept_common(struct thread *td, int s, l_uintpt
 {
struct l_sockaddr *lsa;
struct sockaddr *sa;
-   struct file *fp;
+   struct file *fp, *fp1;
int bflags, len;
struct socket *so;
int error, error1;
 
bflags = 0;
+   fp = NULL;
+   sa = NULL;
+
error = linux_set_socket_flags(flags, );
if (error != 0)
return (error);
 
-   sa = NULL;
if (PTRIN(addr) == NULL) {
len = 0;
error = kern_accept4(td, s, NULL, NULL, bflags, NULL);
@@ -631,48 +634,54 @@ linux_accept_common(struct thread *td, int s, l_uintpt
if (len < 0)
return (EINVAL);
error = kern_accept4(td, s, , , bflags, );
-   if (error == 0)
-   fdrop(fp, td);
}
 
+   /*
+* Translate errno values into ones used by Linux.
+*/
if (error != 0) {
/*
 * XXX. This is wrong, different sockaddr structures
 * have different sizes.
 */
-   if (error == EFAULT && namelen != sizeof(struct sockaddr_in))
-   {
-   error = EINVAL;
-   goto out;
-   }
-   if (error == EINVAL) {
-   error1 = getsock_cap(td, s, _accept_rights, , 
NULL, NULL);
+   switch (error) {
+   case EFAULT:
+   if (namelen != sizeof(struct sockaddr_in))
+   error = EINVAL;
+   break;
+   case EINVAL:
+   error1 = getsock_cap(td, s, _accept_rights, , 
NULL, NULL);
if (error1 != 0) {
error = error1;
-   goto out;
+   break;
}
-   so = fp->f_data;
+   so = fp1->f_data;
if (so->so_type == SOCK_DGRAM)
error = EOPNOTSUPP;
-   fdrop(fp, td);
+   fdrop(fp1, td);
+   break;
}
-   goto out;
+   return (error);
}
 
-   if (len != 0 && error == 0) {
+   if (len != 0) {
error = bsd_to_linux_sockaddr(sa, , len);
if (error == 0)
error = copyout(lsa, PTRIN(addr), len);
free(lsa, M_SONAME);
-   }
 
-   free(sa, M_SONAME);
+   /*
+* XXX: We should also copyout the len, shouldn't we?
+*/
 
-out:
-   if (error != 0) {
-   (void)kern_close(td, td->td_retval[0]);
-   td->td_retval[0] = 0;
+   if (error != 0) {
+   fdclose(td, fp, td->td_retval[0]);
+   td->td_retval[0] = 0;
+   }
}
+   if (fp != NULL)
+   fdrop(fp, td);
+   free(sa, M_SONAME);
return (error);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364705 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 16:23:27 2020
New Revision: 364705
URL: https://svnweb.freebsd.org/changeset/base/364705

Log:
  MFC r362735:
  
  Make linux(4) support SO_PROTOCOL.  Running Python test suite
  with python3.8 from Focal triggers those.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/compat/linux/linux_socket.c
  stable/12/sys/compat/linux/linux_socket.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:21:03 2020
(r364704)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:23:27 2020
(r364705)
@@ -235,6 +235,8 @@ linux_to_bsd_so_sockopt(int opt)
return (SO_TIMESTAMP);
case LINUX_SO_ACCEPTCONN:
return (SO_ACCEPTCONN);
+   case LINUX_SO_PROTOCOL:
+   return (SO_PROTOCOL);
}
return (-1);
 }

Modified: stable/12/sys/compat/linux/linux_socket.h
==
--- stable/12/sys/compat/linux/linux_socket.h   Mon Aug 24 16:21:03 2020
(r364704)
+++ stable/12/sys/compat/linux/linux_socket.h   Mon Aug 24 16:23:27 2020
(r364705)
@@ -199,6 +199,7 @@ int linux_accept(struct thread *td, struct linux_accep
 #defineLINUX_SO_ACCEPTCONN 30
 #defineLINUX_SO_SNDBUFFORCE32
 #defineLINUX_SO_RCVBUFFORCE33
+#defineLINUX_SO_PROTOCOL   38
 
 /* Socket options */
 #defineLINUX_IP_TOS1
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364704 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 16:21:03 2020
New Revision: 364704
URL: https://svnweb.freebsd.org/changeset/base/364704

Log:
  MFC r362176:
  
  Make linux(4) warn about unsupported CMSG level/type.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:15:12 2020
(r364703)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:21:03 2020
(r364704)
@@ -1041,8 +1041,12 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
cmsg->cmsg_level =
linux_to_bsd_sockopt_level(linux_cmsg.cmsg_level);
if (cmsg->cmsg_type == -1
-   || cmsg->cmsg_level != SOL_SOCKET)
+   || cmsg->cmsg_level != SOL_SOCKET) {
+   linux_msg(curthread,
+   "unsupported sendmsg cmsg level %d type %d",
+   linux_cmsg.cmsg_level, 
linux_cmsg.cmsg_type);
goto bad;
+   }
 
/*
 * Some applications (e.g. pulseaudio) attempt to
@@ -1227,6 +1231,9 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
bsd_to_linux_sockopt_level(cm->cmsg_level);
if (linux_cmsg->cmsg_type == -1 ||
cm->cmsg_level != SOL_SOCKET) {
+   linux_msg(curthread,
+   "unsupported recvmsg cmsg level %d type %d",
+   cm->cmsg_level, cm->cmsg_type);
error = EINVAL;
goto bad;
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364703 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 16:15:12 2020
New Revision: 364703
URL: https://svnweb.freebsd.org/changeset/base/364703

Log:
  MFC r362059:
  
  Don't use newlines with linux_msg().  No functional changes.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/compat/linux/linux.c
  stable/12/sys/compat/linux/linux_event.c
  stable/12/sys/compat/linux/linux_futex.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux.c
==
--- stable/12/sys/compat/linux/linux.c  Mon Aug 24 16:06:17 2020
(r364702)
+++ stable/12/sys/compat/linux/linux.c  Mon Aug 24 16:15:12 2020
(r364703)
@@ -485,7 +485,7 @@ linux_to_bsd_sockaddr(const struct l_sockaddr *osa, st
sin6->sin6_scope_id = 0;
} else {
linux_msg(curthread,
-   "obsolete pre-RFC2553 sockaddr_in6 
rejected\n");
+   "obsolete pre-RFC2553 sockaddr_in6 
rejected");
error = EINVAL;
goto out;
}

Modified: stable/12/sys/compat/linux/linux_event.c
==
--- stable/12/sys/compat/linux/linux_event.cMon Aug 24 16:06:17 2020
(r364702)
+++ stable/12/sys/compat/linux/linux_event.cMon Aug 24 16:15:12 2020
(r364703)
@@ -342,7 +342,7 @@ epoll_to_kevent(struct thread *td, int fd, struct epol
if ((pem->flags & LINUX_XUNSUP_EPOLL) == 0) {
pem->flags |= LINUX_XUNSUP_EPOLL;
LINUX_PEM_XUNLOCK(pem);
-   linux_msg(td, "epoll_ctl unsupported flags: 0x%x\n",
+   linux_msg(td, "epoll_ctl unsupported flags: 0x%x",
levents);
} else
LINUX_PEM_XUNLOCK(pem);

Modified: stable/12/sys/compat/linux/linux_futex.c
==
--- stable/12/sys/compat/linux/linux_futex.cMon Aug 24 16:06:17 2020
(r364702)
+++ stable/12/sys/compat/linux/linux_futex.cMon Aug 24 16:15:12 2020
(r364703)
@@ -1086,7 +1086,7 @@ retry2:
return (ENOSYS);
 
default:
-   linux_msg(td, "unsupported futex op %d\n", args->op);
+   linux_msg(td, "unsupported futex op %d", args->op);
LIN_SDT_PROBE1(futex, linux_sys_futex, unknown_operation,
args->op);
LIN_SDT_PROBE1(futex, linux_sys_futex, return, ENOSYS);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364702 - in stable/12/sys: compat/linux i386/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 16:06:17 2020
New Revision: 364702
URL: https://svnweb.freebsd.org/changeset/base/364702

Log:
  MFC r354413:
  
  Make linux(4) create /dev/shm.  Linux applications often expect
  a tmpfs to be mounted there, and because they like to verify it's
  actually a mountpoint, a symlink won't do.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/compat/linux/linux.c
  stable/12/sys/compat/linux/linux.h
  stable/12/sys/compat/linux/linux_common.c
  stable/12/sys/i386/linux/linux_sysvec.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux.c
==
--- stable/12/sys/compat/linux/linux.c  Mon Aug 24 16:06:11 2020
(r364701)
+++ stable/12/sys/compat/linux/linux.c  Mon Aug 24 16:06:17 2020
(r364702)
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -129,6 +130,12 @@ static int linux_to_bsd_sigtbl[LINUX_SIGTBLSZ] = {
SIGSYS  /* LINUX_SIGSYS */
 };
 
+static struct cdev *dev_shm_cdev;
+static struct cdevsw dev_shm_cdevsw = {
+ .d_version = D_VERSION,
+ .d_name= "dev_shm",
+};
+
 /*
  * Map Linux RT signals to the FreeBSD RT signals.
  */
@@ -523,4 +530,24 @@ linux_to_bsd_sockaddr(const struct l_sockaddr *osa, st
 out:
free(kosa, M_SONAME);
return (error);
+}
+
+void
+linux_dev_shm_create(void)
+{
+   int error;
+
+   error = make_dev_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, _shm_cdev,
+   _shm_cdevsw, NULL, UID_ROOT, GID_WHEEL, 0, "shm/.mountpoint");
+   if (error != 0) {
+   printf("%s: failed to create device node, error %d\n",
+   __func__, error);
+   }
+}
+
+void
+linux_dev_shm_destroy(void)
+{
+
+   destroy_dev(dev_shm_cdev);
 }

Modified: stable/12/sys/compat/linux/linux.h
==
--- stable/12/sys/compat/linux/linux.h  Mon Aug 24 16:06:11 2020
(r364701)
+++ stable/12/sys/compat/linux/linux.h  Mon Aug 24 16:06:17 2020
(r364702)
@@ -143,4 +143,7 @@ int bsd_to_linux_signal(int sig);
 extern LIST_HEAD(futex_list, futex) futex_list;
 extern struct mtx futex_mtx;
 
+void linux_dev_shm_create(void);
+void linux_dev_shm_destroy(void);
+
 #endif /* _LINUX_MI_H_ */

Modified: stable/12/sys/compat/linux/linux_common.c
==
--- stable/12/sys/compat/linux/linux_common.c   Mon Aug 24 16:06:11 2020
(r364701)
+++ stable/12/sys/compat/linux/linux_common.c   Mon Aug 24 16:06:17 2020
(r364702)
@@ -68,6 +68,7 @@ linux_common_modevent(module_t mod, int type, void *da
 
switch(type) {
case MOD_LOAD:
+   linux_dev_shm_create();
linux_osd_jail_register();
linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,
linux_proc_exit, NULL, 1000);
@@ -81,6 +82,7 @@ linux_common_modevent(module_t mod, int type, void *da
mtx_init(_mtx, "ftllk", NULL, MTX_DEF);
break;
case MOD_UNLOAD:
+   linux_dev_shm_destroy();
linux_osd_jail_deregister();
SET_FOREACH(ldhp, linux_device_handler_set)
linux_device_unregister_handler(*ldhp);

Modified: stable/12/sys/i386/linux/linux_sysvec.c
==
--- stable/12/sys/i386/linux/linux_sysvec.c Mon Aug 24 16:06:11 2020
(r364701)
+++ stable/12/sys/i386/linux/linux_sysvec.c Mon Aug 24 16:06:17 2020
(r364702)
@@ -1057,6 +1057,7 @@ linux_elf_modevent(module_t mod, int type, void *data)
linux_get_machine(_kplatform);
linux_szplatform = roundup(strlen(linux_kplatform) + 1,
sizeof(char *));
+   linux_dev_shm_create();
linux_osd_jail_register();
stclohz = (stathz ? stathz : hz);
if (bootverbose)
@@ -1082,6 +1083,7 @@ linux_elf_modevent(module_t mod, int type, void *data)
EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
EVENTHANDLER_DEREGISTER(thread_dtor, 
linux_thread_dtor_tag);
+   linux_dev_shm_destroy();
linux_osd_jail_deregister();
if (bootverbose)
printf("Linux ELF exec handler removed\n");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364700 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 16:00:58 2020
New Revision: 364700
URL: https://svnweb.freebsd.org/changeset/base/364700

Log:
  MFC r362103:
  
  Fix naming clash.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 15:56:31 2020
(r364699)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 16:00:58 2020
(r364700)
@@ -942,7 +942,7 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
struct msghdr msg;
struct l_cmsghdr linux_cmsg;
struct l_cmsghdr *ptr_cmsg;
-   struct l_msghdr linux_msg;
+   struct l_msghdr linux_msghdr;
struct iovec *iov;
socklen_t datalen;
struct sockaddr *sa;
@@ -954,7 +954,7 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
l_size_t clen;
int error, fflag;
 
-   error = copyin(msghdr, _msg, sizeof(linux_msg));
+   error = copyin(msghdr, _msghdr, sizeof(linux_msghdr));
if (error != 0)
return (error);
 
@@ -965,10 +965,11 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
 * order to handle this case.  This should be checked, but allows the
 * Linux ping to work.
 */
-   if (PTRIN(linux_msg.msg_control) != NULL && linux_msg.msg_controllen == 
0)
-   linux_msg.msg_control = PTROUT(NULL);
+   if (PTRIN(linux_msghdr.msg_control) != NULL &&
+   linux_msghdr.msg_controllen == 0)
+   linux_msghdr.msg_control = PTROUT(NULL);
 
-   error = linux_to_bsd_msghdr(, _msg);
+   error = linux_to_bsd_msghdr(, _msghdr);
if (error != 0)
return (error);
 
@@ -1006,7 +1007,7 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
goto bad;
}
 
-   if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) {
+   if (linux_msghdr.msg_controllen >= sizeof(struct l_cmsghdr)) {
 
error = ENOBUFS;
control = m_get(M_WAITOK, MT_CONTROL);
@@ -1014,8 +1015,8 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
data = mtod(control, void *);
datalen = 0;
 
-   ptr_cmsg = PTRIN(linux_msg.msg_control);
-   clen = linux_msg.msg_controllen;
+   ptr_cmsg = PTRIN(linux_msghdr.msg_control);
+   clen = linux_msghdr.msg_controllen;
do {
error = copyin(ptr_cmsg, _cmsg,
sizeof(struct l_cmsghdr));
@@ -1150,7 +1151,7 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
struct l_cmsghdr *linux_cmsg = NULL;
struct l_ucred linux_ucred;
socklen_t datalen, maxlen, outlen;
-   struct l_msghdr linux_msg;
+   struct l_msghdr linux_msghdr;
struct iovec *iov, *uiov;
struct mbuf *control = NULL;
struct mbuf **controlp;
@@ -1162,11 +1163,11 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
void *data;
int error, i, fd, fds, *fdp;
 
-   error = copyin(msghdr, _msg, sizeof(linux_msg));
+   error = copyin(msghdr, _msghdr, sizeof(linux_msghdr));
if (error != 0)
return (error);
 
-   error = linux_to_bsd_msghdr(msg, _msg);
+   error = linux_to_bsd_msghdr(msg, _msghdr);
if (error != 0)
return (error);
 
@@ -1194,7 +1195,7 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
goto bad;
 
if (msg->msg_name) {
-   msg->msg_name = PTRIN(linux_msg.msg_name);
+   msg->msg_name = PTRIN(linux_msghdr.msg_name);
error = bsd_to_linux_sockaddr(sa, , msg->msg_namelen);
if (error == 0)
error = copyout(lsa, PTRIN(msg->msg_name),
@@ -1204,12 +1205,12 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
goto bad;
}
 
-   error = bsd_to_linux_msghdr(msg, _msg);
+   error = bsd_to_linux_msghdr(msg, _msghdr);
if (error != 0)
goto bad;
 
-   maxlen = linux_msg.msg_controllen;
-   linux_msg.msg_controllen = 0;
+   maxlen = linux_msghdr.msg_controllen;
+   linux_msghdr.msg_controllen = 0;
if (control) {
linux_cmsg = malloc(L_CMSG_HDRSZ, M_LINUX, M_WAITOK | M_ZERO);
 
@@ -1217,7 +1218,7 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
msg->msg_controllen = control->m_len;
 
cm = CMSG_FIRSTHDR(msg);
-   outbuf = PTRIN(linux_msg.msg_control);
+   outbuf = PTRIN(linux_msghdr.msg_control);
outlen = 0;
while (cm != NULL) {
linux_cmsg->cmsg_type =
@@ 

svn commit: r364699 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 15:56:31 2020
New Revision: 364699
URL: https://svnweb.freebsd.org/changeset/base/364699

Log:
  MFC r348418 by dchagin:
  
  Linux does not support MSG_OOB for unix(4) or non-stream oriented socket,
  return EOPNOTSUPP as a Linux does.

Modified:
  stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 15:54:58 2020
(r364698)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 15:56:31 2020
(r364699)
@@ -946,11 +946,13 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
struct iovec *iov;
socklen_t datalen;
struct sockaddr *sa;
+   struct socket *so;
sa_family_t sa_family;
+   struct file *fp;
void *data;
l_size_t len;
l_size_t clen;
-   int error;
+   int error, fflag;
 
error = copyin(msghdr, _msg, sizeof(linux_msg));
if (error != 0)
@@ -981,12 +983,30 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
 
control = NULL;
 
-   if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) {
-   error = kern_getsockname(td, s, , );
+   error = kern_getsockname(td, s, , );
+   if (error != 0)
+   goto bad;
+   sa_family = sa->sa_family;
+   free(sa, M_SONAME);
+
+   if (flags & LINUX_MSG_OOB) {
+   error = EOPNOTSUPP;
+   if (sa_family == AF_UNIX)
+   goto bad;
+
+   error = getsock_cap(td, s, _send_rights, ,
+   , NULL);
if (error != 0)
goto bad;
-   sa_family = sa->sa_family;
-   free(sa, M_SONAME);
+   so = fp->f_data;
+   if (so->so_type != SOCK_STREAM)
+   error = EOPNOTSUPP;
+   fdrop(fp, td);
+   if (error != 0)
+   goto bad;
+   }
+
+   if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) {
 
error = ENOBUFS;
control = m_get(M_WAITOK, MT_CONTROL);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364698 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 15:54:58 2020
New Revision: 364698
URL: https://svnweb.freebsd.org/changeset/base/364698

Log:
  MFC r348058 by dchagin:
  
  Do not leak sa in linux_recvmsg() call if kern_recvit() fails.

Modified:
  stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 15:53:52 2020
(r364697)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 15:54:58 2020
(r364698)
@@ -1162,7 +1162,8 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
if (msg->msg_name) {
sa = malloc(msg->msg_namelen, M_SONAME, M_WAITOK);
msg->msg_name = sa;
-   }
+   } else
+   sa = NULL;
 
uiov = msg->msg_iov;
msg->msg_iov = iov;
@@ -1179,7 +1180,6 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
error = copyout(lsa, PTRIN(msg->msg_name),
msg->msg_namelen);
free(lsa, M_SONAME);
-   free(sa, M_SONAME);
if (error != 0)
goto bad;
}
@@ -1299,6 +1299,7 @@ bad:
}
free(iov, M_IOV);
free(linux_cmsg, M_LINUX);
+   free(sa, M_SONAME);
 
return (error);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364697 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 15:53:52 2020
New Revision: 364697
URL: https://svnweb.freebsd.org/changeset/base/364697

Log:
  MFC r348057 by dchagin:
  
  Do not use uninitialised sa.

Modified:
  stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 15:52:45 2020
(r364696)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 15:53:52 2020
(r364697)
@@ -1172,7 +1172,7 @@ linux_recvmsg_common(struct thread *td, l_int s, struc
if (error != 0)
goto bad;
 
-   if (sa) {
+   if (msg->msg_name) {
msg->msg_name = PTRIN(linux_msg.msg_name);
error = bsd_to_linux_sockaddr(sa, , msg->msg_namelen);
if (error == 0)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364696 - stable/12/sys/compat/linux

2020-08-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug 24 15:52:45 2020
New Revision: 364696
URL: https://svnweb.freebsd.org/changeset/base/364696

Log:
  MFC r348056 by dchagin:
  
  Do not leak sa in linux_recvfrom() call if kern_recvit() fails.

Modified:
  stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_socket.c
==
--- stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 15:50:57 2020
(r364695)
+++ stable/12/sys/compat/linux/linux_socket.c   Mon Aug 24 15:52:45 2020
(r364696)
@@ -915,7 +915,7 @@ linux_recvfrom(struct thread *td, struct linux_recvfro
 
error = kern_recvit(td, args->s, , UIO_SYSSPACE, NULL);
if (error != 0)
-   return (error);
+   goto out;
 
if (PTRIN(args->from) != NULL) {
error = bsd_to_linux_sockaddr(sa, , msg.msg_namelen);
@@ -928,7 +928,7 @@ linux_recvfrom(struct thread *td, struct linux_recvfro
if (error == 0 && PTRIN(args->fromlen) != NULL)
error = copyout(_namelen, PTRIN(args->fromlen),
sizeof(msg.msg_namelen));
-
+out:
free(sa, M_SONAME);
return (error);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


  1   2   3   4   5   6   7   8   9   10   >