arm64: GPIO "pin bus" drivers

2018-04-23 Thread Artturi Alm
Hi,

pine64 still being my only arm64-sbc, i won't bother w/
gpio*   at rkgpio?
etc., but i would like to have these enabled for arm64,
as atleast pine64 is equipped w/plenty of headers/pins brought out, and
gpio*   at sxipio?
is there already:)


-Artturi


diff --git sys/arch/arm64/conf/GENERIC sys/arch/arm64/conf/GENERIC
index c5c86db19d6..3990b7122ae 100644
--- sys/arch/arm64/conf/GENERIC
+++ sys/arch/arm64/conf/GENERIC
@@ -288,6 +288,12 @@ uk*at scsibus?
 # I2C devices
 rkpmic*at iic? # RK808 PMIC
 
+# GPIO "pin bus" drivers
+gpioiic*   at gpio?# I2C bus bit-banging
+iic*   at gpioiic?
+gpioow*at gpio?# 1-Wire bus bit-banging
+onewire*   at gpioow?
+
 # 1-Wire devices
 option ONEWIREVERBOSE
 owid*  at onewire? # ID



Re: Error in adding system call in OpenBSD 6.3

2018-04-23 Thread Ted Unangst
Neeraj Pal wrote:
> 
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?

Your includes are in the wrong or some are missing. I think you should start
by adding code to a file that already compiles, that's much less trouble.



Re: Error in adding system call in OpenBSD 6.3

2018-04-23 Thread Neeraj Pal
No, I know. But from last some days it's been like too confusing, I
mean first, it was working after some 15 days ago with the pathway
that I have just described, then now not working, then as Ted said, I
skipped config, now I have done that also but still some errors.
I don't know why these errors, I mean why from syscallsrgs.h file,
even after doing sh makesyscalls.sh syscalls.conf syscalls.master.
And also I am not even doing some socket and all then why these errors.

Sorry, If I have forgotten some basic stuff or asking non-sense
beginners question.

On Tue, Apr 24, 2018 at 3:04 AM, Theo de Raadt  wrote:
> So. you don't know what you are doing.
>
>
> Neeraj Pal  wrote:
>> okay. Sure,
>>
>> Instead of sys_hello.c I created a new one sys_test.c. So, guys don't
>> confuse with above sys_hello.c and this time sys_test.c, both are the
>> same file.
>>
>> Then after that, I went through all the steps including "make config"
>>
>> make obj && make config && make -j4
>>
>> Then it throws this error this time. And, I am not able to understand this.
>>
>>
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
>> 'socklen_t'; did you mean '__socklen_t'?
>> syscallarg(socklen_t *) fromlenaddr;
>>^
>>__socklen_t
>> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
>> struct { x datum; } le; \
>>  ^
>> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
>> typedef __uint32_t  __socklen_t;/* length type for network syscalls 
>> */
>> ^
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
>> syscallarg(socklen_t *) fromlenaddr;
>> ^
>> /usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
>> int8_t pad[ (sizeof (register_t) < sizeof (x))  \
>> ^
>> /usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
>> identifier 'socklen_t'
>> syscallarg(socklen_t *) fromlenaddr;
>>^
>> /usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
>> syscallarg(socklen_t *) fromlenaddr;
>> ^
>> /usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
>> : sizeof (register_t) - sizeof (x)];\
>>  ^
>> /usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
>> identifier 'socklen_t'
>> syscallarg(socklen_t *) fromlenaddr;
>>^
>> /usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
>> 'socklen_t'; did you mean '__socklen_t'?
>> syscallarg(socklen_t *) fromlenaddr;
>>^
>>__socklen_t
>> /usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
>> x datum;\
>> ^
>> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
>> typedef __uint32_t  __socklen_t;/* length type for network syscalls 
>> */
>> ^
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:159:13: error: unknown type name
>> 'socklen_t'; did you mean '__socklen_t'?
>> syscallarg(socklen_t *) anamelen;
>>^
>>__socklen_t
>> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
>> struct { x datum; } le; \
>>  ^
>> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
>> typedef __uint32_t  __socklen_t;/* length type for network syscalls 
>> */
>> ^
>> In file included from /usr/src/sys/kern/sys_test.c:4:
>> /usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
>> syscallarg(socklen_t *) anamelen;
>> ^
>> /usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
>> int8_t pad[ (sizeof (register_t) < sizeof (x))  \
>> ^
>> /usr/src/sys/sys/syscallargs.h:159:13: error: use of undeclared
>> identifier 'socklen_t'
>> syscallarg(socklen_t *) anamelen;
>>^
>> /usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
>> syscallarg(socklen_t *) anamelen;
>> ^
>> /usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
>> : sizeof (register_t) - sizeof (x)];\
>>  

Re: Error in adding system call in OpenBSD 6.3

2018-04-23 Thread Theo de Raadt
So. you don't know what you are doing.


Neeraj Pal  wrote:
> okay. Sure,
> 
> Instead of sys_hello.c I created a new one sys_test.c. So, guys don't
> confuse with above sys_hello.c and this time sys_test.c, both are the
> same file.
> 
> Then after that, I went through all the steps including "make config"
> 
> make obj && make config && make -j4
> 
> Then it throws this error this time. And, I am not able to understand this.
> 
> 
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?
> syscallarg(socklen_t *) fromlenaddr;
>^
>__socklen_t
> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
> struct { x datum; } le; \
>  ^
> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
> typedef __uint32_t  __socklen_t;/* length type for network syscalls */
> ^
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
> syscallarg(socklen_t *) fromlenaddr;
> ^
> /usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
> int8_t pad[ (sizeof (register_t) < sizeof (x))  \
> ^
> /usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
> identifier 'socklen_t'
> syscallarg(socklen_t *) fromlenaddr;
>^
> /usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
> syscallarg(socklen_t *) fromlenaddr;
> ^
> /usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
> : sizeof (register_t) - sizeof (x)];\
>  ^
> /usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
> identifier 'socklen_t'
> syscallarg(socklen_t *) fromlenaddr;
>^
> /usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?
> syscallarg(socklen_t *) fromlenaddr;
>^
>__socklen_t
> /usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
> x datum;\
> ^
> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
> typedef __uint32_t  __socklen_t;/* length type for network syscalls */
> ^
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:159:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?
> syscallarg(socklen_t *) anamelen;
>^
>__socklen_t
> /usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
> struct { x datum; } le; \
>  ^
> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
> typedef __uint32_t  __socklen_t;/* length type for network syscalls */
> ^
> In file included from /usr/src/sys/kern/sys_test.c:4:
> /usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
> syscallarg(socklen_t *) anamelen;
> ^
> /usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
> int8_t pad[ (sizeof (register_t) < sizeof (x))  \
> ^
> /usr/src/sys/sys/syscallargs.h:159:13: error: use of undeclared
> identifier 'socklen_t'
> syscallarg(socklen_t *) anamelen;
>^
> /usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
> syscallarg(socklen_t *) anamelen;
> ^
> /usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
> : sizeof (register_t) - sizeof (x)];\
>  ^
> /usr/src/sys/sys/syscallargs.h:159:13: error: use of undeclared
> identifier 'socklen_t'
> syscallarg(socklen_t *) anamelen;
>^
> /usr/src/sys/sys/syscallargs.h:159:13: error: unknown type name
> 'socklen_t'; did you mean '__socklen_t'?
> syscallarg(socklen_t *) anamelen;
>^
>__socklen_t
> /usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
> x datum;\
> ^
> /usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
> typedef __uint32_t  __socklen_t;/* length type for 

Re: Error in adding system call in OpenBSD 6.3

2018-04-23 Thread Neeraj Pal
okay. Sure,

Instead of sys_hello.c I created a new one sys_test.c. So, guys don't
confuse with above sys_hello.c and this time sys_test.c, both are the
same file.

Then after that, I went through all the steps including "make config"

make obj && make config && make -j4

Then it throws this error this time. And, I am not able to understand this.


In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
syscallarg(socklen_t *) fromlenaddr;
   ^
   __socklen_t
/usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
struct { x datum; } le; \
 ^
/usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
typedef __uint32_t  __socklen_t;/* length type for network syscalls */
^
In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
syscallarg(socklen_t *) fromlenaddr;
^
/usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
int8_t pad[ (sizeof (register_t) < sizeof (x))  \
^
/usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
identifier 'socklen_t'
syscallarg(socklen_t *) fromlenaddr;
   ^
/usr/src/sys/sys/syscallargs.h:153:2: error: expected expression
syscallarg(socklen_t *) fromlenaddr;
^
/usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
: sizeof (register_t) - sizeof (x)];\
 ^
/usr/src/sys/sys/syscallargs.h:153:13: error: use of undeclared
identifier 'socklen_t'
syscallarg(socklen_t *) fromlenaddr;
   ^
/usr/src/sys/sys/syscallargs.h:153:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
syscallarg(socklen_t *) fromlenaddr;
   ^
   __socklen_t
/usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
x datum;\
^
/usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
typedef __uint32_t  __socklen_t;/* length type for network syscalls */
^
In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:159:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
syscallarg(socklen_t *) anamelen;
   ^
   __socklen_t
/usr/src/sys/sys/syscallargs.h:17:12: note: expanded from macro 'syscallarg'
struct { x datum; } le; \
 ^
/usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
typedef __uint32_t  __socklen_t;/* length type for network syscalls */
^
In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
syscallarg(socklen_t *) anamelen;
^
/usr/src/sys/sys/syscallargs.h:19:48: note: expanded from macro 'syscallarg'
int8_t pad[ (sizeof (register_t) < sizeof (x))  \
^
/usr/src/sys/sys/syscallargs.h:159:13: error: use of undeclared
identifier 'socklen_t'
syscallarg(socklen_t *) anamelen;
   ^
/usr/src/sys/sys/syscallargs.h:159:2: error: expected expression
syscallarg(socklen_t *) anamelen;
^
/usr/src/sys/sys/syscallargs.h:21:38: note: expanded from macro 'syscallarg'
: sizeof (register_t) - sizeof (x)];\
 ^
/usr/src/sys/sys/syscallargs.h:159:13: error: use of undeclared
identifier 'socklen_t'
syscallarg(socklen_t *) anamelen;
   ^
/usr/src/sys/sys/syscallargs.h:159:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
syscallarg(socklen_t *) anamelen;
   ^
   __socklen_t
/usr/src/sys/sys/syscallargs.h:22:4: note: expanded from macro 'syscallarg'
x datum;\
^
/usr/src/sys/sys/_types.h:61:20: note: '__socklen_t' declared here
typedef __uint32_t  __socklen_t;/* length type for network syscalls */
^
In file included from /usr/src/sys/kern/sys_test.c:4:
/usr/src/sys/sys/syscallargs.h:165:13: error: unknown type name
'socklen_t'; did you mean '__socklen_t'?
syscallarg(socklen_t *) alen;
   ^
  

Re: Error in adding system call in OpenBSD 6.3

2018-04-23 Thread Ted Unangst
Neeraj Pal wrote:
> 4) echo "file kern/sys_hello.c" >> /usr/src/sys/conf/files
> 
> 5) cd /usr/src/sys/arch/amd64/compile/CUSTOM.MP/
> 
> 6) make obj && make -j4
> 
> And, then, It throws an error given below,
> 
> "
> ld -T ld.script -X --warn-common -nopie -o bsd ${SYSTEM_HEAD} vers.o ${OBJS}
> 
> init_sysent.o:(.data+0x14b8): undefined reference to `sys_hello'

this looks like the object wasn't added. you skipped make config.



Re: remove unused rtentry parameter from rtm_addr()

2018-04-23 Thread Claudio Jeker
On Mon, Apr 23, 2018 at 04:38:12PM +0200, Florian Obser wrote:
> any objections? otherwise I'll commit it with OK benno, kn

Not from me. OK claudio@
 
> On Thu, Apr 19, 2018 at 08:08:45AM +0200, Florian Obser wrote:
> > On Wed, Apr 18, 2018 at 11:31:02PM +0200, Alexander Bluhm wrote:
> > > On Wed, Apr 18, 2018 at 05:03:04PM +0200, Florian Obser wrote:
> > > > @@ -1158,9 +1158,9 @@ rt_ifa_del(struct ifaddr *ifa, int flags, struct 
> > > > sockaddr *dst)
> > > > error = rtrequest_delete(, prio, ifp, , rtableid);
> > > > if (error == 0) {
> > > > rtm_send(rt, RTM_DELETE, 0, rtableid);
> > > > -   if (flags & RTF_LOCAL)
> > > > -   rtm_addr(rt, RTM_DELADDR, ifa);
> > > > rtfree(rt);
> > > > +   if (flags & RTF_LOCAL)
> > > > +   rtm_addr(RTM_DELADDR, ifa);
> > > > }
> > > > m_free(m);
> > > >  
> > > 
> > > Why do you change the order of rtfree() and rtm_addr()?
> > > 
> > > Have you checked that the rt->rt_ifa is not holding the last reference
> > > to ifa?  Otherwise the ifafree() in rtfree() could free it.
> > > 
> > > bluhm
> > > 
> > 
> > I missread rtfree() for free(). Best to not do that.
> > 
> > diff --git net/route.c net/route.c
> > index 30c8def301d..fc8f5f3707a 100644
> > --- net/route.c
> > +++ net/route.c
> > @@ -1103,7 +1103,7 @@ rt_ifa_add(struct ifaddr *ifa, int flags, struct 
> > sockaddr *dst)
> >  * userland that a new address has been added.
> >  */
> > if (flags & RTF_LOCAL)
> > -   rtm_addr(rt, RTM_NEWADDR, ifa);
> > +   rtm_addr(RTM_NEWADDR, ifa);
> > rtm_send(rt, RTM_ADD, 0, rtableid);
> > rtfree(rt);
> > }
> > @@ -1159,7 +1159,7 @@ rt_ifa_del(struct ifaddr *ifa, int flags, struct 
> > sockaddr *dst)
> > if (error == 0) {
> > rtm_send(rt, RTM_DELETE, 0, rtableid);
> > if (flags & RTF_LOCAL)
> > -   rtm_addr(rt, RTM_DELADDR, ifa);
> > +   rtm_addr(RTM_DELADDR, ifa);
> > rtfree(rt);
> > }
> > m_free(m);
> > diff --git net/route.h net/route.h
> > index 9f5459a9a62..3c89348cb43 100644
> > --- net/route.h
> > +++ net/route.h
> > @@ -427,7 +427,7 @@ void rt_maskedcopy(struct sockaddr *,
> > struct sockaddr *, struct sockaddr *);
> >  struct sockaddr *rt_plen2mask(struct rtentry *, struct sockaddr_in6 *);
> >  voidrtm_send(struct rtentry *, int, int, unsigned int);
> > -voidrtm_addr(struct rtentry *, int, struct ifaddr *);
> > +voidrtm_addr(int, struct ifaddr *);
> >  voidrtm_miss(int, struct rt_addrinfo *, int, uint8_t, u_int, int, 
> > u_int);
> >  int rt_setgate(struct rtentry *, struct sockaddr *, u_int);
> >  struct rtentry *rt_getll(struct rtentry *);
> > diff --git net/rtsock.c net/rtsock.c
> > index eb570e25698..c5590378259 100644
> > --- net/rtsock.c
> > +++ net/rtsock.c
> > @@ -1509,7 +1509,7 @@ rtm_ifchg(struct ifnet *ifp)
> >   * copies of it.
> >   */
> >  void
> > -rtm_addr(struct rtentry *rt, int cmd, struct ifaddr *ifa)
> > +rtm_addr(int cmd, struct ifaddr *ifa)
> >  {
> > struct ifnet*ifp = ifa->ifa_ifp;
> > struct mbuf *m;
> > 
> > 
> > -- 
> > I'm not entirely sure you are real.
> > 
> 
> -- 
> I'm not entirely sure you are real.
> 

-- 
:wq Claudio



semaphore: validate timespec and handle SA_RESTART

2018-04-23 Thread Paul Irofti
Hi,

After discussing further with mpi@ and guenther@, we decided to first
fix the existing semaphore implementation with regards to SA_RESTART
and POSIX compliant returns in the case where we deal with restartable
signals.

Currently we return EINTR everywhere which is mostly incorrect as the
user can not know if she needs to recall the syscall or not. Philip
suggested we use ECANCELED for that which is what my diff does.

Regression tests pass and so does the posixsuite. Timespec validation
bits are needed to pass the later.

Branch available at

  https://github.com/bulibuta/openbsd-src/tree/oldsem_ecanceled

Thoughts? OKs?

Paul


diff --git lib/libc/thread/rthread_sync.c lib/libc/thread/rthread_sync.c
index 91ce55cbcf9..bb9a26803fa 100644
--- lib/libc/thread/rthread_sync.c
+++ lib/libc/thread/rthread_sync.c
@@ -375,7 +375,8 @@ pthread_cond_timedwait(pthread_cond_t *condp, 
pthread_mutex_t *mutexp,
 * cancellation) then we should just go back to
 * sleep without changing state (timeouts, etc).
 */
-   if (error == EINTR && (tib->tib_canceled == 0 ||
+   if ((error == EINTR || error == ECANCELED) &&
+   (tib->tib_canceled == 0 ||
(tib->tib_cantcancel & CANCEL_DISABLED))) {
_spinlock(>lock);
continue;
@@ -514,7 +515,8 @@ pthread_cond_wait(pthread_cond_t *condp, pthread_mutex_t 
*mutexp)
 * cancellation) then we should just go back to
 * sleep without changing state (timeouts, etc).
 */
-   if (error == EINTR && (tib->tib_canceled == 0 ||
+   if ((error == EINTR || error == ECANCELED) &&
+   (tib->tib_canceled == 0 ||
(tib->tib_cantcancel & CANCEL_DISABLED))) {
_spinlock(>lock);
continue;
diff --git lib/librthread/rthread_rwlock.c lib/librthread/rthread_rwlock.c
index a75e88c52e4..6fccd2fe1bd 100644
--- lib/librthread/rthread_rwlock.c
+++ lib/librthread/rthread_rwlock.c
@@ -143,8 +143,8 @@ int
 pthread_rwlock_timedrdlock(pthread_rwlock_t *lockp,
 const struct timespec *abstime)
 {
-   if (abstime == NULL || abstime->tv_sec < 0 || abstime->tv_nsec < 0 ||
-   abstime->tv_nsec > 10)
+   if (abstime == NULL || abstime->tv_nsec < 0 ||
+   abstime->tv_nsec >= 10)
return (EINVAL);
return (_rthread_rwlock_rdlock(lockp, abstime, 0));
 }
@@ -210,8 +210,8 @@ int
 pthread_rwlock_timedwrlock(pthread_rwlock_t *lockp,
 const struct timespec *abstime)
 {
-   if (abstime == NULL || abstime->tv_sec < 0 || abstime->tv_nsec < 0 ||
-   abstime->tv_nsec > 10)
+   if (abstime == NULL || abstime->tv_nsec < 0 ||
+   abstime->tv_nsec >= 10)
return (EINVAL);
return (_rthread_rwlock_wrlock(lockp, abstime, 0));
 }
diff --git lib/librthread/rthread_sem.c lib/librthread/rthread_sem.c
index 196fb8ec357..d4c133aa4e0 100644
--- lib/librthread/rthread_sem.c
+++ lib/librthread/rthread_sem.c
@@ -75,7 +75,7 @@ _sem_wait(sem_t sem, int tryonly, const struct timespec 
*abstime,
>lock, delayed_cancel);
_spinlock(>lock);
/* ignore interruptions other than cancelation */
-   if (r == EINTR && (delayed_cancel == NULL ||
+   if (r == ECANCELED && (delayed_cancel == NULL ||
*delayed_cancel == 0))
r = 0;
} while (r == 0 && sem->value == 0);
@@ -268,15 +268,16 @@ sem_timedwait(sem_t *semp, const struct timespec *abstime)
int r;
PREP_CANCEL_POINT(tib);
 
-   if (!_threads_ready)
-   _rthread_init();
-   self = tib->tib_thread;
-
-   if (!semp || !(sem = *semp)) {
+   if (!semp || !(sem = *semp) || abstime == NULL ||
+   abstime->tv_nsec < 0 || abstime->tv_nsec >= 10) {
errno = EINVAL;
return (-1);
}
 
+   if (!_threads_ready)
+   _rthread_init();
+   self = tib->tib_thread;
+
ENTER_DELAYED_CANCEL_POINT(tib, self);
r = _sem_wait(sem, 0, abstime, >delayed_cancel);
LEAVE_CANCEL_POINT_INNER(tib, r);
diff --git sys/kern/kern_synch.c sys/kern/kern_synch.c
index ea28288d375..7a920b27c8b 100644
--- sys/kern/kern_synch.c
+++ sys/kern/kern_synch.c
@@ -592,7 +592,7 @@ out:
p->p_thrslpid = 0;
 
if (error == ERESTART)
-   error = EINTR;
+   error = ECANCELED;
 
return (error);
 
@@ -614,13 +614,17 @@ sys___thrsleep(struct proc *p, void *v, register_t 
*retval)
if (SCARG(uap, tp) != NULL) {
if ((error = copyin(SCARG(uap, tp), , sizeof(ts {
*retval = error;
-   return (0);
+   

Re: remove unused rtentry parameter from rtm_addr()

2018-04-23 Thread Florian Obser
any objections? otherwise I'll commit it with OK benno, kn

On Thu, Apr 19, 2018 at 08:08:45AM +0200, Florian Obser wrote:
> On Wed, Apr 18, 2018 at 11:31:02PM +0200, Alexander Bluhm wrote:
> > On Wed, Apr 18, 2018 at 05:03:04PM +0200, Florian Obser wrote:
> > > @@ -1158,9 +1158,9 @@ rt_ifa_del(struct ifaddr *ifa, int flags, struct 
> > > sockaddr *dst)
> > >   error = rtrequest_delete(, prio, ifp, , rtableid);
> > >   if (error == 0) {
> > >   rtm_send(rt, RTM_DELETE, 0, rtableid);
> > > - if (flags & RTF_LOCAL)
> > > - rtm_addr(rt, RTM_DELADDR, ifa);
> > >   rtfree(rt);
> > > + if (flags & RTF_LOCAL)
> > > + rtm_addr(RTM_DELADDR, ifa);
> > >   }
> > >   m_free(m);
> > >  
> > 
> > Why do you change the order of rtfree() and rtm_addr()?
> > 
> > Have you checked that the rt->rt_ifa is not holding the last reference
> > to ifa?  Otherwise the ifafree() in rtfree() could free it.
> > 
> > bluhm
> > 
> 
> I missread rtfree() for free(). Best to not do that.
> 
> diff --git net/route.c net/route.c
> index 30c8def301d..fc8f5f3707a 100644
> --- net/route.c
> +++ net/route.c
> @@ -1103,7 +1103,7 @@ rt_ifa_add(struct ifaddr *ifa, int flags, struct 
> sockaddr *dst)
>* userland that a new address has been added.
>*/
>   if (flags & RTF_LOCAL)
> - rtm_addr(rt, RTM_NEWADDR, ifa);
> + rtm_addr(RTM_NEWADDR, ifa);
>   rtm_send(rt, RTM_ADD, 0, rtableid);
>   rtfree(rt);
>   }
> @@ -1159,7 +1159,7 @@ rt_ifa_del(struct ifaddr *ifa, int flags, struct 
> sockaddr *dst)
>   if (error == 0) {
>   rtm_send(rt, RTM_DELETE, 0, rtableid);
>   if (flags & RTF_LOCAL)
> - rtm_addr(rt, RTM_DELADDR, ifa);
> + rtm_addr(RTM_DELADDR, ifa);
>   rtfree(rt);
>   }
>   m_free(m);
> diff --git net/route.h net/route.h
> index 9f5459a9a62..3c89348cb43 100644
> --- net/route.h
> +++ net/route.h
> @@ -427,7 +427,7 @@ void   rt_maskedcopy(struct sockaddr *,
>   struct sockaddr *, struct sockaddr *);
>  struct sockaddr *rt_plen2mask(struct rtentry *, struct sockaddr_in6 *);
>  void  rtm_send(struct rtentry *, int, int, unsigned int);
> -void  rtm_addr(struct rtentry *, int, struct ifaddr *);
> +void  rtm_addr(int, struct ifaddr *);
>  void  rtm_miss(int, struct rt_addrinfo *, int, uint8_t, u_int, int, u_int);
>  int   rt_setgate(struct rtentry *, struct sockaddr *, u_int);
>  struct rtentry *rt_getll(struct rtentry *);
> diff --git net/rtsock.c net/rtsock.c
> index eb570e25698..c5590378259 100644
> --- net/rtsock.c
> +++ net/rtsock.c
> @@ -1509,7 +1509,7 @@ rtm_ifchg(struct ifnet *ifp)
>   * copies of it.
>   */
>  void
> -rtm_addr(struct rtentry *rt, int cmd, struct ifaddr *ifa)
> +rtm_addr(int cmd, struct ifaddr *ifa)
>  {
>   struct ifnet*ifp = ifa->ifa_ifp;
>   struct mbuf *m;
> 
> 
> -- 
> I'm not entirely sure you are real.
> 

-- 
I'm not entirely sure you are real.



Re: re-run DAD on address update

2018-04-23 Thread Florian Obser
anyone?

On Wed, Apr 18, 2018 at 02:09:56PM +0200, Florian Obser wrote:
> Run duplicate address detection again if an existing address gets
> updated from userland that was marked duplicated or tentative.
> 
> Otherwise we would just lose the duplicated / tentative state and assume
> that the address is now unique and usable.
> 
> OK?
> 
> diff --git in6.c in6.c
> index 1c5ec065aa5..b347ec74621 100644
> --- in6.c
> +++ in6.c
> @@ -420,15 +420,15 @@ in6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, 
> int privileged)
>   break;
>   }
>  
> + /* Perform DAD, if needed. */
> + if (ia6->ia6_flags & IN6_IFF_TENTATIVE)
> + nd6_dad_start(>ia_ifa);
> +
>   if (!newifaddr) {
>   dohooks(ifp->if_addrhooks, 0);
>   break;
>   }
>  
> - /* Perform DAD, if needed. */
> - if (ia6->ia6_flags & IN6_IFF_TENTATIVE)
> - nd6_dad_start(>ia_ifa);
> -
>   plen = in6_mask2len(>ia_prefixmask.sin6_addr, NULL);
>   if ((ifp->if_flags & IFF_LOOPBACK) || plen == 128) {
>   dohooks(ifp->if_addrhooks, 0);
> @@ -655,6 +655,9 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq 
> *ifra,
>   if ((error = in6_ifinit(ifp, ia6, hostIsNew)) != 0)
>   goto unlink;
>  
> + /* re-run DAD */
> + if (ia6->ia6_flags & (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED))
> + ifra->ifra_flags |= IN6_IFF_TENTATIVE;
>   /*
>* configure address flags.
>*/
> 
> 
> -- 
> I'm not entirely sure you are real.
> 

-- 
I'm not entirely sure you are real.



make getsn() use size_t for memory lengths, not int

2018-04-23 Thread David Gwynne
sprinkle some bounded attributes while here.

this isnt used much, so easy to audit too.

ok?

Index: share/man/man9/getsn.9
===
RCS file: /cvs/src/share/man/man9/getsn.9,v
retrieving revision 1.1
diff -u -p -r1.1 getsn.9
--- share/man/man9/getsn.9  23 Apr 2018 10:30:39 -  1.1
+++ share/man/man9/getsn.9  23 Apr 2018 10:44:39 -
@@ -32,8 +32,8 @@
 .Nd read user input from the console
 .Sh SYNOPSIS
 .In lib/libkern/libkern.h
-.Ft int
-.Fn getsn "char *cp" "int size"
+.Ft size_t
+.Fn getsn "char *cp" "size_t size"
 .Sh DESCRIPTION
 The
 .Fn getsn
Index: sys/lib/libkern/getsn.c
===
RCS file: /cvs/src/sys/lib/libkern/getsn.c,v
retrieving revision 1.6
diff -u -p -r1.6 getsn.c
--- sys/lib/libkern/getsn.c 5 Dec 2012 23:20:22 -   1.6
+++ sys/lib/libkern/getsn.c 23 Apr 2018 10:44:39 -
@@ -29,10 +29,11 @@
 #include 
 #include 
 
-int
-getsn(char *cp, int size)
+size_t
+getsn(char *cp, size_t size)
 {
-   int len = 0, c;
+   size_t len = 0;
+   int  c;
char *lp = cp;
 
while (1) {
Index: sys/lib/libkern/libkern.h
===
RCS file: /cvs/src/sys/lib/libkern/libkern.h,v
retrieving revision 1.34
diff -u -p -r1.34 libkern.h
--- sys/lib/libkern/libkern.h   13 Jul 2014 23:49:40 -  1.34
+++ sys/lib/libkern/libkern.h   23 Apr 2018 10:44:39 -
@@ -183,7 +183,8 @@ size_t   strlcat(char *, const char *, si
 int strcmp(const char *, const char *);
 int strncmp(const char *, const char *, size_t);
 int strncasecmp(const char *, const char *, size_t);
-int getsn(char *, int);
+size_t  getsn(char *, size_t)
+   __attribute__ ((__bounded__(__string__,1,2)));
 char   *strchr(const char *, int);
 char   *strrchr(const char *, int);
 int timingsafe_bcmp(const void *, const void *, size_t);



Re: make X509_CRL_METHOD_free() NULL-safe

2018-04-23 Thread Kinichiro Inoguchi
OK inoguchi@


Re: make X509_CRL_METHOD_free() NULL-safe

2018-04-23 Thread Brent Cook
OK bcook@

On Mon, Apr 23, 2018 at 3:27 AM, Theo Buehler  wrote:

> This is a practically unused function (both in our tree and globally),
> but it is the only remaining public *_free() function in libcrypto that
> segfaults on being passed NULL. I'll of course add it to the regress
> tests should this go in.
>
> Index: lib/libcrypto/asn1/x_crl.c
> ===
> RCS file: /var/cvs/src/lib/libcrypto/asn1/x_crl.c,v
> retrieving revision 1.30
> diff -u -p -r1.30 x_crl.c
> --- lib/libcrypto/asn1/x_crl.c  17 Mar 2018 14:33:20 -  1.30
> +++ lib/libcrypto/asn1/x_crl.c  22 Apr 2018 12:12:14 -
> @@ -675,7 +675,7 @@ X509_CRL_METHOD_new(int (*crl_init)(X509
>  void
>  X509_CRL_METHOD_free(X509_CRL_METHOD *m)
>  {
> -   if (!(m->flags & X509_CRL_METHOD_DYNAMIC))
> +   if (m == NULL || !(m->flags & X509_CRL_METHOD_DYNAMIC))
> return;
> free(m);
>  }
>


make X509_CRL_METHOD_free() NULL-safe

2018-04-23 Thread Theo Buehler
This is a practically unused function (both in our tree and globally),
but it is the only remaining public *_free() function in libcrypto that
segfaults on being passed NULL. I'll of course add it to the regress
tests should this go in.

Index: lib/libcrypto/asn1/x_crl.c
===
RCS file: /var/cvs/src/lib/libcrypto/asn1/x_crl.c,v
retrieving revision 1.30
diff -u -p -r1.30 x_crl.c
--- lib/libcrypto/asn1/x_crl.c  17 Mar 2018 14:33:20 -  1.30
+++ lib/libcrypto/asn1/x_crl.c  22 Apr 2018 12:12:14 -
@@ -675,7 +675,7 @@ X509_CRL_METHOD_new(int (*crl_init)(X509
 void
 X509_CRL_METHOD_free(X509_CRL_METHOD *m)
 {
-   if (!(m->flags & X509_CRL_METHOD_DYNAMIC))
+   if (m == NULL || !(m->flags & X509_CRL_METHOD_DYNAMIC))
return;
free(m);
 }



Fix ifstated(8) "carp?.link.unknown"

2018-04-23 Thread YASUOKA Masahiko
Hi,

"carp?.link.unknown" doesn't work.

carp(4) started using LINK_STATE_INVALID for ifi_link_state instead of
LINK_STATE_INVALID(0).  ifstated needs to sync this change.

ok?

Index: usr.sbin/ifstated/ifstated.c
===
RCS file: /var/cvs/openbsd/src/usr.sbin/ifstated/ifstated.c,v
retrieving revision 1.61
diff -u -p -r1.61 ifstated.c
--- usr.sbin/ifstated/ifstated.c30 Aug 2017 16:14:52 -  1.61
+++ usr.sbin/ifstated/ifstated.c23 Apr 2018 06:37:14 -
@@ -448,7 +448,10 @@ external_evtimer_setup(struct ifsd_state
}
 }
 
-#defineLINK_STATE_IS_DOWN(_s)  (!LINK_STATE_IS_UP((_s)))
+#defineLINK_STATE_IS_UNKNOWN(_s)   ((_s) == LINK_STATE_UNKNOWN || \
+   (_s) == LINK_STATE_INVALID)
+#defineLINK_STATE_IS_DOWN(_s)  (!LINK_STATE_IS_UNKNOWN(_s) && \
+   !LINK_STATE_IS_UP((_s)))
 
 int
 scan_ifstate_single(const char *ifname, int s, struct ifsd_state *state)
@@ -468,7 +471,7 @@ scan_ifstate_single(const char *ifname, 
 
truth =
(ifstate->ifstate == IFSD_LINKUNKNOWN &&
-   s == LINK_STATE_UNKNOWN) ||
+   LINK_STATE_IS_UNKNOWN(s)) ||
(ifstate->ifstate == IFSD_LINKDOWN &&
LINK_STATE_IS_DOWN(s)) ||
(ifstate->ifstate == IFSD_LINKUP &&



Re: ccp(4): quick and dirty driver for amd crypto coprocessors

2018-04-23 Thread Mark Kettenis
> From: David Gwynne 
> Date: Mon, 23 Apr 2018 10:38:57 +1000
> 
> > On 21 Apr 2018, at 05:52, Christian Weisgerber  wrote:
> > 
> > On 2018-04-20, Mark Kettenis  wrote:
> > 
> >> At some point I tried playing with this on the APU, which has the v3
> >> engine I think.  Couldn't get anything to work (but I didn't try very
> >> hard).  Would be interesting to see whether this actually works on
> >> that machine.
> > 
> > It attaches.  How can I tell if it works?
> > 
> > ccp0 at pci0 dev 8 function 0 "AMD Cryptographic Co-processor v3" rev 0x00
> 
> i added printfs in the timeout, but that's pretty invasive. how do
> we tell if any rng is working?

We can't tell.  Our random code doesn't really care.  Adding data that
isn't really random to the entropy pool shouldn't make our output less
random and we don't count entropy anymore.



Re: [patch] man for vgafb(4) should have list of supported architectures

2018-04-23 Thread Jason McIntyre
On Tue, Apr 17, 2018 at 04:24:53AM +0300, IL Ka wrote:
> diff --git share/man/man4/vgafb.4 share/man/man4/vgafb.4
> index d9ccfa469..6e9a9875c 100644
> --- share/man/man4/vgafb.4
> +++ share/man/man4/vgafb.4
> @@ -31,6 +31,7 @@
>  .Nm vgafb
>  .Nd VGA frame buffer
>  .Sh SYNOPSIS
> +.Cd # sparc64, macppc
>  .Cd "vgafb* at pci?"
>  .Cd "wsdisplay* at vgafb?"
>  .Sh DESCRIPTION

fixed, thanks.
jmc