svn commit: r356049 - head/sys/kern
Conrad Meyer
cem at FreeBSD.org
Tue Dec 24 06:08:29 UTC 2019
Author: cem
Date: Tue Dec 24 06:08:29 2019
New Revision: 356049
URL: https://svnweb.freebsd.org/changeset/base/356049
Log:
kern_synch: Fix some UB
It is UB to evaluate pointer comparisons when pointers do not point within
the same object. Instead, convert the pointers to numbers and compare the
numbers.
Reported by: kib
Discussed with: rlibby
Modified:
head/sys/kern/kern_synch.c
Modified: head/sys/kern/kern_synch.c
==============================================================================
--- head/sys/kern/kern_synch.c Tue Dec 24 01:47:08 2019 (r356048)
+++ head/sys/kern/kern_synch.c Tue Dec 24 06:08:29 2019 (r356049)
@@ -77,7 +77,7 @@ SYSINIT(synch_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_F
NULL);
int hogticks;
-static uint8_t pause_wchan[MAXCPU];
+static char pause_wchan[MAXCPU];
static struct callout loadav_callout;
@@ -169,8 +169,8 @@ _sleep(void *ident, struct lock_object *lock, int prio
KASSERT(!TD_ON_SLEEPQ(td), ("recursive sleep"));
- if ((uint8_t *)ident >= &pause_wchan[0] &&
- (uint8_t *)ident <= &pause_wchan[MAXCPU - 1])
+ if ((uintptr_t)ident >= (uintptr_t)&pause_wchan[0] &&
+ (uintptr_t)ident <= (uintptr_t)&pause_wchan[MAXCPU - 1])
sleepq_flags = SLEEPQ_PAUSE;
else
sleepq_flags = SLEEPQ_SLEEP;
More information about the svn-src-head
mailing list