diff options
author | bz <bz@FreeBSD.org> | 2006-01-21 10:44:34 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2006-01-21 10:44:34 +0000 |
commit | 6d9ab80fce79d4befb78b6264b0cfe789cdeac58 (patch) | |
tree | 6592dbe525d1fa703ba65343df6cd7f697d18423 /sys/netkey | |
parent | 0da5dd341ca939cb09f09ca6e0b9d4b978a60690 (diff) | |
download | FreeBSD-src-6d9ab80fce79d4befb78b6264b0cfe789cdeac58.zip FreeBSD-src-6d9ab80fce79d4befb78b6264b0cfe789cdeac58.tar.gz |
Fix stack corruptions on amd64.
Vararg functions have a different calling convention than regular
functions on amd64. Casting a varag function to a regular one to
match the function pointer declaration will hide the varargs from
the caller and we will end up with an incorrectly setup stack.
Entirely remove the varargs from these functions and change the
functions to match the declaration of the function pointers.
Remove the now unnecessary casts.
Lots of explanations and help from: peter
Reviewed by: peter
PR: amd64/89261
MFC after: 6 days
Diffstat (limited to 'sys/netkey')
-rw-r--r-- | sys/netkey/keysock.c | 16 | ||||
-rw-r--r-- | sys/netkey/keysock.h | 2 |
2 files changed, 3 insertions, 15 deletions
diff --git a/sys/netkey/keysock.c b/sys/netkey/keysock.c index a19d977..6419956 100644 --- a/sys/netkey/keysock.c +++ b/sys/netkey/keysock.c @@ -75,23 +75,11 @@ struct pfkeystat pfkeystat; * key_output() */ int -#if __STDC__ -key_output(struct mbuf *m, ...) -#else -key_output(m, va_alist) - struct mbuf *m; - va_dcl -#endif +key_output(struct mbuf *m, struct socket *so) { struct sadb_msg *msg; int len, error = 0; int s; - struct socket *so; - va_list ap; - - va_start(ap, m); - so = va_arg(ap, struct socket *); - va_end(ap); if (m == 0) panic("key_output: NULL pointer was passed."); @@ -500,7 +488,7 @@ struct protosw keysw[] = { .pr_domain = &keydomain, .pr_protocol = PF_KEY_V2, .pr_flags = PR_ATOMIC|PR_ADDR, - .pr_output = (pr_output_t *)key_output, + .pr_output = key_output, .pr_ctlinput = raw_ctlinput, .pr_init = raw_init, .pr_usrreqs = &key_usrreqs diff --git a/sys/netkey/keysock.h b/sys/netkey/keysock.h index ff2db81..0422517 100644 --- a/sys/netkey/keysock.h +++ b/sys/netkey/keysock.h @@ -71,7 +71,7 @@ struct keycb { extern struct pfkeystat pfkeystat; -extern int key_output(struct mbuf *, ...); +extern int key_output(struct mbuf *m, struct socket *so); extern int key_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *); |