aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2021-06-14Add mtod_check()Marc-André Lureau2-0/+12
Recent security issues demonstrate the lack of safety care when casting a mbuf to a particular structure type. At least, it should check that the buffer is large enough. The following patches will make use of this function. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-06-07icmp: Support falling back on trying a SOCK_RAW socketSamuel Thibault1-22/+38
This allows pings provided that the process is running as root (or has some capability to create raw sockets). Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-06-07poll_fd: add missing fd registration for UDP and ICMPSamuel Thibault2-0/+2
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-06-07icmp: Document the use of UDP echo serviceSamuel Thibault1-0/+5
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-06-06mbuf: Avoid warningSamuel Thibault1-0/+1
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-06-06timer_mod: explicit that expire_time is in ms, not nsSamuel Thibault1-1/+1
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-06-06Merge branch 'valgrind' into 'master'Samuel Thibault12-5/+148
mbuf: Add debugging helpers for allocation See merge request slirp/libslirp!90
2021-06-06mbuf: Add debugging helpers for allocationSamuel Thibault12-12/+125
This adds a few helpers for debugging mbuf allocations when running in debugging mode (lsan, valgrind, etc.) - We do not want to cache allocations, so always set M_DOFREE to prevent us from putting any mbuf in it. - We want to update the mbuf allocation owner on function call for more precise leak reporting. Based on Jeremy Marchand's fuzzing work. Signed-off-by: jeremy marchand <jeremy.marchand@etu.u-bordeaux.fr> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-06-06Check that we have the expected room before m_dataSamuel Thibault7-0/+30
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-06-06Merge branch 'ncsi_pack' into 'master'Samuel Thibault2-33/+33
ncsi: make ncsi_calculate_checksum work with unaligned data Closes #43 See merge request slirp/libslirp!89
2021-06-03ncsi: Mark ncsi headers with SLIRP_PACKEDSamuel Thibault1-29/+29
Fixes #43
2021-06-03ncsi: make ncsi_calculate_checksum work with unaligned dataSamuel Thibault1-4/+4
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-05-25src/ip: Fix typos in commentsThomas Huth2-2/+2
Found with the "codespell" utility. Signed-off-by: Thomas Huth <thuth@redhat.com>
2021-05-09SlirpCb: explicit that it is fine for a guest to drop framesSamuel Thibault1-5/+5
2021-05-09ndp_table: For unspecified address, return broadcast ethernet addressSamuel Thibault1-1/+6
We cannot let the guest crash libslirp by making it answer a tftp request such as shown in https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33873 https://gitlab.com/qemu-project/qemu/-/issues/111 unspecified addresses may also be used for non-configured devices, so it makes sense to use the broadcast ethernet address in that case, just like we do with IPv4.
2021-05-07Remove alloca() call in get_dns_addr_resolv_conf()Philippe Mathieu-Daudé1-5/+9
The ALLOCA(3) man-page mentions its "use is discouraged". For now get_dns_addr_resolv_conf() is called with pointer to a in_addr/in6_addr structure, and its size. Declare a union of these structures on the stack, able to hold both of them. This allows us to remove the alloca() call, keeping the buffer on the stack. Add an assertion in the unlikely case another inet address is handled by this function. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20210507133212.1952121-1-philmd@redhat.com>
2021-04-12Merge branch 'lazy-ipv6-resolution' into 'master'Samuel Thibault6-13/+130
Perform lazy guest address resolution for IPv6 See merge request slirp/libslirp!81
2021-04-12Perform lazy guest address resolution for IPv6Doug Evans6-13/+130
Previously QEMU rejected IPv6 host-forward attempts that had an unspecified guest address. This is because for IPv6 the guest's IP address isn't necessarily known ahead of time: Libslirp only provides a "stateless" DHCPv6 server, which if the macaddr is random then the IPv6 address is random too. This patch changes this to do the address resolution lazily, in the hopes that the guest's IPv6 address is known at the time the user wants to connect to the guest. The request can still fail if the guest doesn't have an IPv6 address yet (e.g., it's still early in the boot). Such requests are immediately rejected. Signed-off-by: Doug Evans <dje@google.com>
2021-04-07Merge branch 'listen_v6only' into 'master'Samuel Thibault6-2/+18
Listen v6only See merge request slirp/libslirp!77
2021-04-06Merge branch 'newtcpcb-no-fail' into 'master'Samuel Thibault1-4/+1
tcpx_listen: tcp_newtcpcb doesn't fail See merge request slirp/libslirp!79
2021-04-06slirp_add_host*fwd: Ensure all error paths set errnoDoug Evans4-2/+14
Debugging bind/listen failures without errno can get painful. Signed-off-by: Doug Evans <dje@google.com>
2021-03-29tcpx_listen: tcp_newtcpcb doesn't failDoug Evans1-4/+1
Signed-off-by: Doug Evans <dje@google.com>
2021-03-29Remove slirp_add/remove_ipv6_hostfwdSamuel Thibault7-102/+0
They are superseded by slirp_add/remove_hostxfwd Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-03-17Merge branch 'verbose-if-start' into 'master'Samuel Thibault3-1/+10
Move DEBUG_CALL("if_start") to DEBUG_VERBOSE_CALL See merge request slirp/libslirp!78
2021-03-17hostfwd: Add SLIRP_HOSTFWD_V6ONLY flagSamuel Thibault6-2/+18
That allows to request binding on v6 addresses only. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-03-17Move DEBUG_CALL("if_start") to DEBUG_VERBOSE_CALLDoug Evans3-1/+10
This debugging printf reduces the overall S/N ratio of debug output in the normal case, so separate it out. Signed-off-by: Doug Evans <dje@google.com>
2021-03-05Add ipv4/ipv6-agnostic host forwarding functionsSamuel Thibault3-1/+85
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-03-05udpx/tcpx_listen: Use struct sockaddr * typesSamuel Thibault4-22/+32
This actually makes most of the code simpler.
2021-03-04Merge branch 'neighbor-info' into 'master'Samuel Thibault9-23/+91
Neighbor info See merge request slirp/libslirp!71
2021-03-03New API routine slirp_neighbor_infoDoug Evans4-4/+50
This will be called from QEMU to dump the ARP/NDP tables. ndpentry.eth_addr type changed from unsigned char to uint8_t to be consistent with other macaddr objects. Ditto for slirp_arphdr.{ar_sha,ar_tha}. Signed-off-by: Doug Evans <dje@google.com>
2021-03-03m_cleanup_list: make staticDoug Evans1-1/+1
Was causing compilation failures with -Werror=missing-prototypes.
2021-03-02New utility slirp_ether_ntoaDoug Evans5-19/+41
... and call it everywhere a macaddr is pretty-printed. Signed-off-by: Doug Evans <dje@google.com>
2021-03-01sockaddr_*: add missing const qualifiersSamuel Thibault1-7/+7
2021-03-01udpx/tcpx_listen: Add missing const qualifierSamuel Thibault4-16/+16
2021-03-01Merge branch 'x_listen' into 'master'Samuel Thibault4-97/+86
Expose udpx_listen and tcpx_listen as taking sockaddr See merge request slirp/libslirp!74
2021-03-01Merge branch 'macos-pri' into 'master'Samuel Thibault1-3/+11
Disable polling for PRI on MacOS Closes #35 See merge request slirp/libslirp!73
2021-03-01Disable polling for PRI on MacOSSamuel Thibault1-3/+11
Fixes #35. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-02-28Expose udpx_listen and tcpx_listen as taking sockaddrSamuel Thibault4-97/+86
This generalizes adding hostfwd, and opens the path for cross ipv4/6 forward. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-02-28socket.h: add missing sbuf.h inclusionSamuel Thibault1-0/+1
to get struct sbuf Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-02-28TODO for generalizing the hostfwd callsSamuel Thibault3-0/+5
2021-02-18m_cleanup: set qh_link and qh_rlink to the list headjeremy marchand1-0/+2
This should ensure the lists are considered empty after the cleanup
2021-02-18m_cleanup: fix memory leaksjeremy marchand1-0/+2
m_cleanup didn't cleanup the if_batchq and if_fastq queues, resulting in a memory leak.
2021-02-18refactor m_cleanup as requested in slirp/libslirp!68jeremy marchand1-9/+9
2021-02-18m_free: remove the M_EXT flag after freeing the mbuf extended bufferjeremy marchand1-0/+1
mbufs added to the freelist shouldn't keep the M_EXT flag as they can be recycled and the new owner could try to access the freed extended buffer.
2021-02-18ip6_output: fix memory leak on fast-sendndp-leakSamuel Thibault1-0/+3
When emitting NDP Neighbour Sollicitations, ip6_output immediately calls if_encap without going through any queue. if_encap however does not free the mbuf, so ip6_output has to do it. This was leaking one mbuf per NDP NS sent by slirp. Hopefully the guest was not using more than NDP_TABLE_SIZE (16) IPv6 addresses, in which case it was limited to a bound number, but more addresses would result to leaks.
2021-02-16Reject host forwarding to ipv6 "addr-any"Doug Evans1-0/+8
Libslirp currently only provides a stateless DHCPv6 server, and thus can't do the "addr-any -> guest IP address" translation that is done for ipv4. Until a stateful DHCPv6 server is available, reject addr-any. Signed-off-by: Doug Evans <dje@google.com>
2021-02-11tcpx_listen: Pass sizeof(addr) to memsetDoug Evans1-2/+2
Signed-off-by: Doug Evans <dje@google.com>
2021-02-11Complete timeout documentationSamuel Thibault1-1/+1
2021-02-11Document the slirp APISamuel Thibault1-9/+55
2021-02-03Merge branch 'ipv6-host-fwd-9-patch' into 'master'Samuel Thibault7-44/+191
Add ipv6 host forward support See merge request slirp/libslirp!62