Commit Graph

711 Commits

Author SHA1 Message Date
maxv
f645db7adb Remove support for non-IKE markers in the kernel. Discussed on tech-net@,
and now in PR/53334. Basically non-IKE markers come from a deprecated
draft, and our kernel code for them has never worked.

Setsockopt will now reject UDP_ENCAP_ESPINUDP_NON_IKE.

Perhaps we should also add a check in key_handle_natt_info(), to make
sure we also reject UDP_ENCAP_ESPINUDP_NON_IKE in the SADB.
2018-05-31 07:03:57 +00:00
maxv
ec343e4518 Constify ipseczeroes, and remove one use of it. 2018-05-31 06:25:41 +00:00
maxv
80da173622 Add a comment and a KASSERT. I remember wondering whether this check was a
problem, since ARC4 has a blocksize of one. Normally ARC4 can't be used in
IPsec.
2018-05-31 06:14:18 +00:00
maxv
824196ce25 style 2018-05-31 05:52:09 +00:00
maxv
d52acbb31e Correctly handle the padding for IPv6-AH, as specified by RFC4302. Seen in
a FreeBSD bug report, by Jason Mader.

The RFC specifies that under IPv6 the complete AH header must be 64bit-
aligned, and under IPv4 32bit-aligned. That's a rule we've never respected.
The other BSDs and MacOS never have either.

So respect it now.

This makes it possible to set up IPv6-AH between Linux and NetBSD, and also
probably between Windows and NetBSD.

Until now all the tests I made were between two *BSD hosts, and everything
worked "correctly" since both hosts were speaking the same non-standard
AHv6, so they could understand each other.

Tested with Fedora<->NetBSD, hmac-sha2-384.
2018-05-30 18:02:40 +00:00
maxv
7aac0885cf Introduce ah_authsiz, which computes the length of the ICV only. Use it in
esp_hdrsiz, and clarify.

Until now we were using ah_hdrsiz, and were relying on the fact that the
size of the AH header happens to be equal to that of the ESP trailer.

Now the size of the ESP trailer is added manually. This also fixes one
branch in esp_hdrsiz: we always append an ESP trailer, so it must always
be taken into account, and not just when an ICV is here.
2018-05-30 17:17:11 +00:00
maxv
de1c7e1421 Apply the previous change in esp_input too, same as esp_output. 2018-05-30 16:49:38 +00:00
maxv
f4ab40f822 Remove dead code, 'espx' is never NULL and dereferenced earlier, so no need
to NULL-check all the time.
2018-05-30 16:43:29 +00:00
maxv
173a0d4a18 Simplify the padding computation. Until now 'padlen' contained the ESP
Trailer (two bytes), and we were doing minus two all the time.

Declare 'tlen', which contains padlen+ESP_Trailer+ICV, and use 'struct
esptail' instead of hardcoding the construction of the trailer. 'padlen'
now indicates only the length of the padding, so no need to do -2.
2018-05-30 16:32:26 +00:00
maxv
bc40d0f4f9 Rename padding -> padlen, pad -> tail, and clarify. 2018-05-30 16:15:19 +00:00
maxv
4b1bee9844 Strengthen and simplify, once more. 2018-05-29 16:50:38 +00:00
ozaki-r
25ec1e8354 Fix non-INET6 builds 2018-05-29 09:25:44 +00:00
maxv
a1d8c752e7 IP6_EXTHDR_GET -> M_REGION_GET, no functional change. 2018-05-18 18:58:51 +00:00
maxv
00ff305a9c Merge ipsec4_input and ipsec6_input into ipsec_ip_input. Make the argument
a bool for clarity. Optimize the function: if M_CANFASTFWD is not there
(because already removed by the firewall) leave now.

Makes it easier to see that M_CANFASTFWD is not removed on IPv6.
2018-05-14 17:34:26 +00:00
ozaki-r
b51605482b Restore TCP header inclusions for TCP_SIGNATURE 2018-05-14 02:16:29 +00:00
maxv
88bfc8dc97 Remove unused calls to nat_t_ports_get. 2018-05-13 18:34:59 +00:00
maxv
336c2eba16 ENOBUFS -> EACCES when updating the replay counter. 2018-05-11 15:43:07 +00:00
maxv
2bf15a966b Clean up, and panic if we call functions that are not supposed to be
called.
2018-05-11 13:50:38 +00:00
maxv
59275f7378 Replace dumb code by M_VERIFY_PACKET. In fact, perhaps we should not even
call M_VERIFY_PACKET here, there is no particular reason for this place to
be more wrong than the rest.
2018-05-10 05:15:14 +00:00
maxv
f813c44d31 Rename ipsec4_forward -> ipsec_mtu, and switch to void. 2018-05-10 05:08:53 +00:00
maxv
858396682a static const on ipsecif4_encapsw 2018-05-09 07:33:31 +00:00
maxv
436305f8d3 Remove a dummy reference to XF_IP4, explain briefly why we don't use
ipe4_xformsw, and remove unused includes.
2018-05-07 09:33:51 +00:00
maxv
20668b06aa Remove now unused 'isr', 'skip' and 'protoff' arguments from ipip_output. 2018-05-07 09:25:04 +00:00
maxv
defd3aa31c Remove unused 'mp' argument from all the xf_output functions. Also clean
up xform.h a bit.
2018-05-07 09:16:46 +00:00
maxv
a3d9b92c8d Clarify IPIP: ipe4_xformsw is not allowed to call ipip_output, so replace
the pointer by ipe4_output, which just panics. Group the ipe4_* functions
together. Localify other functions.

ok ozaki-r@
2018-05-07 09:08:06 +00:00
maxv
69c944f0bf Remove some more dead code. 2018-05-01 08:34:08 +00:00
maxv
187c068ea2 When IP6_EXTHDR_GET fails, return ENOBUFS, and don't log an error (HDROPS
is not supposed to be used here).
2018-05-01 08:27:13 +00:00
maxv
84a7697bfe When the replay check fails, return EACCES instead of ENOBUFS. 2018-05-01 08:16:34 +00:00
maxv
82314dff45 Remove double include, opencrypto/xform.h is already included in
netipsec/xform.h.
2018-05-01 08:13:37 +00:00
maxv
c802aa1f31 Remove unused. 2018-05-01 08:08:46 +00:00
maxv
a7d0cc8839 Fix the checks in compute_ipsec_pos, otherwise m_copydata could crash. I
already fixed half of the problem two months ago in rev1.67, back then I
thought it was not triggerable because each packet we emit is guaranteed
to have correctly formed IPv6 options; but it is actually triggerable via
IPv6 forwarding, we emit a packet we just received, and we don't sanitize
its options before invoking IPsec.

Since it would be wrong to just stop the iteration and continue the IPsec
processing, allow compute_ipsec_pos to fail, and when it does, drop the
packet entirely.
2018-05-01 05:42:26 +00:00
maxv
417565290f Remove useless icmp6.h include, remove manual externs and include in6.h
to get proper definitions, and remove duplicate logic in
ipsec6_common_input_cb.
2018-04-29 14:54:09 +00:00
maxv
fa4d17703e Remove obsolete/dead code, the IP-in-IP encapsulation doesn't work this
way anymore (XF_IP4 partly dropped by FAST_IPSEC).
2018-04-29 14:35:35 +00:00
maxv
d920327205 Remove unused and misleading argument from ipsec_set_policy. 2018-04-29 11:51:08 +00:00
maxv
dc72a4cb13 Remove duplicate prototype. 2018-04-29 07:24:38 +00:00
maxv
68df48a8f0 Remove IPSEC_SPLASSERT_SOFTNET, it has always been a no-op. 2018-04-28 15:45:16 +00:00
maxv
f193022c1a Inline M_EXT_WRITABLE directly, and remove the XXX, there's nothing wrong
in the use of !M_READONLY.
2018-04-28 14:39:34 +00:00
maxv
c075b705a8 Move the ipsec6_input prototype into ipsec6.h, and style. 2018-04-28 14:25:56 +00:00
maxv
19f9cae6f8 Stop using a macro, rename the function to ipsec_init_pcbpolicy directly. 2018-04-28 14:21:03 +00:00
maxv
6f320ea66c Style and remove unused stuff. 2018-04-28 14:01:50 +00:00
maxv
ab18d0d461 Fix the net.inet6.ipsec6.def_policy node, the variable should be
&ip6_def_policy.policy, otherwise we're overwriting other fields of the
structure.
2018-04-28 13:44:19 +00:00
maxv
2f2fea5f0e Remove unused macros. 2018-04-28 13:23:17 +00:00
knakahara
b0c61d654b Fix LOCKDEBUG kernel panic when many(about 200) tunnel interfaces is created.
The tunnel interfaces are gif(4), l2tp(4), and ipsecif(4). They use mutex
itself in percpu area. When percpu_cpu_enlarge() run, the address of the
mutex in percpu area becomes different from the address which lockdebug
saved. That can cause "already initialized" false detection.
2018-04-27 09:55:27 +00:00
maxv
eee3723d53 Stop using m_copy(), use m_copym() directly. m_copy is useless,
undocumented and confusing.
2018-04-26 19:50:09 +00:00
maxv
3e02f4fab8 Remove the M_AUTHIPDGM flag. It is equivalent to M_AUTHIPHDR, both
are set in IPsec-AH, and they are always handled together.
2018-04-24 08:07:05 +00:00
maxv
64956f36ba Remove the kernel RH0 code. RH0 is deprecated by RFC5095, for security
reasons. RH0 was already removed in the kernel's input path, but some
parts were still present in the output path: they are now removed.

Sent on tech-net@ a few days ago.
2018-04-23 07:22:54 +00:00
maxv
48c5ec192c Rename ipip_allow->ipip_spoofcheck, and add net.inet.ipsec.ipip_spoofcheck.
Makes it simpler, and also fixes PR/39919.
2018-04-22 10:25:40 +00:00
christos
87fd18f8e5 s/static inline/static __inline/g for consistency. 2018-04-19 21:50:06 +00:00
maxv
e2c8a66404 Remove extra long file paths from the headers. 2018-04-19 08:27:38 +00:00
maxv
bad5f5991a Remove unused typedef, remove unused arguments from _ipip_input, sync
comment with reality, and change panic message.
2018-04-19 08:16:44 +00:00