From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202608 header.b=G8EjHzYi; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id A6DD75A0265 for ; Fri, 14 Aug 2026 07:40:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202608; t=1786686041; bh=g+BzscvD5M+3k+62Y6jvKWixXHWouixZqWifas+Kdyg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G8EjHzYiflxB5GsGw4Dv+Ib+pKLo2to+5GDoxTkBKLS8mV37L+XXqcq28owBN3iij SkUr7zBG2NlXIWsummNWoiE045DvOqnd379Oc24vWc9C27wTJmqXWXPLN2pAGbOnCn FDJJJo/tkWsRk6o2STd7LyRgO3pcQsCASaYG9Iz3iACVRFPBNIf/xcqc7wq7ZJQ2MT 7dshS+OJIAns8nuc6rn6+RukWvPR51/6Yo81AVV4a6TnjwbwZF3AqjEWFyrhR84hXW N2cgDdfjnKjyeEePXHovIf/eQxb5zvg9atwJEVBXU7SJVo+2qaGK9cpz7Rybuy39q2 k/kb3DKaw+0+g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4hLrfx66VZz4wHf; Fri, 14 Aug 2026 15:40:41 +1000 (AEST) Date: Fri, 14 Aug 2026 15:40:35 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 5/5] fuzz: Add test server for bidirectional protocol fuzzing Message-ID: References: <20260812072630.3235261-1-anskuma@redhat.com> <20260812072630.3235261-6-anskuma@redhat.com> <20260813095323.4c2719bd@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dA8LPj+/iKbtPqOA" Content-Disposition: inline In-Reply-To: <20260813095323.4c2719bd@elisabeth> Message-ID-Hash: MRIMEJBOYEQKLN4OQTQ767BWJLMA5KUQ X-Message-ID-Hash: MRIMEJBOYEQKLN4OQTQ767BWJLMA5KUQ X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Anshu Kumari , passt-dev@passt.top, aerosound161@gmail.com, abdobngad@gmail.com, lvivier@redhat.com X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --dA8LPj+/iKbtPqOA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 13, 2026 at 09:53:24AM +0200, Stefano Brivio wrote: > On Wed, 12 Aug 2026 12:56:28 +0530 > Anshu Kumari wrote: >=20 > > Add fuzz-server that acts as passt's network peer > > during fuzzing. >=20 > To me, this part makes sense. But this one: >=20 > > It connects to passt's UNIX socket >=20 > much less, while: >=20 > > and listens on 127.0.0.1:9999 for TCP connections. >=20 > this is the part that I expected instead. Otherwise it's not just > passt's network peer, it's the guest as well. >=20 > > UNIX socket path: responds to ARP requests and TCP SYNs with > > stateless replies (swapped addresses, fixed ISN). Responses > > are XOR'd with AFL++ shared memory data so the fuzzer can > > mutate server behavior. >=20 > This looks rather complicated to me. It does. > The approach I was suggesting with a test server is the following: >=20 >=20 > ,- exchanges guest-side data with ------------. > | ,---------|---------. > | ,--| passt | > | / '-.---------------^-' > ,---|---. / | connect(), | accept(), > | AFL++ |-- shares memory with ---| | send data, | reply with > '---|---' \ | etc. | data, etc. > | \ ,-v---------------'-. > | '--| test server | > | '---------|---------' > '- exchanges host-side data with -------------' >=20 > ...at least in its basic form. Eventually, the test server should be > able to connect to passt itself (and we could call it "test peer" at > that point). So, I agree that to meaningfully fuzz things, we want the fuzzer to be able to control data on both the guest and host side. I can see two basic approaches: A) Alter passt/pasta so that instead of directly communicating with external entities (either guest or host side) we use mocked versions which retrieve data from AFL. We can do that either at the system call level, or at a higher helper function level, the lower level we go, the more of the "normal" passt code we're exercising, but doing at a slightly higher level might be easier to implement B) Run passt/pasta in an environment where we can intercept the external transfers to a test server / test peer / test guest which in turn responds based on data from AFL. Both the current draft and the sketch diagram Stefano has provided are a hybrid of both approaches, so far I'm not seeing a clear advantage to that over going all one way or the other. (B) is quite easy to do guest side - we just connect a "test guest" to passt's socket. Approach B is much harder for host side. The current draft has a test server listening on a single address. But that means the fuzzing is fundamentally incapable of finding bugs involving talking to multiple peers at once. Worse, we have to constrain the construction of guest side data so that we talk to the test server not something else, and that's one of the things we most want to fuzz. To really take approach B for the host side we'd need to intercept *all* host side network traffic regardless of address. Probably easiest way to do that would be put the whole thing inside another netns. That outside netns would have a default route to a tap device, and on the other side of the tap device would be a test server serving up frames built from the fuzzer output. It's probably easier to co-ordinate if the host side and guest side test server is the same, so we'd have: ,-------. ,-------------. | AFL++ |-- shares memory with ---| test peer | '-------' '--v------v---' | | /-tap device-/ | | | /- test netns ----------^-------------------|-------------\ | | | | ,--------. | | | | passt >----------------/ | | '--------' | \---------------------------------------------------------/ The test peer generates host side frames via the tap device, and guest side frames via the Unix socket. It could also be done with pasta, like this: ,-------. ,-------------. | AFL++ |-- shares memory with ---| test peer | '-------' '--v------v---' | | /-tap device-/ packet | socket /- test netns ----------^-------------------|-------------\ | | | | ,--------. ,----------------|---. | | | pasta >-tap device-< guest netns * | | | '--------' '--------------------' | \---------------------------------------------------------/ The order it generates host vs. guest frames should also come from the fuzzer, not be fixed. At least theoretically, this is non-invasive: it could run with an unmodified passt/pasta. Except that - AFL would still need coverage feedback from passt/pasta - It wouldn't allow us to simulate odd timings (except by actually expending real time) - The various interposing layers will probably slow down fuzzing. =20 So, I rather suspect it will work better to go fully to approach A: no test peer at all, instead passt itself is modified to use mocked versions of all the external syscalls to slurp data from AFL. The draft series already does this for epoll_wait() and recv*(), but we'd need to also do that for recv*() on the tap socket, connect(), accept(), TCP_INFO and probably others. We'd also need to mock "sending" calls, send(), write() and shutdown() at least - but those could probably be no-ops. This is more invasive, of course. It also means we need to deal with the case where AFL generates a syscall results that should be impossible - that should move onto the next case ASAP, but not be flagged as a passt bug. On the other hand, this approach should be fast, and since we can also mock clock_gettime(), the fuzzer can potentially find timer logic bugs that would only occur after hours or days in real time. > As far as I understood, it's not trivial to make the same instance > of AFL++ share memory with two processes at the same time, so the > memory-sharing path might need to take a more complicated turn, for > example there could be a wrapper starting both passt and the test > server and sharing memory with them, or passt could _additionally_ > (using a special out-of-band fuzzing channel) share data from AFL++ > with the test server. >=20 > An example of communication below (but events don't necessarily need > to be in this order, this is just an example). For simplicity, let's > ignore the fact that AFL++ might not directly share memory with passt > and test server, and assume there are three areas of memory that > AFL++ directly controls: >=20 > a. shared with passt: an array of struct epoll_event, 'ev' >=20 > b. shared with passt: the kind of tap-side buffer you implemented in > 4/5, 'buf' >=20 > c. shared with the test server: a separate buffer, 'test_buf' >=20 > Example: >=20 > 1. AFL++ writes an EPOLLIN event in 'ev' with type > EPOLL_TYPE_TAP_PASST, of some data in 'buf', and some data in > 'test_buf' >=20 > 2. AFL++ starts passt and the test server >=20 > 3. passt reads the EPOLL_TYPE_TAP_PASST event from 'ev', reads data > from 'buf' and hands it to passt_tap_handler() >=20 > 4. this happens to be have Ethernet, IP, and TCP headers, with the > SYN flag set, and destination address set to the address of the > test server (we might want to force all this, at least initially, > or give it as a hint to AFL++ somehow), so passt connects to > the test server >=20 > 5. the test server accepts the connection, and sends the contents > of 'test_buf' on it (for the test server, this is directly > payload, without headers, as they don't make sense there). I'm > not sure if we should have a different set of events (maybe we > need a "play script" for the server, in case?) >=20 > 6. this generates an EPOLLOUT event for passt. It's not in 'ev', > it's a regular epoll_wait() (I think we could have an > epoll_wait() loop where we additionally read one event from > 'ev' for every iteration, or something like that) >=20 > 7. passt marks the connection as established and inserts it in the > flow table >=20 > 8. passt reads the data sent from the test server and generates > whatever TCP data packet to the "guest" (it might simply be > a sink) >=20 > ...and this attempt ends here because AFL++ generated a single > event for passt, but there could be more (this should also be > decided by AFL++). >=20 > Would something like this make sense? --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --dA8LPj+/iKbtPqOA Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmp+qkYACgkQzQJF27ox 2Gd7nRAAnN/3XR3/NacDAE9f9kqW7nFHfcDPpramrpHsdYvsvAfnGV7oLk1qOUAp hU0X6cNd2TDH+V8kHuMh+m4DH5xbcBEAWCDot+iYZcWehPCUuB1PAbCy/A0ViB/o gkLo3RD4Iwj5He7F8XH7g6qP2stQyCEut6JN3jXYaR5MeHJlzJHJbzpd8WxiW+B5 T8iuJRcwzha+tTpB73dOMONjFy53lL78evURE6MwYzFcXYQWVXH507jdN8R9d0tz 9T542Hv0z5aPZs5m0iu8ruxfPQri7+CYTCP0eXFGWVIOY2IIG+/wvjVjo3oC6I8R +tw48M/9zJgWZx2pmyktxUd3d02SBAdmH/CZTAeiL8Et5Y7TFrM9Y9Ns0y31eTUO C/kNKjrPmZP7LcGDnfCA1dejqvCmWuQxhg+aHJwpW4mae2Ya8P1K0rtg2gEy+AF9 6MvleBt40057xLBIZKjsw0pZiFOv4sZtoT/OhfKvC4XDk0EyBYNXNFneZmNUjuED 24Nw9za2xM/8atXu9ZdDpuEW0kFvXg6KEIqeYxphr2FuDwEBW2U/CjoojVF7VE78 bEt68kmeoVBKjANIuTEp+rnljEFw7XDigQ++f7QDAAuGjXEVyBTER1I+Y4fR0jRG 323jVpmBzZrt9h4BTwRSfxAuvjsOGvpydNYtsSARK6M4tDTMnoE= =ybNl -----END PGP SIGNATURE----- --dA8LPj+/iKbtPqOA--