From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 07B495A005E for ; Fri, 25 Nov 2022 10:24:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669368247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N/tqBqqlmz54qu0LXYDPVLoSurqPMqqrk9VKXVYdsFw=; b=ds+nMsG4m20zJqTe9ej6HTi2nuD2kmis8vCrdiJAuZkH8c+89YC/5RY8Zm+Gdv81yEUPHD F3dqyzNQR+1ZscKAKONU5+D1vH703yoF5e/fM1SsNte3DzKA73zVFSNLjeiz6V6Fd8M9Zz DxC+aItfYS3jjwBlN0PTHPcdsvY05X8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-399-5OUW4V_LPnS91hKgpDcJmQ-1; Fri, 25 Nov 2022 04:24:06 -0500 X-MC-Unique: 5OUW4V_LPnS91hKgpDcJmQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 727D5101A58E for ; Fri, 25 Nov 2022 09:24:06 +0000 (UTC) Received: from maya.cloud.tilaa.com (ovpn-208-30.brq.redhat.com [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37741C15BA5; Fri, 25 Nov 2022 09:24:06 +0000 (UTC) Date: Fri, 25 Nov 2022 10:23:54 +0100 From: Stefano Brivio To: "Richard W.M. Jones" Subject: Re: [PATCH passt v2 0/7] Add fuzzing Message-ID: <20221125102354.0540ad95@elisabeth> In-Reply-To: <20221117184938.2270462-1-rjones@redhat.com> References: <20221117184938.2270462-1-rjones@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: WKVE5LQPPOSLJXE2CVNGTF5WKIKPHY5O X-Message-ID-Hash: WKVE5LQPPOSLJXE2CVNGTF5WKIKPHY5O X-MailFrom: sbrivio@redhat.com 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: passt-dev@passt.top X-Mailman-Version: 3.3.3 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: On Thu, 17 Nov 2022 18:49:31 +0000 "Richard W.M. Jones" wrote: > With this series, fuzzing actually works, albeit slowly. More on that > below. > > Patches 1 & 2 are the same as before. > > Patch 3 is Stefano Brivio's modified patch (with some changes that we > discussed together on IRC but otherwise unchanged). > > Patch 4 is new, but discussed already upstream: It changes the order > in which EPOLLIN and EPOLLRDHUP events are processed, so that we don't > drop packets when the socket is closed. > > Patches 5 & 6 are the hacks that were needed to get fuzzing to work. > Patch 6 removes all seccomp and other isolation stuff because for > unclear reasons that breaks AFL instrumentation. AFL appears to fork > off a second process, and somehow strace cannot follow that process, > but the second process fails, and that breaks AFL completely. Without > strace data it's rather hard to see what's going on so I didn't > investigate this further. > > Patch 7 adds the fuzzing wrapper and is not greatly changed from > before. However I did have to disable the AFL "fork server" > optimization which somehow doesn't work with passt (it does work fine > with libnbd & nbdkit). > > Speed is not great. I'm getting ~ 75-80 execs/second. Really we want > this to be much higher, since that ultimately governs how fast we can > explore new code paths and find bugs. Ideally well over 1000 execs/s > (per fuzzing process) would be a good target to aim for. (Of course > this depends on the hardware as well.) Applied up to 4/7, thanks! For the rest: I have a local branch with 5/7 and 6/7 fixed up: the 'fuzzing' Makefile target enables the syscalls you listed and avoids prctl(PR_SET_DUMPABLE, 0) in isolation_postfork() via -DFUZZING. I managed to speed things up by skipping some operations not needed for fuzzing, but just a tiny bit (~200 execs/s). I'm looking into switching to persistent mode: https://github.com/AFLplusplus/AFLplusplus/blob/stable/instrumentation/README.persistent_mode.md and introducing frames with special values, as you hinted on IRC, for example one-byte frames with commands such as "go ahead with socket processing then come back to 'tap' frames", so that passt has a chance to do some meaningful socket-side operations before getting back to fuzz input. Patch 7/7 is very useful and appreciated anyway as it demystifies the whole topic for me, and we can probably recycle most of the documentation. I'm not sure yet how/if the wrapper still fits with the stuff I'm looking into. -- Stefano