CVS: cvs.openbsd.org: src

2020-07-08 Thread Scott Soule Cheloha
CVSROOT:/cvs
Module name:src
Changes by: chel...@cvs.openbsd.org 2020/07/08 20:17:07

Modified files:
lib/libc/sys   : adjfreq.2 
sys/kern   : kern_time.c 

Log message:
adjfreq(2): limit adjustment to [-50, +50] ppm

When we recompute the scaling factor during tc_windup() there is an
opportunity for arithmetic overflow if the active timecounter's
adjfreq(2) adjustment is too large.  If we limit the adjustment to
[-50, +50] ppm the statement in question cannot overflow.

In particular, we are concerned with the following bit of code:

scale = (u_int64_t)1 << 63;
scale += \
((th->th_adjustment + th->th_counter->tc_freq_adj) / 1024) * 2199;
scale /= th->th_counter->tc_frequency;
th->th_scale = scale * 2;

where scale is an int64_t.  Overflow when we do:

scale += (...) / 1024 * 2199;

as th->th_counter->tc_freq_adj is currently unbounded.
th->th_adjustment is limited to [-5000ppm, 5000ppm].

To see that overflow is prevented with the new bounds, consider the
new edge case where th->th_counter->tc_freq_adj is 50ppm and
th->th_adjustment is 5000ppm.  Both are of type int64_t.  We have:

int64_t th_adjustment = (5000 * 1000) << 32;/* 2147483648000 */
int64_t tc_freq_adj = 5LL << 32;/* 21474836480 */

scale = (u_int64_t)1 << 63; /* 9223372036854775808 */
scale += (th_adjustment + tc_freq_adj) / 1024 * 2199;
/* scale += 216895848448000 / 1024 * 2199; */
/* scale += 465775362048000; */

9223372036854775808 + 465775362048000 = 13881125657334775808,
which less than 18446744073709551616, so we don't have overflow.

On the opposite end, if th->th_counter->tc_freq_adj is -50ppm and
th->th_adjustment is -5000ppm we would have -465775362048000.

9223372036854775808 - 465775362048000 = 4565618416374775808.
Again, no overflow.

50ppm and -50ppm are extreme adjustments.  otto@ says ntpd(8)
would never arrive at them naturally, so we are not at risk of breaking
a working setup by imposing these restrictions.

Documentation input from kettenis@.

No complaints from otto@.



CVS: cvs.openbsd.org: src

2020-07-08 Thread Ingo Schwarze
CVSROOT:/cvs
Module name:src
Changes by: schwa...@cvs.openbsd.org2020/07/08 19:49:15

Modified files:
regress/lib/libc/printf: Makefile 
Added files:
regress/lib/libc/printf: int.c 

Log message:
New regression tests for integral type conversions
and for their modifiers, written from scratch.



CVS: cvs.openbsd.org: src

2020-07-08 Thread Theo de Raadt
CVSROOT:/cvs
Module name:src
Changes by: dera...@cvs.openbsd.org 2020/07/08 19:38:36

Removed files:
sys/arch/powerpc/include: timetc.h 

Log message:
do not need this one either



CVS: cvs.openbsd.org: src

2020-07-08 Thread David Gwynne
CVSROOT:/cvs
Module name:src
Changes by: d...@cvs.openbsd.org2020/07/08 19:08:55

Modified files:
sys/dev/pci: if_mcx.c 

Log message:
a couple of small tweaks that shrink the kstat code.

saves a few hundred bytes on both amd64 and sparc64



CVS: cvs.openbsd.org: src

2020-07-08 Thread Tobias Heider
CVSROOT:/cvs
Module name:src
Changes by: to...@cvs.openbsd.org   2020/07/08 15:35:35

Modified files:
sbin/iked  : ikev2_msg.c 

Log message:
Always try to retransmit on sendtofrom() errors to ensure the SA
is properly cleaned up in ikev2_msg_retransmit_timeout().

ok patrick@



CVS: cvs.openbsd.org: src

2020-07-08 Thread Theo de Raadt
CVSROOT:/cvs
Module name:src
Changes by: dera...@cvs.openbsd.org 2020/07/08 15:05:42

Modified files:
sys/kern   : sysv_sem.c 

Log message:
Info leaks in semctl SEM_GET, the pads (unknown old contents) and base (a
RW page within allocateable space) were leaked.  report from adam@grimm-co
ok millert



CVS: cvs.openbsd.org: xenocara

2020-07-08 Thread Matthieu Herrb
CVSROOT:/cvs
Module name:xenocara
Changes by: matth...@cvs.openbsd.org2020/07/08 14:04:44

Modified files:
.  : MODULES 

Log message:
update



CVS: cvs.openbsd.org: xenocara

2020-07-08 Thread Matthieu Herrb
CVSROOT:/cvs
Module name:xenocara
Changes by: matth...@cvs.openbsd.org2020/07/08 14:03:10

Modified files:
distrib/sets/lists/xbase: mi 
distrib/sets/lists/xshare: mi 

Log message:
sync



CVS: cvs.openbsd.org: xenocara

2020-07-08 Thread Matthieu Herrb
CVSROOT:/cvs
Module name:xenocara
Changes by: matth...@cvs.openbsd.org2020/07/08 14:01:53

Modified files:
lib: Makefile 

Log message:
Unlink libxbui from the build. ok jsg@



CVS: cvs.openbsd.org: src

2020-07-08 Thread Mark Kettenis
CVSROOT:/cvs
Module name:src
Changes by: kette...@cvs.openbsd.org2020/07/08 11:48:28

Modified files:
sys/arch/powerpc64/powerpc64: machdep.c 

Log message:
Handle a few more Hypervisor traps.



CVS: cvs.openbsd.org: src

2020-07-08 Thread Todd C . Miller
CVSROOT:/cvs
Module name:src
Changes by: mill...@cvs.openbsd.org 2020/07/08 10:05:27

Modified files:
bin/csh: csh.1 
usr.bin/su : su.1 

Log message:
Clarify that csh's -f flag is not just about .cshrc.
We don't need to be too specific about this in su(1), leave the
details for csh(1).  OK jca@



CVS: cvs.openbsd.org: src

2020-07-08 Thread Visa Hankala
CVSROOT:/cvs
Module name:src
Changes by: v...@cvs.openbsd.org2020/07/08 09:53:59

Modified files:
sys/arch/octeon/include: atomic.h 

Log message:
Make membar_consumer() a plain compiler barrier in kernel on octeon.
The processor does not perform speculative reads and only one of its
execution pipes should issue memory accesses. As a result, loads should
happen in the correct order without barrier instructions.

Tested on CN5020, CN6120, CN7130 and CN7360.

This diff has been in use on the octeon-based mips64 bulk build cluster
for several months. Also tested in snaps for a while.



CVS: cvs.openbsd.org: src

2020-07-08 Thread Theo de Raadt
CVSROOT:/cvs
Module name:src
Changes by: dera...@cvs.openbsd.org 2020/07/08 09:46:31

Modified files:
distrib/sets/lists/comp: md.octeon 

Log message:
sync



CVS: cvs.openbsd.org: src

2020-07-08 Thread Jeremie Courreges-Anglas
CVSROOT:/cvs
Module name:src
Changes by: j...@cvs.openbsd.org2020/07/08 09:36:35

Modified files:
usr.bin/su : su.c 

Log message:
Simplify csh vs other shells setup code

ok millert@



CVS: cvs.openbsd.org: src

2020-07-08 Thread Theo de Raadt
CVSROOT:/cvs
Module name:src
Changes by: dera...@cvs.openbsd.org 2020/07/08 08:45:15

Removed files:
sys/arch/arm/include: timetc.h 
sys/arch/m88k/include: timetc.h 
sys/arch/mips64/include: timetc.h 

Log message:
do not need these versions of timetc.h



CVS: cvs.openbsd.org: src

2020-07-08 Thread Frederic Cambus
CVSROOT:/cvs
Module name:src
Changes by: fcam...@cvs.openbsd.org 2020/07/08 07:01:25

Modified files:
sys/arch/amd64/amd64: identcpu.c 

Log message:
Use CPU_IS_PRIMARY macro in identifycpu() on amd64.

OK deraadt@



CVS: cvs.openbsd.org: src

2020-07-08 Thread Job Snijders
CVSROOT:/cvs
Module name:src
Changes by: j...@cvs.openbsd.org2020/07/08 04:41:38

Modified files:
libexec/login_yubikey: login_yubikey.8 

Log message:
Clarify man page

OK sobrado@ jmc@



CVS: cvs.openbsd.org: src

2020-07-08 Thread Jeremie Courreges-Anglas
CVSROOT:/cvs
Module name:src
Changes by: j...@cvs.openbsd.org2020/07/08 04:35:06

Modified files:
usr.bin/su : su.1 su.c 

Log message:
Teach su -l -f how to start a regular shell for non-csh shells

su -l does nice things like reset the environment and change the home
directory, but it also always starts the user's shell as a login shell
(argv[0] == '-').  This is a problem for su -l consumers like rc.d,
where e.g. /root/.profile is read by the shell before starting a daemon
as root. This tends to blow up if the admin introduces side effects to
/root/.profile (or /etc/profile).

csh supports an -f flag to skip reading .cshrc and .login, and su
already has special support for it.  Similarly, teach su -l -f how to
start a regular shell (not a login shell) for non-csh shells.

Discussion started by robert@ during p2k19 and revived by ajacoutot@,
help and ok kn@ millert@



CVS: cvs.openbsd.org: src

2020-07-08 Thread Mark Kettenis
CVSROOT:/cvs
Module name:src
Changes by: kette...@cvs.openbsd.org2020/07/08 03:20:28

Modified files:
sys/arch/sparc64/sparc64: clock.c 
lib/libc/arch/sparc64/gen: Makefile.inc usertc.c 
sys/arch/sparc64/include: timetc.h 

Log message:
Userland timecounter implementation for sparc64.

ok deraadt@, pirofti@



CVS: cvs.openbsd.org: src

2020-07-08 Thread Mark Kettenis
CVSROOT:/cvs
Module name:src
Changes by: kette...@cvs.openbsd.org2020/07/08 03:17:48

Modified files:
lib/libc/arch/amd64/gen: usertc.c 
sys/arch/amd64/include: timetc.h 

Log message:
Clean up the amd64 userland timecounter implementation a bit:

* We don't need TC_LAST
* Make internal functions static to avoid namespace pollution in libc.a
* Use a switch statement to harmonize with architectures providing
multiple timecounters

ok deraadt@, pirofti@