open correct render node in libdrm

2019-05-11 Thread Jonathan Gray
drm render nodes have the same major as drm primary devices but have a
minor offset.

render nodes have a name that reflects the minor node not offset by the
base.  I expected it to be the other way around when these non-linux
codepaths were added (before we had render nodes).

Index: xf86drm.c
===
RCS file: /cvs/xenocara/lib/libdrm/xf86drm.c,v
retrieving revision 1.34
diff -u -p -r1.34 xf86drm.c
--- xf86drm.c   26 Apr 2019 07:45:37 -  1.34
+++ xf86drm.c   12 May 2019 02:45:41 -
@@ -2931,7 +2931,7 @@ static char *drmGetMinorNameForFD(int fd
 char buf[PATH_MAX + 1];
 const char *dev_name;
 unsigned int maj, min;
-int n, base;
+int n;
 
 if (fstat(fd, ))
 return NULL;
@@ -2956,11 +2956,7 @@ static char *drmGetMinorNameForFD(int fd
 return NULL;
 };
 
-base = drmGetMinorBase(type);
-if (base < 0)
-return NULL;
-
-n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min - base);
+n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min);
 if (n == -1 || n >= sizeof(buf))
 return NULL;
 
@@ -3854,7 +3850,7 @@ drm_public int drmGetDevice2(int fd, uin
 char node[PATH_MAX + 1];
 const char  *dev_name;
 int  node_type, subsystem_type;
-int  maj, min, n, ret, base;
+int  maj, min, n, ret;
 
 if (fd == -1 || device == NULL)
 return -EINVAL;
@@ -3886,11 +3882,7 @@ drm_public int drmGetDevice2(int fd, uin
 return -EINVAL;
 };
 
-base = drmGetMinorBase(node_type);
-if (base < 0)
-return -EINVAL;
-
-n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
+n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min);
 if (n == -1 || n >= PATH_MAX)
   return -errno;
 if (stat(node, ))
@@ -4110,7 +4102,7 @@ drm_public char *drmGetDeviceNameFromFd2
 char node[PATH_MAX + 1];
 const char  *dev_name;
 int  node_type;
-int  maj, min, n, base;
+int  maj, min, n;
 
 if (fstat(fd, ))
 return NULL;
@@ -4139,11 +4131,7 @@ drm_public char *drmGetDeviceNameFromFd2
 return NULL;
 };
 
-base = drmGetMinorBase(node_type);
-if (base < 0)
-return NULL;
-
-n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
+n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min);
 if (n == -1 || n >= PATH_MAX)
   return NULL;
 



acpi_loadtables(): do not assume rsdt exists

2019-05-11 Thread Lawrence Teo
This makes acpi_loadtables() ensure that rsdp->rsdp_rsdt exists before
attempting to to use it.

ok?


Index: acpi.c
===
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.365
diff -u -p -r1.365 acpi.c
--- acpi.c  11 May 2019 14:59:52 -  1.365
+++ acpi.c  12 May 2019 01:36:26 -
@@ -1363,7 +1363,7 @@ acpi_loadtables(struct acpi_softc *sc, s
NULL, 1);
 
free(sdt, M_DEVBUF, sizeof(*sdt) + len);
-   } else {
+   } else if (rsdp->rsdp_rsdt) {
struct acpi_rsdt *rsdt;
 
sdt = acpi_maptable(sc, rsdp->rsdp_rsdt, NULL, NULL, NULL, 0);
@@ -1382,6 +1382,9 @@ acpi_loadtables(struct acpi_softc *sc, s
NULL, 1);
 
free(sdt, M_DEVBUF, sizeof(*sdt) + len);
+   } else {
+   printf("couldn't find xsdt or rsdt\n");
+   return (ENOMEM);
}
 
return (0);



Re: sys_pledgepid() clean patch; comments?

2019-05-11 Thread Theo de Raadt
I disagree strongly with the direction.

Processes should follow the promises previous code made.

Developers should be "mindful" of their program's rules & model, if
they can't design properly and keep the situation in their head
in a 'static fashion', they don't stand a chance in hell of doing
this work in a 'dynamic fashion'

Noone should writing code which programatically 'studies the situation'
and makes dynamic decisions.

Furthermore, the pledge made by one program is an internal secret,
noone needs to inspect it.

This proposal is not going anywhere.



Andy Seniuk  wrote:

> Hello once again,
> 
> I have CC'd the original developers of tame/pledge; hope that is
> not in violation of etiquette?  This is my last post on this
> subject (or to any devs emails) if interest remains cool, but
> it deserves a fair shot, and after all, 500 hours is nothing
> to sneeze at!
> 
> These non-invasive additions apply cleanly to the latest code of the
> three affected source files.  I admit I am still running -current
> from mid-April, so I can't test it with these latest files, but the
> only change since my mid-April versions was to syscalls.master, and
> merged easily.
> 
> https://fremissant.net/pledge
> 
> This doesn't include patches to insert into , but it's
> sufficient for the present, so that pledge(1) can run at full
> capabilities for anyone who has the patched kernel.  Also, the
> pledge.2 mdoc patch is not included; but is available at that URL.
> 
> I don't think the patch is too long to include on tech@?
> Copied below.
> 
> The future of pledge(1) depends on your decision.
> 
> Thanks for your consideration,
> Andy.
> 
> Index: sys/kern/kern_pledge.c
> ===
> RCS file: /cvs/src/sys/kern/kern_pledge.c,v
> retrieving revision 1.251
> diff -u -p -r1.251 kern_pledge.c
> --- sys/kern/kern_pledge.c14 Feb 2019 15:41:47 -  1.251
> +++ sys/kern/kern_pledge.c11 May 2019 23:50:24 -
> @@ -233,6 +233,11 @@ const uint64_t pledge_syscalls[SYS_MAXSY
>  
>   [SYS_wait4] = PLEDGE_STDIO,
>  
> + [SYS_pledgepid] = PLEDGE_ALWAYS,
> +#if 0
> + [SYS_pledgepid] = PLEDGE_PROC,/* if choose this, move it down */
> +#endif
> +
>   /*
>* Can kill self with "stdio".  Killing another pid
>* requires "proc"
> @@ -500,6 +512,219 @@ sys_pledge(struct proc *p, void *v, regi
>   pr->ps_execpledge = execpromises;
>   pr->ps_flags |= PS_EXECPLEDGE;
>   }
> + return (0);
> +}
> +
> +/*
> + * To query, PLEDGEPID_QUERY opts bit must be set, and results are
> + * returned through copyout() to the pbits/epbits pointers.
> + * To set/drop [exec]promises, set opts PLEDGEPID_SET/DROP_[E]PROMS;
> + * the promise data are read from [e]pbits.
> + * It is permissible to combine query and set/drop.
> + * Query only affects the components (pbits/epbits) which were
> + * passed non-NULL.  Passing NULL with set/drop causes current
> + * pledge state in that component to remain unchanged.
> + * Caveat: query destructively overwrites userland data pointed to
> + * by pbits/epbits (when not NULL).
> + * -
> + * [ based on sys_pledge(), sys/kern/kern_sig.c:cansignal(),sys_kill() ]
> + */
> +int
> +sys_pledgepid(struct proc *caller_p, void *v, register_t *retval)
> +{
> + struct sys_pledgepid_args /* {
> + syscallarg(pid_t)pid;
> + syscallarg(uint32_t)opts;
> + syscallarg(uint64_t *)pbits;
> + syscallarg(uint64_t *)epbits;
> + syscallarg(const void *)aux;
> + } */*uap = v;
> + uint32_t opts = SCARG(uap, opts);
> + uint64_t u64tmp, *pbits = NULL, *epbits = NULL;
> + struct process *caller_pr = caller_p->p_p;
> + struct process *target_pr;  /* will be proc. corresp. to pid arg. */
> + pid_t pid_caller = caller_pr->ps_pid;
> + pid_t pid_target = SCARG(uap, pid);
> + /* see kern_sig.c:cansignal() */
> + struct ucred *caller_p_uc = caller_p->p_ucred;
> +  /* ...and not caller_pr->ps_ucred... */
> + struct ucred *target_pr_uc;  /* will use (*process)->ps_ucred */
> + int empowered = 0;
> + int error;
> +
> + /*
> +  * If caller is under pledge, and pid argument is not that of
> +  * the caller (or 0), fail immediately unless hold "proc" promise.
> +  */
> + if ((error = pledge_kill(caller_p, pid_target)) != 0)
> + return (error);
> +
> + if (pid_target < 0)
> + return (EINVAL);
> +
> + if (pid_target == 0) {
> + pid_target = pid_caller;
> + target_pr = caller_pr;
> + } else if((target_pr = prfind(pid_target)) == NULL) {
> + if ((target_pr = zombiefind(pid_target)) == NULL)
> + return (ESRCH);
> + else {
> + /*
> +  * Let it go ahead and try to act on the zombie; if
> +  * it's 

sys_pledgepid() clean patch; comments?

2019-05-11 Thread Andy Seniuk
Hello once again,

I have CC'd the original developers of tame/pledge; hope that is
not in violation of etiquette?  This is my last post on this
subject (or to any devs emails) if interest remains cool, but
it deserves a fair shot, and after all, 500 hours is nothing
to sneeze at!

These non-invasive additions apply cleanly to the latest code of the
three affected source files.  I admit I am still running -current
from mid-April, so I can't test it with these latest files, but the
only change since my mid-April versions was to syscalls.master, and
merged easily.

https://fremissant.net/pledge

This doesn't include patches to insert into , but it's
sufficient for the present, so that pledge(1) can run at full
capabilities for anyone who has the patched kernel.  Also, the
pledge.2 mdoc patch is not included; but is available at that URL.

I don't think the patch is too long to include on tech@?
Copied below.

The future of pledge(1) depends on your decision.

Thanks for your consideration,
Andy.

Index: sys/kern/kern_pledge.c
===
RCS file: /cvs/src/sys/kern/kern_pledge.c,v
retrieving revision 1.251
diff -u -p -r1.251 kern_pledge.c
--- sys/kern/kern_pledge.c  14 Feb 2019 15:41:47 -  1.251
+++ sys/kern/kern_pledge.c  11 May 2019 23:50:24 -
@@ -233,6 +233,11 @@ const uint64_t pledge_syscalls[SYS_MAXSY
 
[SYS_wait4] = PLEDGE_STDIO,
 
+   [SYS_pledgepid] = PLEDGE_ALWAYS,
+#if 0
+   [SYS_pledgepid] = PLEDGE_PROC,/* if choose this, move it down */
+#endif
+
/*
 * Can kill self with "stdio".  Killing another pid
 * requires "proc"
@@ -500,6 +512,219 @@ sys_pledge(struct proc *p, void *v, regi
pr->ps_execpledge = execpromises;
pr->ps_flags |= PS_EXECPLEDGE;
}
+   return (0);
+}
+
+/*
+ * To query, PLEDGEPID_QUERY opts bit must be set, and results are
+ * returned through copyout() to the pbits/epbits pointers.
+ * To set/drop [exec]promises, set opts PLEDGEPID_SET/DROP_[E]PROMS;
+ * the promise data are read from [e]pbits.
+ * It is permissible to combine query and set/drop.
+ * Query only affects the components (pbits/epbits) which were
+ * passed non-NULL.  Passing NULL with set/drop causes current
+ * pledge state in that component to remain unchanged.
+ * Caveat: query destructively overwrites userland data pointed to
+ * by pbits/epbits (when not NULL).
+ * -
+ * [ based on sys_pledge(), sys/kern/kern_sig.c:cansignal(),sys_kill() ]
+ */
+int
+sys_pledgepid(struct proc *caller_p, void *v, register_t *retval)
+{
+   struct sys_pledgepid_args /* {
+   syscallarg(pid_t)pid;
+   syscallarg(uint32_t)opts;
+   syscallarg(uint64_t *)pbits;
+   syscallarg(uint64_t *)epbits;
+   syscallarg(const void *)aux;
+   } */*uap = v;
+   uint32_t opts = SCARG(uap, opts);
+   uint64_t u64tmp, *pbits = NULL, *epbits = NULL;
+   struct process *caller_pr = caller_p->p_p;
+   struct process *target_pr;  /* will be proc. corresp. to pid arg. */
+   pid_t pid_caller = caller_pr->ps_pid;
+   pid_t pid_target = SCARG(uap, pid);
+   /* see kern_sig.c:cansignal() */
+   struct ucred *caller_p_uc = caller_p->p_ucred;
+/* ...and not caller_pr->ps_ucred... */
+   struct ucred *target_pr_uc;  /* will use (*process)->ps_ucred */
+   int empowered = 0;
+   int error;
+
+   /*
+* If caller is under pledge, and pid argument is not that of
+* the caller (or 0), fail immediately unless hold "proc" promise.
+*/
+   if ((error = pledge_kill(caller_p, pid_target)) != 0)
+   return (error);
+
+   if (pid_target < 0)
+   return (EINVAL);
+
+   if (pid_target == 0) {
+   pid_target = pid_caller;
+   target_pr = caller_pr;
+   } else if((target_pr = prfind(pid_target)) == NULL) {
+   if ((target_pr = zombiefind(pid_target)) == NULL)
+   return (ESRCH);
+   else {
+   /*
+* Let it go ahead and try to act on the zombie; if
+* it's possible to pledge it down as requested, so
+* much the better, zombie or not. :)
+*/
+#if 0
+/* (This happens quite often when pledge(1) tries to set post-init promises
+ * on a command which finishes sooner than the default 400 ms delay.)
+ */
+   zombie = 1;
+   uprintf("pledgepid: warn: [%d] zombie\n", pid_target);
+#endif
+   }
+   }
+
+   target_pr_uc = target_pr->ps_ucred;
+
+   if (opts & (PLEDGEPID_SET_PROMS | PLEDGEPID_SET_EPROMS |
+   PLEDGEPID_DROP_PROMS | PLEDGEPID_DROP_EPROMS)) {
+   /* Copy them now, or query will stomp. */
+   if (SCARG(uap, pbits) != 

Better acpi(4) support

2019-05-11 Thread Mark Kettenis
We encountered a machine that used the "extended" gasio description of
the ACPI PM registers, which is something we currently don't support.
This diff adds such support and with this diff ACPI support gets
enabled and the machine powers off fine if you run "halt -p".

ok?


Index: dev/acpi/acpi.c
===
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.365
diff -u -p -r1.365 acpi.c
--- dev/acpi/acpi.c 11 May 2019 14:59:52 -  1.365
+++ dev/acpi/acpi.c 12 May 2019 01:27:26 -
@@ -1575,6 +1575,7 @@ acpi_write_pmreg(struct acpi_softc *sc, 
 void
 acpi_map_pmregs(struct acpi_softc *sc)
 {
+   struct acpi_fadt *fadt = sc->sc_fadt;
bus_addr_t addr;
bus_size_t size, access;
const char *name;
@@ -1591,14 +1592,19 @@ acpi_map_pmregs(struct acpi_softc *sc)
case ACPIREG_SMICMD:
name = "smi";
size = access = 1;
-   addr = sc->sc_fadt->smi_cmd;
+   addr = fadt->smi_cmd;
break;
case ACPIREG_PM1A_STS:
case ACPIREG_PM1A_EN:
name = "pm1a_sts";
-   size = sc->sc_fadt->pm1_evt_len >> 1;
-   addr = sc->sc_fadt->pm1a_evt_blk;
-   access = 2;
+   size = fadt->pm1_evt_len >> 1;
+   if (fadt->pm1a_evt_blk) {
+   addr = fadt->pm1a_evt_blk;
+   access = 2;
+   } else {
+   addr = fadt->x_pm1a_evt_blk.address;
+   access = 1 << fadt->x_pm1a_evt_blk.access_size;
+   }
if (reg == ACPIREG_PM1A_EN && addr) {
addr += size;
name = "pm1a_en";
@@ -1606,16 +1612,26 @@ acpi_map_pmregs(struct acpi_softc *sc)
break;
case ACPIREG_PM1A_CNT:
name = "pm1a_cnt";
-   size = sc->sc_fadt->pm1_cnt_len;
-   addr = sc->sc_fadt->pm1a_cnt_blk;
-   access = 2;
+   size = fadt->pm1_cnt_len;
+   if (fadt->pm1a_cnt_blk) {
+   addr = fadt->pm1a_cnt_blk;
+   access = 2;
+   } else {
+   addr = fadt->x_pm1a_cnt_blk.address;
+   access = 1 << fadt->x_pm1a_cnt_blk.access_size;
+   }
break;
case ACPIREG_PM1B_STS:
case ACPIREG_PM1B_EN:
name = "pm1b_sts";
-   size = sc->sc_fadt->pm1_evt_len >> 1;
-   addr = sc->sc_fadt->pm1b_evt_blk;
-   access = 2;
+   size = fadt->pm1_evt_len >> 1;
+   if (fadt->pm1b_evt_blk) {
+   addr = fadt->pm1b_evt_blk;
+   access = 2;
+   } else {
+   addr = fadt->x_pm1b_evt_blk.address;
+   access = 1 << fadt->x_pm1b_evt_blk.access_size;
+   }
if (reg == ACPIREG_PM1B_EN && addr) {
addr += size;
name = "pm1b_en";
@@ -1623,36 +1639,56 @@ acpi_map_pmregs(struct acpi_softc *sc)
break;
case ACPIREG_PM1B_CNT:
name = "pm1b_cnt";
-   size = sc->sc_fadt->pm1_cnt_len;
-   addr = sc->sc_fadt->pm1b_cnt_blk;
-   access = 2;
+   size = fadt->pm1_cnt_len;
+   if (fadt->pm1b_cnt_blk) {
+   addr = fadt->pm1b_cnt_blk;
+   access = 2;
+   } else {
+   addr = fadt->x_pm1b_cnt_blk.address;
+   access = 1 << fadt->x_pm1b_cnt_blk.access_size;
+   }
break;
case ACPIREG_PM2_CNT:
name = "pm2_cnt";
-   size = sc->sc_fadt->pm2_cnt_len;
-   addr = sc->sc_fadt->pm2_cnt_blk;
-   access = size;
+   size = fadt->pm2_cnt_len;
+   if (fadt->pm2_cnt_blk) {
+   addr = fadt->pm2_cnt_blk;
+   access = size;
+   } else {
+   addr = fadt->x_pm2_cnt_blk.address;
+   access = 1 << fadt->x_pm2_cnt_blk.access_size;
+  

Re: SCHED_LOCK vs 'struct proc'

2019-05-11 Thread Ian Sutton
On Sat, May 11, 2019 at 07:23:42PM -0400, Martin Pieuchot wrote:
> Document which fields are protected by the SCHED_LOCK(), ok?
> 
> Index: sys/proc.h
> ===
> RCS file: /cvs/src/sys/sys/proc.h,v
> retrieving revision 1.263
> diff -u -p -r1.263 proc.h
> --- sys/proc.h6 Jan 2019 12:59:45 -   1.263
> +++ sys/proc.h11 May 2019 23:21:57 -
> @@ -297,8 +297,12 @@ struct process {
>  struct kcov_dev;
>  struct lock_list_entry;
>  
> +/*
> + *  Locks used to protect struct members in this file:
> + *   s   scheduler lock
> + */
>  struct proc {
> - TAILQ_ENTRY(proc) p_runq;
> + TAILQ_ENTRY(proc) p_runq;   /* [s] current run/sleep queue */
>   LIST_ENTRY(proc) p_list;/* List of all threads. */
>  
>   struct  process *p_p;   /* The process of this thread. */
> @@ -314,7 +318,7 @@ struct proc {
>  
>   int p_flag; /* P_* flags. */
>   u_char  p_spare;/* unused */
> - charp_stat; /* S* process status. */
> + charp_stat; /* [s] S* process status. */
>   charp_pad1[1];
>   u_char  p_descfd;   /* if not 255, fdesc permits this fd */
>  
> @@ -328,17 +332,17 @@ struct proc {
>   longp_thrslpid; /* for thrsleep syscall */
>  
>   /* scheduling */
> - u_int   p_estcpu;/* Time averaged value of p_cpticks. */
> + u_int   p_estcpu;   /* [s] Time averaged val of p_cpticks */
>   int p_cpticks;   /* Ticks of cpu time. */
> - const volatile void *p_wchan;/* Sleep address. */
> + const volatile void *p_wchan;   /* [s] Sleep address. */
>   struct  timeout p_sleep_to;/* timeout for tsleep() */
> - const char *p_wmesg; /* Reason for sleep. */
> - fixpt_t p_pctcpu;/* %cpu for this thread */
> - u_int   p_slptime;   /* Time since last blocked. */
> + const char *p_wmesg;/* [s] Reason for sleep. */
> + fixpt_t p_pctcpu;   /* [s] %cpu for this thread */
> + u_int   p_slptime;  /* [s] Time since last blocked. */
>   u_int   p_uticks;   /* Statclock hits in user mode. */
>   u_int   p_sticks;   /* Statclock hits in system mode. */
>   u_int   p_iticks;   /* Statclock hits processing intr. */
> - struct  cpu_info * volatile p_cpu; /* CPU we're running on. */
> + struct  cpu_info * volatile p_cpu; /* [s] CPU we're running on. */
>  
>   struct  rusage p_ru;/* Statistics */
>   struct  tusage p_tu;/* accumulated times. */
> @@ -357,8 +361,8 @@ struct proc {
>   vaddr_t  p_spstart;
>   vaddr_t  p_spend;
>  
> - u_char  p_priority; /* Process priority. */
> - u_char  p_usrpri;   /* User-priority based on p_estcpu and ps_nice. 
> */
> + u_char  p_priority; /* [s] Process priority. */
> + u_char  p_usrpri;   /* [s] User-prio based on p_estcpu & ps_nice. */
>   int p_pledge_syscall;   /* Cache of current syscall */
>  
>   struct  ucred *p_ucred; /* cached credentials */
>

I've checked the [s]-marked members, this is correct from my point of
view

ok ians@



Re: SCHED_LOCK vs 'struct proc'

2019-05-11 Thread Amit Kulkarni
On Sat, May 11, 2019 at 6:29 PM Martin Pieuchot  wrote:
>
> Document which fields are protected by the SCHED_LOCK(), ok?
>
> Index: sys/proc.h
> ===
> RCS file: /cvs/src/sys/sys/proc.h,v
> retrieving revision 1.263
> diff -u -p -r1.263 proc.h
> --- sys/proc.h  6 Jan 2019 12:59:45 -   1.263
> +++ sys/proc.h  11 May 2019 23:21:57 -
> @@ -297,8 +297,12 @@ struct process {
>  struct kcov_dev;
>  struct lock_list_entry;
>
> +/*
> + *  Locks used to protect struct members in this file:
> + * s   scheduler lock
> + */
>  struct proc {
> -   TAILQ_ENTRY(proc) p_runq;
> +   TAILQ_ENTRY(proc) p_runq;   /* [s] current run/sleep queue */
> LIST_ENTRY(proc) p_list;/* List of all threads. */
>
> struct  process *p_p;   /* The process of this thread. */
> @@ -314,7 +318,7 @@ struct proc {
>
> int p_flag; /* P_* flags. */
> u_char  p_spare;/* unused */
> -   charp_stat; /* S* process status. */
> +   charp_stat; /* [s] S* process status. */
> charp_pad1[1];
> u_char  p_descfd;   /* if not 255, fdesc permits this fd 
> */
>
> @@ -328,17 +332,17 @@ struct proc {
> longp_thrslpid; /* for thrsleep syscall */
>
> /* scheduling */
> -   u_int   p_estcpu;/* Time averaged value of p_cpticks. */
> +   u_int   p_estcpu;   /* [s] Time averaged val of p_cpticks 
> */
> int p_cpticks;   /* Ticks of cpu time. */
> -   const volatile void *p_wchan;/* Sleep address. */
> +   const volatile void *p_wchan;   /* [s] Sleep address. */
> struct  timeout p_sleep_to;/* timeout for tsleep() */
> -   const char *p_wmesg; /* Reason for sleep. */
> -   fixpt_t p_pctcpu;/* %cpu for this thread */
> -   u_int   p_slptime;   /* Time since last blocked. */
> +   const char *p_wmesg;/* [s] Reason for sleep. */
> +   fixpt_t p_pctcpu;   /* [s] %cpu for this thread */
> +   u_int   p_slptime;  /* [s] Time since last blocked. */

Thanks for this diff, it is pretty useful for anyone reading SCHED_LOCK'd code.

Can you please modify description for p_slptime?
 /* [s] Time since last run (in secs). */

as p_slptime is reset to 0 in setrunnable() in sched_bsd.

> u_int   p_uticks;   /* Statclock hits in user mode. */
> u_int   p_sticks;   /* Statclock hits in system mode. */
> u_int   p_iticks;   /* Statclock hits processing intr. */
> -   struct  cpu_info * volatile p_cpu; /* CPU we're running on. */
> +   struct  cpu_info * volatile p_cpu; /* [s] CPU we're running on. */
>
> struct  rusage p_ru;/* Statistics */
> struct  tusage p_tu;/* accumulated times. */
> @@ -357,8 +361,8 @@ struct proc {
> vaddr_t  p_spstart;
> vaddr_t  p_spend;
>
> -   u_char  p_priority; /* Process priority. */
> -   u_char  p_usrpri;   /* User-priority based on p_estcpu and 
> ps_nice. */
> +   u_char  p_priority; /* [s] Process priority. */
> +   u_char  p_usrpri;   /* [s] User-prio based on p_estcpu & ps_nice. 
> */
> int p_pledge_syscall;   /* Cache of current syscall */
>
> struct  ucred *p_ucred; /* cached credentials */
>



SCHED_LOCK vs 'struct proc'

2019-05-11 Thread Martin Pieuchot
Document which fields are protected by the SCHED_LOCK(), ok?

Index: sys/proc.h
===
RCS file: /cvs/src/sys/sys/proc.h,v
retrieving revision 1.263
diff -u -p -r1.263 proc.h
--- sys/proc.h  6 Jan 2019 12:59:45 -   1.263
+++ sys/proc.h  11 May 2019 23:21:57 -
@@ -297,8 +297,12 @@ struct process {
 struct kcov_dev;
 struct lock_list_entry;
 
+/*
+ *  Locks used to protect struct members in this file:
+ * s   scheduler lock
+ */
 struct proc {
-   TAILQ_ENTRY(proc) p_runq;
+   TAILQ_ENTRY(proc) p_runq;   /* [s] current run/sleep queue */
LIST_ENTRY(proc) p_list;/* List of all threads. */
 
struct  process *p_p;   /* The process of this thread. */
@@ -314,7 +318,7 @@ struct proc {
 
int p_flag; /* P_* flags. */
u_char  p_spare;/* unused */
-   charp_stat; /* S* process status. */
+   charp_stat; /* [s] S* process status. */
charp_pad1[1];
u_char  p_descfd;   /* if not 255, fdesc permits this fd */
 
@@ -328,17 +332,17 @@ struct proc {
longp_thrslpid; /* for thrsleep syscall */
 
/* scheduling */
-   u_int   p_estcpu;/* Time averaged value of p_cpticks. */
+   u_int   p_estcpu;   /* [s] Time averaged val of p_cpticks */
int p_cpticks;   /* Ticks of cpu time. */
-   const volatile void *p_wchan;/* Sleep address. */
+   const volatile void *p_wchan;   /* [s] Sleep address. */
struct  timeout p_sleep_to;/* timeout for tsleep() */
-   const char *p_wmesg; /* Reason for sleep. */
-   fixpt_t p_pctcpu;/* %cpu for this thread */
-   u_int   p_slptime;   /* Time since last blocked. */
+   const char *p_wmesg;/* [s] Reason for sleep. */
+   fixpt_t p_pctcpu;   /* [s] %cpu for this thread */
+   u_int   p_slptime;  /* [s] Time since last blocked. */
u_int   p_uticks;   /* Statclock hits in user mode. */
u_int   p_sticks;   /* Statclock hits in system mode. */
u_int   p_iticks;   /* Statclock hits processing intr. */
-   struct  cpu_info * volatile p_cpu; /* CPU we're running on. */
+   struct  cpu_info * volatile p_cpu; /* [s] CPU we're running on. */
 
struct  rusage p_ru;/* Statistics */
struct  tusage p_tu;/* accumulated times. */
@@ -357,8 +361,8 @@ struct proc {
vaddr_t  p_spstart;
vaddr_t  p_spend;
 
-   u_char  p_priority; /* Process priority. */
-   u_char  p_usrpri;   /* User-priority based on p_estcpu and ps_nice. 
*/
+   u_char  p_priority; /* [s] Process priority. */
+   u_char  p_usrpri;   /* [s] User-prio based on p_estcpu & ps_nice. */
int p_pledge_syscall;   /* Cache of current syscall */
 
struct  ucred *p_ucred; /* cached credentials */



show driver name on scan debug lines

2019-05-11 Thread Stefan Sperling
Watching scan debug output from multiple drivers at once is
highly confusing without this...

diff 017348fd9e151db65e509e6fb577f24587e25b0f /usr/src
blob - 6aeb14832608d36c839e855b4193418ffb6f7ce0
file + sys/net80211/ieee80211_node.c
--- sys/net80211/ieee80211_node.c
+++ sys/net80211/ieee80211_node.c
@@ -1063,7 +1063,7 @@ ieee80211_match_bss(struct ieee80211com *ic, struct ie
}
 
if (ic->ic_if.if_flags & IFF_DEBUG) {
-   printf(" %c %s%c", fail ? '-' : '+',
+   printf("%s: %c %s%c", ic->ic_if.if_xname, fail ? '-' : '+',
ether_sprintf(ni->ni_bssid),
fail & 0x20 ? '!' : ' ');
printf(" %3d%c", ieee80211_chan2ieee(ic, ni->ni_chan),



Re: fix tcpdump localtime caching

2019-05-11 Thread Holger Mikolon
> The variables could have more meaningful names, also the reuse of
> variable "gt" looks hackish, but the current code looks correct to me.
> 
> Does the diff below make things clearer?

It does. After reading the current code again a few times, it is
as well clear. Incredible how I couldn't see it before.
My apologies! And many thanks for the helpful replies to you and Otto!

Holger

> 
> --- privsep.c.~1.53.~ Sat May 11 14:17:40 2019
> +++ privsep.c Sat May 11 14:20:30 2019
> @@ -724,10 +724,12 @@ struct  tm *
>  priv_localtime(const time_t *t)
>  {
>   static struct tm lt, gt0;
> - static struct tm *gt = NULL;
>   static char zone[PATH_MAX];
> + static int cached = 0;
>  
> - if (gt != NULL) {
> + if (cached) {
> + struct tm *gt;
> +
>   gt = gmtime(t);
>   gt0.tm_sec = gt->tm_sec;
>   gt0.tm_zone = gt->tm_zone;
> @@ -749,7 +751,7 @@ priv_localtime(const time_t *t)
>   lt.tm_zone = NULL;
>  
>   gt0.tm_zone = NULL;
> - gt = 
> + cached = 1;
>  
>   return 
>  }
> 
> -- 
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: ld.so speedup (part 2)

2019-05-11 Thread Philip Guenther
On Tue, 7 May 2019, Jeremie Courreges-Anglas wrote:
> On Sat, Apr 27 2019, Nathanael Rensen  
> wrote:
> > The diff below speeds up ld.so library intialisation where the 
> > dependency tree is broad and deep, such as samba's smbd which links 
> > over 100 libraries.
...
> As I told mpi@ earlier today, I think your changes are correct as is,
> and are good to be committed.  So this counts as an ok jca@.  But I'd
> expect other developers to chime in soon, maybe they'll spot something
> that I didn't.

drahn@ and I pulled on our ld.so waders and agreed it's good, so I've 
committed it with some tweaking to the #defines to make them 
self-explanatory and have contiguous bit-assignments.

Thank you for identifying this badly inefficient algorithm and spotting 
how easy it was to fix!


Philip Guenther



Re: cmdfile for config -ef

2019-05-11 Thread Benjamin Baier
On Sat, 11 May 2019 13:26:14 -0600
"Theo de Raadt"  wrote:

> Ted Unangst  wrote:
> 
> > Benjamin Baier wrote:
> > > On Sat, 11 May 2019 11:18:02 -0400
> > > "Ted Unangst"  wrote:
> > > 
> > > > This adds a new option to config, -c cmdfile, that allows reading 
> > > > commands
> > > > from a file instead of stdin. This makes it easier to script.
> > > 
> > > Interesting. Can the cmdfile be /bsd ?
> > > So something like config -u but without the need of /dev/mem ?
> > 
> > No, the intended use case is not to copy options between kernels, but to 
> > apply
> > a consistent set of changes after linking.
> 
> @ boot-time, /etc/rc kernel relink script
>   KARL links a new kernel
>   apply config -e changes
>   install
>   hash it

I do realize that it's a polished version of what I wrote yesterday.
https://marc.info/?l=openbsd-misc=155751021025538=2
It just made me think that it may be possible without yet another config file.

Just thinking out loud, do carry on...



Re: cmdfile for config -ef

2019-05-11 Thread Theo de Raadt
Ted Unangst  wrote:

> Benjamin Baier wrote:
> > On Sat, 11 May 2019 11:18:02 -0400
> > "Ted Unangst"  wrote:
> > 
> > > This adds a new option to config, -c cmdfile, that allows reading commands
> > > from a file instead of stdin. This makes it easier to script.
> > 
> > Interesting. Can the cmdfile be /bsd ?
> > So something like config -u but without the need of /dev/mem ?
> 
> No, the intended use case is not to copy options between kernels, but to apply
> a consistent set of changes after linking.

@ boot-time, /etc/rc kernel relink script
KARL links a new kernel
apply config -e changes
install
hash it



Re: cmdfile for config -ef

2019-05-11 Thread Ted Unangst
Benjamin Baier wrote:
> On Sat, 11 May 2019 11:18:02 -0400
> "Ted Unangst"  wrote:
> 
> > This adds a new option to config, -c cmdfile, that allows reading commands
> > from a file instead of stdin. This makes it easier to script.
> 
> Interesting. Can the cmdfile be /bsd ?
> So something like config -u but without the need of /dev/mem ?

No, the intended use case is not to copy options between kernels, but to apply
a consistent set of changes after linking.



Re: fix tcpdump localtime caching

2019-05-11 Thread Otto Moerbeek
On Fri, May 10, 2019 at 03:25:17PM +0200, Holger Mikolon wrote:

> The comment above priv_localtime() says, the obtained localtime (from the 
> privileged process) is cached for about one minute. However, since the 
> according if statement compares the wrong variable, the caching doesn't 
> happen. This bug is there since the very first file version (from 15+ 
> years ago).
> 
> Regards
> Holger

No, this is not correct.

The point is that the code remembers the timezone corrected value so
it does not have to consult the privileged process for it all the time.

Once the timezone corrected date and hour and mintue are known, only
seconds are updated via a call to gmtime().

-Otto

> 
> 
> Index: usr.sbin/tcpdump/privsep.c
> ===
> RCS file: /cvs/src/usr.sbin/tcpdump/privsep.c,v
> retrieving revision 1.53
> diff -u -p -u -r1.53 privsep.c
> --- usr.sbin/tcpdump/privsep.c18 Mar 2019 00:09:22 -  1.53
> +++ usr.sbin/tcpdump/privsep.c10 May 2019 13:17:42 -
> @@ -727,7 +727,7 @@ priv_localtime(const time_t *t)
>   static struct tm *gt = NULL;
>   static char zone[PATH_MAX];
>  
> - if (gt != NULL) {
> + if (t != NULL) {
>   gt = gmtime(t);
>   gt0.tm_sec = gt->tm_sec;
>   gt0.tm_zone = gt->tm_zone;
> 



Re: fix tcpdump localtime caching

2019-05-11 Thread Jeremie Courreges-Anglas
On Fri, May 10 2019, Holger Mikolon  wrote:
> The comment above priv_localtime() says, the obtained localtime (from the 
> privileged process) is cached for about one minute. However, since the 
> according if statement compares the wrong variable, the caching doesn't 
> happen. This bug is there since the very first file version (from 15+ 
> years ago).

The variables could have more meaningful names, also the reuse of
variable "gt" looks hackish, but the current code looks correct to me.

Does the diff below make things clearer?


--- privsep.c.~1.53.~   Sat May 11 14:17:40 2019
+++ privsep.c   Sat May 11 14:20:30 2019
@@ -724,10 +724,12 @@ structtm *
 priv_localtime(const time_t *t)
 {
static struct tm lt, gt0;
-   static struct tm *gt = NULL;
static char zone[PATH_MAX];
+   static int cached = 0;
 
-   if (gt != NULL) {
+   if (cached) {
+   struct tm *gt;
+
gt = gmtime(t);
gt0.tm_sec = gt->tm_sec;
gt0.tm_zone = gt->tm_zone;
@@ -749,7 +751,7 @@ priv_localtime(const time_t *t)
lt.tm_zone = NULL;
 
gt0.tm_zone = NULL;
-   gt = 
+   cached = 1;
 
return 
 }

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: cmdfile for config -ef

2019-05-11 Thread Benjamin Baier
On Sat, 11 May 2019 11:18:02 -0400
"Ted Unangst"  wrote:

> This adds a new option to config, -c cmdfile, that allows reading commands
> from a file instead of stdin. This makes it easier to script.

Interesting. Can the cmdfile be /bsd ?
So something like config -u but without the need of /dev/mem ?


> Index: config.8
> ===
> RCS file: /home/cvs/src/usr.sbin/config/config.8,v
> retrieving revision 1.66
> diff -u -p -r1.66 config.8
> --- config.8  25 Apr 2018 12:01:11 -  1.66
> +++ config.8  11 May 2019 15:16:45 -
> @@ -43,6 +43,7 @@
>  .Op Fl s Ar srcdir
>  .Op Ar config-file
>  .Nm config
> +.Op Fl c Ar cmdfile
>  .Op Fl u
>  .Op Fl f | o Ar outfile
>  .Fl e
> @@ -103,6 +104,9 @@ directories above the build directory).
>  .Pp
>  For kernel modification, the options are as follows:
>  .Bl -tag -width Ds
> +.It Fl c Ar cmdfile
> +Read commands from the specified file instead of the standard input.
> +Save and quit automatically when the end of file is reached.
>  .It Fl e
>  Allows the modification of kernel device configuration (see
>  .Xr boot_config 8 ) .
> Index: main.c
> ===
> RCS file: /home/cvs/src/usr.sbin/config/main.c,v
> retrieving revision 1.59
> diff -u -p -r1.59 main.c
> --- main.c22 Jun 2017 15:57:16 -  1.59
> +++ main.c11 May 2019 15:00:34 -
> @@ -82,7 +82,7 @@ usage(void)
>  
>   fprintf(stderr,
>   "usage: %s [-p] [-b builddir] [-s srcdir] [config-file]\n"
> - "   %s [-u] [-f | -o outfile] -e infile\n",
> + "   %s [-c cmdfile] [-u] [-f | -o outfile] -e infile\n",
>   __progname, __progname);
>  
>   exit(1);
> @@ -92,6 +92,7 @@ int pflag = 0;
>  char *sflag = NULL;
>  char *bflag = NULL;
>  char *startdir;
> +char *cmdfile;
>  
>  int
>  main(int argc, char *argv[])
> @@ -105,9 +106,11 @@ main(int argc, char *argv[])
>   err(1, "pledge");
>  
>   pflag = eflag = uflag = fflag = 0;
> - while ((ch = getopt(argc, argv, "epfb:s:o:u")) != -1) {
> + while ((ch = getopt(argc, argv, "c:epfb:s:o:u")) != -1) {
>   switch (ch) {
> -
> + case 'c':
> + cmdfile = optarg;
> + break;
>   case 'o':
>   outfile = optarg;
>   break;
> Index: misc.c
> ===
> RCS file: /home/cvs/src/usr.sbin/config/misc.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 misc.c
> --- misc.c2 Oct 2011 22:20:49 -   1.9
> +++ misc.c11 May 2019 15:08:56 -
> @@ -38,13 +38,10 @@
>  extern int verbose;
>  
>  int
> -ask_cmd(cmd_t *cmd)
> +parse_cmd(cmd_t *cmd, char *lbuf)
>  {
> - char lbuf[100], *cp, *buf;
> + char *cp, *buf;
>  
> - /* Get input */
> - if (fgets(lbuf, sizeof lbuf, stdin) == NULL)
> - errx(1, "eof");
>   lbuf[strcspn(lbuf, "\n")] = '\0';
>   if (verbose)
>   printf("%s\n", lbuf);
> @@ -59,6 +56,17 @@ ask_cmd(cmd_t *cmd)
>   strlcpy(cmd->args, buf, sizeof cmd->args);
>  
>   return (0);
> +}
> +
> +int
> +ask_cmd(cmd_t *cmd)
> +{
> + char lbuf[100];
> +
> + /* Get input */
> + if (fgets(lbuf, sizeof lbuf, stdin) == NULL)
> + errx(1, "eof");
> + return parse_cmd(cmd, lbuf);
>  }
>  
>  int
> Index: misc.h
> ===
> RCS file: /home/cvs/src/usr.sbin/config/misc.h,v
> retrieving revision 1.4
> diff -u -p -r1.4 misc.h
> --- misc.h3 Jun 2003 00:52:35 -   1.4
> +++ misc.h11 May 2019 15:10:04 -
> @@ -33,6 +33,7 @@
>  
>  /* Prototypes */
>  int ask_cmd(cmd_t *);
> +int parse_cmd(cmd_t *, char *);
>  int ask_yn(const char *);
>  
>  #endif /* _MISC_H */
> Index: ukcutil.c
> ===
> RCS file: /home/cvs/src/usr.sbin/config/ukcutil.c,v
> retrieving revision 1.23
> diff -u -p -r1.23 ukcutil.c
> --- ukcutil.c 27 Sep 2017 15:14:52 -  1.23
> +++ ukcutil.c 11 May 2019 15:14:25 -
> @@ -29,6 +29,7 @@
>  #include 
>  
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -1295,13 +1296,61 @@ add_history(int devno, short unit, short
>  }
>  
>  int
> +config_fromfile(const char *cmdfile) {
> + FILE *fp;
> + cmd_t cmd;
> + int i;
> +
> + fp = fopen(cmdfile, "r");
> + if (fp == NULL)
> + err(1, "open %s", cmdfile);
> +
> + /* Set up command table pointer */
> + cmd.table = cmd_table;
> +
> + /* Edit cycle */
> + do {
> + char lbuf[100];
> +
> + /* Get input */
> + if (fgets(lbuf, sizeof lbuf, fp) == NULL)
> + break;
> + parse_cmd(, lbuf);
> +
> + if (cmd.cmd[0] == '\0')
> + continue;
> + for 

Re: route(8): -n means numeric for default too

2019-05-11 Thread Denis Fondras
On Sat, May 11, 2019 at 01:15:16PM -0400, Alexander Bluhm wrote:
> What is wrong with "default"?  Why is "0.0.0.0/0" and "::/0" better?
> 

Nothing wrong per-se. I was comparing the output of "bgpctl sh fib" and "route
show" when I noticed this.



Re: route(8): -n means numeric for default too

2019-05-11 Thread Alexander Bluhm
On Sat, May 11, 2019 at 07:03:34PM +0200, Denis Fondras wrote:
> When using "route -n", also print numeric value for default route.

I use -n to avoid DNS lookups.  "default" does not do that.

So I do not see the benefit of this change.  It has been that way
for ever without harm.  New behavior would be different.  It breaks
peoples expectations and possibly some scripts.

What is wrong with "default"?  Why is "0.0.0.0/0" and "::/0" better?

bluhm



route(8): -n means numeric for default too

2019-05-11 Thread Denis Fondras
When using "route -n", also print numeric value for default route.

Before :

[denis@jig-ai] route -n show -inet6
Routing tables

Internet6:
DestinationGatewayFlags   Refs  
Use   Mtu  Prio Iface
default2a00:6060:1::1 UGS2  
   1549 - 8 em0  
::/96  ::1UGRS   0  
  0 32768 8 lo0  
::1::1UHhl  10  
 20 32768 1 lo0  

After :

[denis@jig-ai] route -n show -inet6
Routing tables

Internet6:
DestinationGatewayFlags   Refs  
Use   Mtu  Prio Iface
::/0   2a00:6060:1::1 UGS2  
   1549 - 8 em0  
::/96  ::1UGRS   0  
  0 32768 8 lo0  
::1::1UHhl  10  
 20 32768 1 lo0  


Index: show.c
===
RCS file: /cvs/src/sbin/route/show.c,v
retrieving revision 1.114
diff -u -p -r1.114 show.c
--- show.c  31 Aug 2018 15:18:02 -  1.114
+++ show.c  11 May 2019 16:56:38 -
@@ -539,7 +539,7 @@ netname4(in_addr_t in, struct sockaddr_i
cp = hp->h_name;
}
if (in == INADDR_ANY && mask == INADDR_ANY)
-   cp = "default";
+   cp = nflag ? "0.0.0.0/0" : "default";
mbits = mask ? 33 - ffs(mask) : 0;
in = ntohl(in);
if (cp)
@@ -636,7 +636,7 @@ netname6(struct sockaddr_in6 *sa6, struc
masklen = 128;
 
if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(_addr))
-   return ("default");
+   return (nflag ? "::/0" : "default");
 
if (illegal)
warnx("illegal prefixlen");



Re: pthread signal delivery

2019-05-11 Thread Alexander Bluhm
On Thu, May 09, 2019 at 11:01:13PM -0400, Alexander Bluhm wrote:
> When killing a process, the signal is handled by any thread that
> does not block the signal.  If all threads block the signal, we
> currently deliver it to the main thread.  This does not conform to
> POSIX.  If any thread unblocks the signal, it should be delivered
> immediately to this thread.  We block it until the main thread
> unblocks.
>
> I see the problem as some tests of posixtestsuite hang.  Various
> people reported similar observations with multi threaded programs
> to me.
>
> Solution is to mark such signals at the process instead of one
> thread.  Then any thread can handle it later.  There is a XXX comment
> that suggests this behavior, NetBSD also does this.
>
> This diff survived a full regress run on i386.

I have written a regress test that has showed a bug I introdced.
In exit1() I have to clear pr->ps_siglist only when exiting the
main thread.

new diff, ok?

bluhm

Index: kern/exec_elf.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/exec_elf.c,v
retrieving revision 1.149
diff -u -p -r1.149 exec_elf.c
--- kern/exec_elf.c 9 May 2019 22:25:42 -   1.149
+++ kern/exec_elf.c 10 May 2019 02:39:07 -
@@ -1224,7 +1224,7 @@ coredump_notes_elf(struct proc *p, void
cpi.cpi_signo = p->p_sisig;
cpi.cpi_sigcode = p->p_sicode;

-   cpi.cpi_sigpend = p->p_siglist;
+   cpi.cpi_sigpend = p->p_siglist | pr->ps_siglist;
cpi.cpi_sigmask = p->p_sigmask;
cpi.cpi_sigignore = pr->ps_sigacts->ps_sigignore;
cpi.cpi_sigcatch = pr->ps_sigacts->ps_sigcatch;
Index: kern/kern_exit.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/kern_exit.c,v
retrieving revision 1.173
diff -u -p -r1.173 kern_exit.c
--- kern/kern_exit.c23 Jan 2019 22:39:47 -  1.173
+++ kern/kern_exit.c11 May 2019 04:48:49 -
@@ -180,6 +180,8 @@ exit1(struct proc *p, int rv, int flags)
}
}
p->p_siglist = 0;
+   if ((p->p_flag & P_THREAD) == 0)
+   pr->ps_siglist = 0;

 #if NKCOV > 0
kcov_exit(p);
Index: kern/kern_sig.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/kern_sig.c,v
retrieving revision 1.229
diff -u -p -r1.229 kern_sig.c
--- kern/kern_sig.c 1 May 2019 06:26:42 -   1.229
+++ kern/kern_sig.c 11 May 2019 04:17:30 -
@@ -365,6 +365,7 @@ setsigvec(struct proc *p, int signum, st
if (sa->sa_handler == SIG_IGN ||
(sigprop[signum] & SA_IGNORE && sa->sa_handler == SIG_DFL)) {
atomic_clearbits_int(>p_siglist, bit);
+   atomic_clearbits_int(>p_p->ps_siglist, bit);
if (signum != SIGCONT)
ps->ps_sigignore |= bit;/* easier in psignal */
ps->ps_sigcatch &= ~bit;
@@ -419,6 +420,7 @@ execsigs(struct proc *p)
if (nc != SIGCONT)
ps->ps_sigignore |= mask;
atomic_clearbits_int(>p_siglist, mask);
+   atomic_clearbits_int(>p_p->ps_siglist, mask);
}
ps->ps_sigact[nc] = SIG_DFL;
}
@@ -472,7 +474,7 @@ int
 sys_sigpending(struct proc *p, void *v, register_t *retval)
 {

-   *retval = p->p_siglist;
+   *retval = p->p_siglist | p->p_p->ps_siglist;
return (0);
 }

@@ -875,7 +877,6 @@ psignal(struct proc *p, int signum)

 /*
  * type = SPROCESS process signal, can be diverted (sigwait())
- * XXX if blocked in all threads, mark as pending in struct process
  * type = STHREAD  thread signal, but should be propagated if unhandled
  * type = SPROPAGATED  propagated to this thread, so don't propagate again
  */
@@ -885,6 +886,7 @@ ptsignal(struct proc *p, int signum, enu
int s, prop;
sig_t action;
int mask;
+   int *siglist;
struct process *pr = p->p_p;
struct proc *q;
int wakeparent = 0;
@@ -907,7 +909,7 @@ ptsignal(struct proc *p, int signum, enu
if (pr->ps_flags & PS_COREDUMP && signum == SIGKILL) {
if (pr->ps_single != NULL)
p = pr->ps_single;
-   atomic_setbits_int(>p_siglist, mask);
+   atomic_setbits_int(>p_p->ps_siglist, mask);
return;
}

@@ -962,7 +964,6 @@ ptsignal(struct proc *p, int signum, enu
 */
if (pr->ps_flags & PS_TRACED) {
action = SIG_DFL;
-   atomic_setbits_int(>p_siglist, mask);
} else {
/*
 * If the signal is being ignored,
@@ -992,17 +993,23 @@ ptsignal(struct proc *p, int signum, enu
if 

net80211: fix userflags + stayauth

2019-05-11 Thread Stefan Sperling
This fixes ifconfig 'nwflags' hiddennwid and nobridge; these flags
currently overlap with other flags, such as the AUTO_JOIN flag and
hence can't be used.

While here, add another flag which makes the interface ignore deauth frames.

diff 63562686d340902505feb02c68d09c5d34652880 /usr/src
blob - adc7fa737fc2f734df37a6c286e0ff50ad36425c
file + sbin/ifconfig/ifconfig.8
--- sbin/ifconfig/ifconfig.8
+++ sbin/ifconfig/ifconfig.8
@@ -969,22 +969,32 @@ Show the list of currently configured auto-join networ
 Remove all networks in the list of auto-join networks.
 .It Cm nwflag Ar flag
 Set specified flag.
-The flag name can be either
-.Ql hidenwid
-or
-.Ql nobridge .
+The flag name can be:
+.Bl -tag -width tenletters
+.It hidenwid
 The
 .Ql hidenwid
 flag will hide the network ID (ESSID) in beacon frames when operating
 in Host AP mode.
 It will also prevent responses to probe requests with an unspecified
 network ID.
+.It nobridge
 The
 .Ql nobridge
 flag will disable the direct bridging of frames between associated
 nodes when operating in Host AP mode.
 Setting this flag will block and filter direct inter-station
 communications.
+.It stayauth
+The
+.Ql stayauth
+flag will cause the interface to ignore deauth frames from the
+access point.
+This flag should only be used on wifi networks which are being
+attacked with spoofed deauth frames.
+It breaks interoperability with spectrum management solutions and access
+points that perform band-steering of clients.
+.El
 .Pp
 Note that the
 .Ql hidenwid
diff 63562686d340902505feb02c68d09c5d34652880 /usr/src
blob - 1c863e788dca720c3666be6387d7ea812d7a937a
file + sys/net80211/ieee80211_input.c
--- sys/net80211/ieee80211_input.c
+++ sys/net80211/ieee80211_input.c
@@ -882,7 +882,7 @@ ieee80211_deliver_data(struct ieee80211com *ic, struct
m1 = NULL;
 #ifndef IEEE80211_STA_ONLY
if (ic->ic_opmode == IEEE80211_M_HOSTAP &&
-   !(ic->ic_flags & IEEE80211_F_NOBRIDGE) &&
+   !(ic->ic_userflags & IEEE80211_F_NOBRIDGE) &&
eh->ether_type != htons(ETHERTYPE_PAE)) {
struct ieee80211_node *ni1;
 
@@ -2418,7 +2418,9 @@ ieee80211_recv_deauth(struct ieee80211com *ic, struct 
case IEEE80211_M_STA: {
int bgscan = ((ic->ic_flags & IEEE80211_F_BGSCAN) &&
ic->ic_state == IEEE80211_S_RUN);
-   if (!bgscan) /* ignore deauth during bgscan */
+   int stay_auth = ((ic->ic_userflags & IEEE80211_F_STAYAUTH) &&
+   ic->ic_state >= IEEE80211_S_AUTH);
+   if (!(bgscan || stay_auth))
ieee80211_new_state(ic, IEEE80211_S_AUTH,
IEEE80211_FC0_SUBTYPE_DEAUTH);
}
blob - f9a7edff8968924fb609ef7b829682fba923ac55
file + sys/net80211/ieee80211_ioctl.c
--- sys/net80211/ieee80211_ioctl.c
+++ sys/net80211/ieee80211_ioctl.c
@@ -903,17 +903,17 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t
}
break;
case SIOCG80211FLAGS:
-   flags = ic->ic_flags;
+   flags = ic->ic_userflags;
 #ifndef IEEE80211_STA_ONLY
if (ic->ic_opmode != IEEE80211_M_HOSTAP)
 #endif
flags &= ~IEEE80211_F_HOSTAPMASK;
-   ifr->ifr_flags = flags >> IEEE80211_F_USERSHIFT;
+   ifr->ifr_flags = flags;
break;
case SIOCS80211FLAGS:
if ((error = suser(curproc)) != 0)
break;
-   flags = (u_int32_t)ifr->ifr_flags << IEEE80211_F_USERSHIFT;
+   flags = ifr->ifr_flags;
if (
 #ifndef IEEE80211_STA_ONLY
ic->ic_opmode != IEEE80211_M_HOSTAP &&
@@ -922,7 +922,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t
error = EINVAL;
break;
}
-   ic->ic_flags = (ic->ic_flags & ~IEEE80211_F_USERMASK) | flags;
+   ic->ic_userflags = flags;
error = ENETRESET;
break;
case SIOCADDMULTI:
blob - 69dbc52cbe8738b74669a4e85084512f8e0de5b3
file + sys/net80211/ieee80211_ioctl.h
--- sys/net80211/ieee80211_ioctl.h
+++ sys/net80211/ieee80211_ioctl.h
@@ -394,20 +394,21 @@ struct ieee80211_nodereq_all {
 #define SIOCG80211ALLNODES _IOWR('i', 214, struct ieee80211_nodereq_all)
 
 /* net80211 specific interface flags */
-#define IEEE80211_F_HIDENWID   0x1000  /* CONF: hidden ssid mode */
-#define IEEE80211_F_NOBRIDGE   0x2000  /* CONF: no internal bridging */
-#define IEEE80211_F_HOSTAPMASK 0x3000
-#define IEEE80211_F_USERSHIFT  28
-#define IEEE80211_F_USERBITS   "\20\01HIDENWID\02NOBRIDGE"
+#define IEEE80211_F_HIDENWID   0x0001  /* CONF: hidden ssid mode */
+#define IEEE80211_F_NOBRIDGE   0x0002  /* CONF: no internal bridging */
+#define IEEE80211_F_HOSTAPMASK 0x0003
+#define IEEE80211_F_STAYAUTH   0x0004  /* CONF: ignore deauth */

Re: iked(8): add support for IKEv2 Message Fragmentation

2019-05-11 Thread Tobias Heider
Hey,

I updated the diff to work with the recent fixes.
Currently next_pl is checked to be the encrypted payload after the IKE_SA_INIT
exchange, this also whitelists the new encrypted fragment payload.
Also ikev2_send_encrypted_fragments() now uses the new sa_msgid_current
instead of sa_msgid just like ikev2_msg_send_encrypt() does.

Ok?

Index: sbin/iked/config.c
===
RCS file: /mount/openbsd/cvs/src/sbin/iked/config.c,v
retrieving revision 1.49
diff -u -p -u -r1.49 config.c
--- sbin/iked/config.c  27 Nov 2017 18:39:35 -  1.49
+++ sbin/iked/config.c  11 May 2019 15:39:40 -
@@ -1,6 +1,7 @@
 /* $OpenBSD: config.c,v 1.49 2017/11/27 18:39:35 patrick Exp $ */
 
 /*
+ * Copyright (c) 2019 Tobias Heider 
  * Copyright (c) 2010-2013 Reyk Floeter 
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -94,12 +95,29 @@ config_free_kex(struct iked_kex *kex)
 }
 
 void
+config_free_fragments(struct iked_frag *frag)
+{
+   size_t i;
+
+   if (frag && frag->frag_arr) {
+   for (i = 0; i < frag->frag_total; i++) {
+   if (frag->frag_arr[i] != NULL)
+   free(frag->frag_arr[i]->frag_data);
+   free(frag->frag_arr[i]);
+   }
+   free(frag->frag_arr);
+   bzero(frag, sizeof(struct iked_frag));
+   }
+}
+
+void
 config_free_sa(struct iked *env, struct iked_sa *sa)
 {
timer_del(env, >sa_timer);
timer_del(env, >sa_keepalive);
timer_del(env, >sa_rekey);
 
+   config_free_fragments(>sa_fragments);
config_free_proposals(>sa_proposals, 0);
config_free_childsas(env, >sa_childsas, NULL, NULL);
sa_free_flows(env, >sa_flows);
@@ -834,6 +852,29 @@ config_getmobike(struct iked *env, struc
memcpy(, imsg->data, sizeof(boolval));
env->sc_mobike = boolval;
log_debug("%s: %smobike", __func__, env->sc_mobike ? "" : "no ");
+   return (0);
+}
+
+int
+config_setfragmentation(struct iked *env)
+{
+   unsigned int boolval;
+
+   boolval = env->sc_frag;
+   proc_compose(>sc_ps, PROC_IKEV2, IMSG_CTL_FRAGMENTATION,
+   , sizeof(boolval));
+   return (0);
+}
+
+int
+config_getfragmentation(struct iked *env, struct imsg *imsg)
+{
+   unsigned int boolval;
+
+   IMSG_SIZE_CHECK(imsg, );
+   memcpy(, imsg->data, sizeof(boolval));
+   env->sc_frag = boolval;
+   log_debug("%s: %sfragmentation", __func__, env->sc_frag ? "" : "no ");
return (0);
 }
 
Index: sbin/iked/iked.c
===
RCS file: /mount/openbsd/cvs/src/sbin/iked/iked.c,v
retrieving revision 1.36
diff -u -p -u -r1.36 iked.c
--- sbin/iked/iked.c27 Nov 2017 18:39:35 -  1.36
+++ sbin/iked/iked.c11 May 2019 15:39:40 -
@@ -1,6 +1,7 @@
 /* $OpenBSD: iked.c,v 1.36 2017/11/27 18:39:35 patrick Exp $   */
 
 /*
+ * Copyright (c) 2019 Tobias Heider 
  * Copyright (c) 2010-2013 Reyk Floeter 
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -251,6 +252,7 @@ parent_configure(struct iked *env)
fatal("pledge");
 
config_setmobike(env);
+   config_setfragmentation(env);
config_setcoupled(env, env->sc_decoupled ? 0 : 1);
config_setmode(env, env->sc_passive ? 1 : 0);
config_setocsp(env);
@@ -282,6 +284,7 @@ parent_reload(struct iked *env, int rese
config_setcompile(env, PROC_IKEV2);
 
config_setmobike(env);
+   config_setfragmentation(env);
config_setcoupled(env, env->sc_decoupled ? 0 : 1);
config_setmode(env, env->sc_passive ? 1 : 0);
config_setocsp(env);
Index: sbin/iked/iked.conf.5
===
RCS file: /mount/openbsd/cvs/src/sbin/iked/iked.conf.5,v
retrieving revision 1.54
diff -u -p -u -r1.54 iked.conf.5
--- sbin/iked/iked.conf.5   2 Apr 2019 09:42:55 -   1.54
+++ sbin/iked/iked.conf.5   11 May 2019 15:39:40 -
@@ -136,6 +136,12 @@ This is the default.
 .It Ic set decouple
 Don't load the negotiated SAs and flows from the kernel.
 This mode is only useful for testing and debugging.
+.It Ic set fragmentation
+Enable IKEv2 Message Fragmentation (RFC 7383) support.
+This allows IKEv2 to operate in environments that might block IP fragments.
+.It Ic set nofragmentation
+Disables IKEv2 Message Fragmentation support.
+This is the default.
 .It Ic set mobike
 Enable MOBIKE (RFC 4555) support.
 This is the default.
Index: sbin/iked/iked.h
===
RCS file: /mount/openbsd/cvs/src/sbin/iked/iked.h,v
retrieving revision 1.120
diff -u -p -u -r1.120 iked.h
--- sbin/iked/iked.h10 May 2019 15:02:17 -  1.120
+++ sbin/iked/iked.h11 May 2019 15:39:40 -

cmdfile for config -ef

2019-05-11 Thread Ted Unangst
This adds a new option to config, -c cmdfile, that allows reading commands
from a file instead of stdin. This makes it easier to script.


Index: config.8
===
RCS file: /home/cvs/src/usr.sbin/config/config.8,v
retrieving revision 1.66
diff -u -p -r1.66 config.8
--- config.825 Apr 2018 12:01:11 -  1.66
+++ config.811 May 2019 15:16:45 -
@@ -43,6 +43,7 @@
 .Op Fl s Ar srcdir
 .Op Ar config-file
 .Nm config
+.Op Fl c Ar cmdfile
 .Op Fl u
 .Op Fl f | o Ar outfile
 .Fl e
@@ -103,6 +104,9 @@ directories above the build directory).
 .Pp
 For kernel modification, the options are as follows:
 .Bl -tag -width Ds
+.It Fl c Ar cmdfile
+Read commands from the specified file instead of the standard input.
+Save and quit automatically when the end of file is reached.
 .It Fl e
 Allows the modification of kernel device configuration (see
 .Xr boot_config 8 ) .
Index: main.c
===
RCS file: /home/cvs/src/usr.sbin/config/main.c,v
retrieving revision 1.59
diff -u -p -r1.59 main.c
--- main.c  22 Jun 2017 15:57:16 -  1.59
+++ main.c  11 May 2019 15:00:34 -
@@ -82,7 +82,7 @@ usage(void)
 
fprintf(stderr,
"usage: %s [-p] [-b builddir] [-s srcdir] [config-file]\n"
-   "   %s [-u] [-f | -o outfile] -e infile\n",
+   "   %s [-c cmdfile] [-u] [-f | -o outfile] -e infile\n",
__progname, __progname);
 
exit(1);
@@ -92,6 +92,7 @@ int pflag = 0;
 char *sflag = NULL;
 char *bflag = NULL;
 char *startdir;
+char *cmdfile;
 
 int
 main(int argc, char *argv[])
@@ -105,9 +106,11 @@ main(int argc, char *argv[])
err(1, "pledge");
 
pflag = eflag = uflag = fflag = 0;
-   while ((ch = getopt(argc, argv, "epfb:s:o:u")) != -1) {
+   while ((ch = getopt(argc, argv, "c:epfb:s:o:u")) != -1) {
switch (ch) {
-
+   case 'c':
+   cmdfile = optarg;
+   break;
case 'o':
outfile = optarg;
break;
Index: misc.c
===
RCS file: /home/cvs/src/usr.sbin/config/misc.c,v
retrieving revision 1.9
diff -u -p -r1.9 misc.c
--- misc.c  2 Oct 2011 22:20:49 -   1.9
+++ misc.c  11 May 2019 15:08:56 -
@@ -38,13 +38,10 @@
 extern int verbose;
 
 int
-ask_cmd(cmd_t *cmd)
+parse_cmd(cmd_t *cmd, char *lbuf)
 {
-   char lbuf[100], *cp, *buf;
+   char *cp, *buf;
 
-   /* Get input */
-   if (fgets(lbuf, sizeof lbuf, stdin) == NULL)
-   errx(1, "eof");
lbuf[strcspn(lbuf, "\n")] = '\0';
if (verbose)
printf("%s\n", lbuf);
@@ -59,6 +56,17 @@ ask_cmd(cmd_t *cmd)
strlcpy(cmd->args, buf, sizeof cmd->args);
 
return (0);
+}
+
+int
+ask_cmd(cmd_t *cmd)
+{
+   char lbuf[100];
+
+   /* Get input */
+   if (fgets(lbuf, sizeof lbuf, stdin) == NULL)
+   errx(1, "eof");
+   return parse_cmd(cmd, lbuf);
 }
 
 int
Index: misc.h
===
RCS file: /home/cvs/src/usr.sbin/config/misc.h,v
retrieving revision 1.4
diff -u -p -r1.4 misc.h
--- misc.h  3 Jun 2003 00:52:35 -   1.4
+++ misc.h  11 May 2019 15:10:04 -
@@ -33,6 +33,7 @@
 
 /* Prototypes */
 int ask_cmd(cmd_t *);
+int parse_cmd(cmd_t *, char *);
 int ask_yn(const char *);
 
 #endif /* _MISC_H */
Index: ukcutil.c
===
RCS file: /home/cvs/src/usr.sbin/config/ukcutil.c,v
retrieving revision 1.23
diff -u -p -r1.23 ukcutil.c
--- ukcutil.c   27 Sep 2017 15:14:52 -  1.23
+++ ukcutil.c   11 May 2019 15:14:25 -
@@ -29,6 +29,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1295,13 +1296,61 @@ add_history(int devno, short unit, short
 }
 
 int
+config_fromfile(const char *cmdfile) {
+   FILE *fp;
+   cmd_t cmd;
+   int i;
+
+   fp = fopen(cmdfile, "r");
+   if (fp == NULL)
+   err(1, "open %s", cmdfile);
+
+   /* Set up command table pointer */
+   cmd.table = cmd_table;
+
+   /* Edit cycle */
+   do {
+   char lbuf[100];
+
+   /* Get input */
+   if (fgets(lbuf, sizeof lbuf, fp) == NULL)
+   break;
+   parse_cmd(, lbuf);
+
+   if (cmd.cmd[0] == '\0')
+   continue;
+   for (i = 0; cmd_table[i].cmd != NULL; i++)
+   if (strstr(cmd_table[i].cmd, cmd.cmd) ==
+   cmd_table[i].cmd)
+   break;
+
+   /* Check for valid command */
+   if (cmd_table[i].cmd == NULL) {
+   printf("Invalid command '%s'\n", cmd.cmd);
+  

Re: tcpdump support extended bgp shutdown communication

2019-05-11 Thread Job Snijders
OK job@

On Sat, May 11, 2019 at 14:37 Claudio Jeker 
wrote:

> bgpd already got support for extended shutdown communication messages.
> This adds the same support to tcpdump.
>
> OK?
> --
> :wq Claudio
>
> Index: print-bgp.c
> ===
> RCS file: /cvs/src/usr.sbin/tcpdump/print-bgp.c,v
> retrieving revision 1.27
> diff -u -p -r1.27 print-bgp.c
> --- print-bgp.c 28 Dec 2018 11:54:10 -  1.27
> +++ print-bgp.c 25 Apr 2019 08:20:27 -
> @@ -241,7 +241,7 @@ static const char *bgpnotify_minor_fsm[]
>  /* RFC 8203 */
>  #define BGP_NOTIFY_MINOR_CEASE_SHUT2
>  #define BGP_NOTIFY_MINOR_CEASE_RESET   4
> -#define BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN  128
> +#define BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN  255
>  static const char *bgpnotify_minor_cease[] = {
> NULL, "Maximum Number of Prefixes Reached", "Administrative
> Shutdown",
> "Peer De-configured", "Administrative Reset", "Connection
> Rejected",
> @@ -982,14 +982,14 @@ bgp_notification_print(const u_char *dat
> u_int16_t af;
> u_int8_t safi;
> const u_char *p;
> -   uint8_t shutdown_comm_length;
> +   size_t shutdown_comm_length;
> char shutstring[BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN + 1];
>
> TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
> memcpy(, dat, BGP_NOTIFICATION_SIZE);
>
> /* sanity checking */
> -   if (length +   if (length < BGP_NOTIFICATION_SIZE)
> return;
>
> printf(": error %s,", bgp_notify_major(bgpn.bgpn_major));
> @@ -1027,22 +1027,23 @@ bgp_notification_print(const u_char *dat
> (length >= BGP_NOTIFICATION_SIZE + 1)) {
> p = dat + BGP_NOTIFICATION_SIZE;
> TCHECK2(*p, 1);
> -   shutdown_comm_length = *(p);
> +   shutdown_comm_length = *p;
>
> /* sanity checking */
> if (shutdown_comm_length == 0)
> return;
> if (shutdown_comm_length >
> BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN)
> -   return;
> -   if (length < (shutdown_comm_length + 1 +
> BGP_NOTIFICATION_SIZE))
> -   return;
> +   goto trunc;
> +   if (length < (shutdown_comm_length + 1 +
> +   BGP_NOTIFICATION_SIZE))
> +   goto trunc;
> TCHECK2(*(p+1), shutdown_comm_length);
>
> /* a proper shutdown communication */
> -   printf(", Shutdown Communication [len %u]: \"",
> +   printf(", Shutdown Communication [len %zu]: \"",
> shutdown_comm_length);
> -   memset(shutstring, 0,
> BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN + 1);
> +   memset(shutstring, 0, sizeof(shutstring));
> memcpy(shutstring, p+1, shutdown_comm_length);
> safeputs(shutstring);
> printf("\"");
>
>


tcpdump support extended bgp shutdown communication

2019-05-11 Thread Claudio Jeker
bgpd already got support for extended shutdown communication messages.
This adds the same support to tcpdump.

OK?
-- 
:wq Claudio

Index: print-bgp.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/print-bgp.c,v
retrieving revision 1.27
diff -u -p -r1.27 print-bgp.c
--- print-bgp.c 28 Dec 2018 11:54:10 -  1.27
+++ print-bgp.c 25 Apr 2019 08:20:27 -
@@ -241,7 +241,7 @@ static const char *bgpnotify_minor_fsm[]
 /* RFC 8203 */
 #define BGP_NOTIFY_MINOR_CEASE_SHUT2
 #define BGP_NOTIFY_MINOR_CEASE_RESET   4
-#define BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN  128
+#define BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN  255
 static const char *bgpnotify_minor_cease[] = {
NULL, "Maximum Number of Prefixes Reached", "Administrative Shutdown",
"Peer De-configured", "Administrative Reset", "Connection Rejected",
@@ -982,14 +982,14 @@ bgp_notification_print(const u_char *dat
u_int16_t af;
u_int8_t safi;
const u_char *p;
-   uint8_t shutdown_comm_length;
+   size_t shutdown_comm_length;
char shutstring[BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN + 1];
 
TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
memcpy(, dat, BGP_NOTIFICATION_SIZE);
 
/* sanity checking */
-   if (length= BGP_NOTIFICATION_SIZE + 1)) {
p = dat + BGP_NOTIFICATION_SIZE;
TCHECK2(*p, 1);
-   shutdown_comm_length = *(p);
+   shutdown_comm_length = *p;
 
/* sanity checking */
if (shutdown_comm_length == 0)
return;
if (shutdown_comm_length >
BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN)
-   return;
-   if (length < (shutdown_comm_length + 1 + 
BGP_NOTIFICATION_SIZE))
-   return;
+   goto trunc;
+   if (length < (shutdown_comm_length + 1 +
+   BGP_NOTIFICATION_SIZE))
+   goto trunc;
TCHECK2(*(p+1), shutdown_comm_length);

/* a proper shutdown communication */
-   printf(", Shutdown Communication [len %u]: \"",
+   printf(", Shutdown Communication [len %zu]: \"",
shutdown_comm_length);
-   memset(shutstring, 0, 
BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN + 1);
+   memset(shutstring, 0, sizeof(shutstring));
memcpy(shutstring, p+1, shutdown_comm_length);
safeputs(shutstring);
printf("\"");



Re: Removing old video drivers

2019-05-11 Thread Matthieu Herrb
On Mon, Apr 22, 2019 at 06:47:23PM +0200, Matthieu Herrb wrote:
> Hi,
> 
> In xenocara, we still build a number of video drivers for very old
> hardware, that is mostly useless. For AGP, I don't have a working
> motherboard to test the cards I still have.
> I also still have a few PCI cards for some of them, but most of them
> are dead, or don't work as primary display with modern BIOSes.
> 
> And most important, none of these old cards has enough RAM to run any
> kind of modern 16 or 32 bpp X at a decent resolution. (And the xserver
> version 1.20 has dropped support for 24 bits per pixel modes).
> 
> So rather that try to blindly fix the issues with these drivers I'd
> rather remove them. This is the list of candidates for removing.
> 

Here is the patch that implements the proposed removals. I've kept
xf86-video-savage for now, since they made cards with decent amounts
of RAM that are still usable.

ok ?

Index: Makefile
===
RCS file: /cvs/OpenBSD/xenocara/driver/Makefile,v
retrieving revision 1.73
diff -u -r1.73 Makefile
--- Makefile16 Apr 2019 02:06:30 -  1.73
+++ Makefile11 May 2019 07:56:17 -
@@ -44,16 +44,14 @@
 VIDEO_DRV_alpha=
 
 VIDEO_DRV_amd64= \
-   xf86-video-amdgpu xf86-video-apm xf86-video-ark \
+   xf86-video-amdgpu xf86-video-apm \
xf86-video-ast xf86-video-ati \
-   xf86-video-chips xf86-video-cirrus xf86-video-dummy xf86-video-glint \
-   xf86-video-i128 xf86-video-intel xf86-video-mach64 \
-   xf86-video-mga xf86-video-neomagic \
+   xf86-video-cirrus xf86-video-dummy \
+   xf86-video-intel xf86-video-mach64 \
+   xf86-video-mga \
xf86-video-nv xf86-video-openchrome xf86-video-r128 \
-   xf86-video-rendition xf86-video-s3 \
-   xf86-video-s3virge xf86-video-savage xf86-video-siliconmotion \
-   xf86-video-sis xf86-video-tdfx xf86-video-trident \
-   xf86-video-tseng xf86-video-vesa xf86-video-vmware \
+   xf86-video-savage xf86-video-siliconmotion \
+   xf86-video-vesa xf86-video-vmware \
xf86-video-wsfb xf86-video-wsudl
 
 VIDEO_DRV_arm64= \
@@ -68,9 +66,7 @@
 
 VIDEO_DRV_i386= \
${VIDEO_DRV_amd64} \
-   xf86-video-geode \
-   xf86-video-i740 \
-   xf86-video-voodoo
+   xf86-video-geode
 
 VIDEO_DRV_landisk=
 
@@ -89,7 +85,7 @@
 VIDEO_DRV_sgi= xf86-video-wsfb
 
 VIDEO_DRV_sparc64= \
-   xf86-video-ati xf86-video-mach64 xf86-video-r128 xf86-video-glint \
+   xf86-video-ati xf86-video-mach64 xf86-video-r128 \
xf86-video-sunffb \
xf86-video-wildcatfb xf86-video-wsfb
 

-- 
Matthieu Herrb