Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2174184pxb; Sat, 21 Nov 2020 11:34:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxj6Y+Z50I2rdJ86+3KPhrJWtEZR/VUCFHTFubTFrN3hn2p4s9OMmNvcuyqn2bTaP/p4LLq X-Received: by 2002:aa7:dc49:: with SMTP id g9mr2569759edu.383.1605987251898; Sat, 21 Nov 2020 11:34:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605987251; cv=none; d=google.com; s=arc-20160816; b=QribDiDk0oSzsU/ltlNaaypMGZOdfCyN3S1PXKwP1E0nqTB8ZrObXWQUrZZjBmdiAY RIlhC9XiyDEns18h7U1NOKzqbQe2As+kuUi+F5uK34s6Ob46U712j+e9/lpysTOqI+so 9F69+4ZgiNORRmzmgiIxb8l4DXfCpZfaIGV7iIwc1XTOO+Qa+20a2trsd9kJrI1utL5W VlZL/No2OtoJdqREJOjFXekhhRWiDVYTVzRELacfUWiAmxDKXMmYgiH6Eb6eQiWWgfhj N7+c2KTJe365z1M96tVg9cka8Gfc1AratVYictX4mkGBpdxinLOWuxIQh2AnWl8yjZiE WEXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=1OYS5b1uSN1TRqj426e3+vICw/ULjb9UjTZ4iKa/cPo=; b=OmNljaoDy2i5qtp/5t5z1OQSA8IQAthK4AFIsP2dTWKeUedLfsi8ShzpDFWcvpcjq4 v8ZqrEixzrHru/o5U5CMVpLP6ng2X4F4q4PDoctE+tIcVxPwoRxV+TahDEbw7fLyhNyJ dx2XUWU8Hu2UTJuiav0hK8Qis77c5wVx9r4LQzNN9YZHIkRhV3IODiVMv64WeV4VqpZZ 6KUiROElG3BSfLyuQiqu8c7IviqVDvdJB+pNplnZ2s5YaEi8NITT0TidWI+2m7/WcC/P vgXeewi0R5hw9Er+0yMqRRcXLQRkjOnJ8mTSNyE+X7jMqB5hUg9AzmSRK6WOPIvWv+PP 5BpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d24si3988052eds.446.2020.11.21.11.33.35; Sat, 21 Nov 2020 11:34:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728443AbgKUTa4 (ORCPT + 99 others); Sat, 21 Nov 2020 14:30:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728404AbgKUTa4 (ORCPT ); Sat, 21 Nov 2020 14:30:56 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30D29C0613CF; Sat, 21 Nov 2020 11:30:56 -0800 (PST) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1kgYar-00C8JD-PD; Sat, 21 Nov 2020 20:30:45 +0100 Message-ID: <106fc65f0459bc316e89beaf6bd71e823c4c01b7.camel@sipsolutions.net> Subject: Re: [PATCH v5 2/3] net: add kcov handle to skb extensions From: Johannes Berg To: Jakub Kicinski Cc: Florian Westphal , Ido Schimmel , Aleksandr Nogikh , davem@davemloft.net, edumazet@google.com, andreyknvl@google.com, dvyukov@google.com, elver@google.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, willemdebruijn.kernel@gmail.com, Aleksandr Nogikh , Willem de Bruijn Date: Sat, 21 Nov 2020 20:30:44 +0100 In-Reply-To: <20201121103529.4b4acbff@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> References: <20201029173620.2121359-1-aleksandrnogikh@gmail.com> <20201029173620.2121359-3-aleksandrnogikh@gmail.com> <20201121160941.GA485907@shredder.lan> <20201121165227.GT15137@breakpoint.cc> <20201121100636.26aaaf8a@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20201121103529.4b4acbff@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Sat, 2020-11-21 at 10:35 -0800, Jakub Kicinski wrote: > On Sat, 21 Nov 2020 19:12:21 +0100 Johannes Berg wrote: > > > So I'm leaning towards reverting the whole thing. You can attach > > > kretprobes and record the information you need in BPF maps. > > > > I'm not going to object to reverting it (and perhaps redoing it better > > later), but I will point out that kretprobe isn't going to work, you > > eventually need kcov_remote_start() to be called in strategic points > > before processing the skb after it bounced through the system. > > > > IOW, it's not really about serving userland, it's about enabling (and > > later disabling) coverage collection for the bits of code it cares > > about, mostly because collecting it for _everything_ is going to be too > > slow and will mess up the data since for coverage guided fuzzing you > > really need the reported coverage data to be only about the injected > > fuzz data... > > All you need is make kcov_remote_start_common() be BPF-able, like > the LSM hooks are now, right? And then BPF can return whatever handle > it pleases. Not sure I understand. Are you saying something should call "kcov_remote_start_common()" with, say, the SKB, and leave it to a mass of bpf hooks to figure out where the SKB got cloned or copied or whatnot, track that in a map, and then ... no, wait, I don't really see what you mean, sorry. IIUC, fundamentally, you have this: - at the beginning, a task is tagged with "please collect coverage data for this handle" - this task creates an SKB, etc, and all of the code that this task executes is captured and the coverage data is reported - However, the SKB traverses lots of things, gets copied, cloned, or whatnot, and eventually leaves the annotated task, say for further processing in softirq context or elsewhere. Now since the whole point is to see what chaos this SKB created from beginning (allocation) to end (free), since it was filled with fuzzed data, you now have to figure out where to pick back up when the SKB is processed further. This is what the infrastructure was meant to solve. But note that the SKB might be further cloned etc, so in order to track it you'd have to (out-of-band) figure out all the possible places where it could be reallocated, any time the skb pointer could change. Then, when you know you've got interesting code on your hands, like in mac80211 that was annotated in patch 3 here, you basically say "oohhh, this SKB was annotated before, let's continue capturing coverage data here" (and turn it off again later by the corresponding kcov_remote_stop(). So the only way I could _possibly_ see how to do this would be to * capture all possible places where the skb pointer can change * still call something like skb_get_kcov_handle() but let it call out to a BPF program to query a map or something to figure out if this SKB has a handle attached to it > Or if you don't like BPF or what to KCOV BPF itself in the future you > can roll your own mechanism. The point is - this should be relatively > easily doable out of line... Seems pretty complicated to me though ... johannes