summaryrefslogtreecommitdiff
path: root/sys/netipsec/ipsec_input.c
AgeCommit message (Collapse)Author
2023-01-27ipsec: remove unnecessary splsoftnetozaki-r
Because the code of IPsec itself is already MP-safe.
2022-08-23Improve IPsec log when no key association found for SA. Implemented by ↵knakahara
ohishi@IIJ.
2022-05-24fix various typos in comment, documentation and log messages.andvar
2022-05-19PR/56840: Andrew Cagney: use the proper polarity hton/ntoh macros (nochristos
functional change). Factor out spi retrieving code into a function.
2019-01-27Merge the [pgoyette-compat] branchpgoyette
2019-01-17Fix ipsecif(4) cannot apply input direction packet filter. Reviewed by ↵knakahara
ozaki-r@n.o and ryo@n.o. Add ATF later.
2018-11-15Remove the 't' argument from m_tag_find().maxv
2018-10-27Localify one function, and switch to C99 types while here.maxv
2018-09-14Use non-variadic function pointer in protosw::pr_input.maxv
2018-05-18IP6_EXTHDR_GET -> M_REGION_GET, no functional change.maxv
2018-04-29Remove useless icmp6.h include, remove manual externs and include in6.hmaxv
to get proper definitions, and remove duplicate logic in ipsec6_common_input_cb.
2018-04-29Remove obsolete/dead code, the IP-in-IP encapsulation doesn't work thismaxv
way anymore (XF_IP4 partly dropped by FAST_IPSEC).
2018-04-28Remove IPSEC_SPLASSERT_SOFTNET, it has always been a no-op.maxv
2018-04-19Remove extra long file paths from the headers.maxv
2018-04-18Remove unused malloc.h include.maxv
2018-04-17fix commentsmaxv
2018-04-15Introduce a m_verify_packet function, that verifies the mbuf chain of amaxv
packet to ensure it is not malformed. Call this function in "points of interest", that are the IPv4/IPv6/IPsec entry points. There could be more. We use M_VERIFY_PACKET(m), declared under DIAGNOSTIC only. This function should not be called everywhere, especially not in places that temporarily manipulate (and clobber) the mbuf structure; once they're done they put the mbuf back in a correct format.
2018-02-26Dedup: merge ipsec4_in_reject and ipsec6_in_reject into ipsec_in_reject.maxv
While here fix misleading comment. ok ozaki-r@
2018-02-26If 'skip' is lower than sizeof(struct ip), we are in trouble. So remove amaxv
nonsensical branch, and add a panic at the beginning of the function.
2018-02-26m is never allowed to be NULL, so turn the KASSERT (and the null check)maxv
to a panic.
2018-02-26Merge some minor (mostly stylistic) changes from last week.maxv
2018-02-21Argh, in my previous commit in this file I forgot to fix the IPv6maxv
entry point; apply the same fix there.
2018-02-21Extend these #ifdef notyet. The m_copydata's in these branches are wrong,maxv
we are not guaranteed to have enough room for another struct ip, and we may crash here. Triggerable remotely, but after authentication, by sending an AH packet that has a one-byte-sized IPIP payload.
2018-02-08Remove unused net_osdep.h include.maxv
2018-01-24Fix the iteration: IPPROTO_FRAGMENT options are special, in the sensemaxv
that they don't have a 'length' field. It is therefore incorrect to read ip6e.ip6e_len, it contains garbage. I'm not sure whether this an exploitable vulnerability. Because of this bug you could theoretically craft 'protoff', which means that you can have the kernel patch the nxt value at the wrong place once the packet is decrypted. Perhaps it can be used in some unusual MITM - a router that happens to be between two IPsec hosts adds a frag6 option in the outer IPv6 header to trigger the bug in the receiver -, but I couldn't come up with anything worrying.
2018-01-24ipsec4_fixup_checksum calls m_pullup, so don't forget to do mtod() again,maxv
to prevent use-after-free. In fact, the m_pullup call is never reached: it is impossible for 'skip' to be zero in this function, so add an XXX for now.
2018-01-23Add missing NULL-checking for m_pullup (CID 1427770: Null pointer ↵ozaki-r
dereferences (NULL_RETURNS))
2018-01-23KNF: replace soft tabs with hard tabsozaki-r
2017-08-03Introduce KEY_SA_UNREF and replace KEY_FREESAV with it where sav will never ↵ozaki-r
be actually freed in the future KEY_SA_UNREF is still key_freesav so no functional change for now. This change reduces diff of further changes.
2017-08-03Remove unnecessary KEY_FREESAV in an error pathozaki-r
sav should be freed (unreferenced) by the caller.
2017-07-21Stop setting mtag of PACKET_TAG_IPSEC_IN_DONE because there is no users anymoreozaki-r
2017-07-12Omit unnecessary NULL checks for sav->sahozaki-r
2017-07-07Rename key_alloc* functions (NFC)ozaki-r
We shouldn't use the term "alloc" for functions that just look up data and actually don't allocate memory.
2017-07-06Simplify; we can assume sav->tdb_xform cannot be NULL while it's validozaki-r
2017-07-05Remove codes for PACKET_TAG_IPSEC_IN_CRYPTO_DONEozaki-r
It seems that PACKET_TAG_IPSEC_IN_CRYPTO_DONE is for network adapters that have IPsec accelerators; a driver sets the mtag to a packet when its device has already encrypted the packet. Unfortunately no driver implements such offload features for long years and seems unlikely to implement them soon. (Note that neither FreeBSD nor Linux doesn't have such drivers.) Let's remove related (unused) codes and simplify the IPsec code.
2017-06-28PR/52346: Frank Kardel: Fix checksumming for NAT-Tchristos
See XXX for improvements.
2017-05-19Introduce IPSECLOG and replace ipseclog and DPRINTF with itozaki-r
2017-05-11Make ipsec_address() and ipsec_logsastr() mpsafe.ryo
2017-04-19Retire ipsec_osdep.hozaki-r
We don't need to care other OSes (FreeBSD) anymore. Some macros are alive in ipsec_private.h.
2017-04-18Convert IPSEC_ASSERT to KASSERT or KASSERTMSGozaki-r
IPSEC_ASSERT just discarded specified message...
2017-04-18Remove __FreeBSD__ and __NetBSD__ switchesozaki-r
No functional changes (except for a debug printf). Note that there remain some __FreeBSD__ for sysctl knobs which counerparts to NetBSD don't exist. And ipsec_osdep.h isn't touched yet; tidying it up requires actual code changes.
2017-04-06Prepare netipsec for rump-ificationozaki-r
- Include "opt_*.h" only if _KERNEL_OPT is defined - Allow encapinit to be called twice (by ifinit and ipe4_attach) - ifinit didn't call encapinit if IPSEC is enabled (ipe4_attach called it instead), however, on a rump kernel ipe4_attach may not be called even if IPSEC is enabled. So we need to allow ifinit to call it anyway - Setup sysctls in ipsec_attach explicitly instead of using SYSCTL_SETUP - Call ip6flow_invalidate_all in key_spdadd only if in6_present - It's possible that a rump kernel loads the ipsec library but not the inet6 library
2017-01-16Make ip6_sprintf(), in_fmtaddr(), lla_snprintf() and icmp6_redirect_diag() ↵ryo
mpsafe. Reviewed by ozaki-r@
2016-06-10Avoid storing a pointer of an interface in a mbufozaki-r
Having a pointer of an interface in a mbuf isn't safe if we remove big kernel locks; an interface object (ifnet) can be destroyed anytime in any packet processing and accessing such object via a pointer is racy. Instead we have to get an object from the interface collection (ifindex2ifnet) via an interface index (if_index) that is stored to a mbuf instead of an pointer. The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9) for sleep-able critical sections and m_{get,put}_rcvif that use pserialize(9) for other critical sections. The change also adds another API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition moratorium, i.e., it is intended to be used for places where are not planned to be MP-ified soon. The change adds some overhead due to psref to performance sensitive paths, however the overhead is not serious, 2% down at worst. Proposed on tech-kern and tech-net.
2016-01-21Revert previous: ran cvs commit when I meant cvs diff. Sorry!riastradh
Hit up-arrow one too few times.
2016-01-21Give proper prototype to ip_output.riastradh
2015-03-30Tidy up opt_ipsec.h inclusionsozaki-r
Some inclusions of opt_ipsec.h were for IPSEC_NAT_T and are now unnecessary. Add inclusions to some C files for IPSEC_DEBUG.
2014-03-08Mark a variable __diagusedozaki-r
2013-11-03- apply some __diagusedmrg
- remove unused variables - move some variables inside their relevant use #ifdef
2013-06-04PR/47886: Dr. Wolfgang Stukenbrock: IPSEC_NAT_T enabled kernels may accesschristos
outdated pointers and pass ESP data to UPD-sockets. While here, simplify the code and remove the IPSEC_NAT_T option; always compile nat-traversal in so that it does not bitrot.