Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6289947ybx; Mon, 11 Nov 2019 06:58:00 -0800 (PST) X-Google-Smtp-Source: APXvYqzT+0eLIu2WHj7sVjed9UX6CCiqC1yvTlpW6NkVSmMOhpXJ8UlvbNRQuY7wX0dok7NYxG6R X-Received: by 2002:a50:958d:: with SMTP id w13mr27211729eda.243.1573484280455; Mon, 11 Nov 2019 06:58:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573484280; cv=none; d=google.com; s=arc-20160816; b=Wf4OtG8eQqQ0m0RrRrMjae0Lzxxz8mzIHCR5f8JM3Rv/subG4EnVOb3wVLpfSCErA2 WJvrRKNiQVw/rG3JC3TPHT1cqgF5cxVg+2DqlnluXjwpN6EVO+edgpWOld4STXZrAp+8 jNJKew7wSlBXq7NdsSKxC0LwyqIZOoB9rYxBH5SGFG0H2t3gR3M9fOoyJxCzN00JWGK6 4KFQfQ0wi4AUgJEjm+l11kRuX4JJW0BJ/59VmKoOrB/Lil+h9rnLEbsVR6Ik1CQDmUng YrHLs5/2b7k5uFGso8PJhApJi1UOzJ4l00XI3QyTifljyFYIdNachb34FnNM7r2w50bH JrwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=60Q7vS2CmK4AK0J+x4ZvzH3U+jveBIMJrpq1nfCbPwQ=; b=c/nX5+DnWHTHW9yz23fw/FPBRFlntHNbuJLjbEFJc7BbwnGAxFQTkgrYe4zc9exssH ZIdN40Dr12stoWoHyNmxKy4Com/30frl3X28UWQWh84sjUyXS7J3sbycrxHJbJ1KtnUb tdg0tLeadNE6J1P2SqKWN2FegZTgbyZiA+xtzEx9rDfIkqIg9b+vnOfRbP8SzZ0AeQig kpj63On/d35B7HAO4gdQRzu1fhIJkS5nRf1Js0P7wmkaWgk06+PAfTuLGMzS+J6Ya9hX cc1jQ4LbdfM+yeYGR+sfv8Q8QgiNH4bc1C0tTE9yGVZsdfV3uB1X2IkT3oPdwNCLXtjN HesQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZBx0shAX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c23si9694285ejk.143.2019.11.11.06.57.35; Mon, 11 Nov 2019 06:58:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZBx0shAX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726949AbfKKO4w (ORCPT + 99 others); Mon, 11 Nov 2019 09:56:52 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:30423 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726889AbfKKO4w (ORCPT ); Mon, 11 Nov 2019 09:56:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573484211; 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=60Q7vS2CmK4AK0J+x4ZvzH3U+jveBIMJrpq1nfCbPwQ=; b=ZBx0shAXRbN6UNyfZwLIphjceKvNoxxqDv4l9TWII5Vf9sBbaUuEmkjRObn6oTRMHlssKr lRu93hzh+NcvSISF2Pwt99homsVliFY4roCVLI5nx7N6qHoDuuuKqupZJY4MMgLxYPUkqZ /ttJtMgGFoFSAFn/xvrVwRFUQUL4nWI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-Ov9PzoJrP_udTUFq1cP-gQ-1; Mon, 11 Nov 2019 09:56:45 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8736D18B9FDA; Mon, 11 Nov 2019 14:56:44 +0000 (UTC) Received: from krava (unknown [10.40.205.88]) by smtp.corp.redhat.com (Postfix) with SMTP id ED0EE60904; Mon, 11 Nov 2019 14:56:40 +0000 (UTC) Date: Mon, 11 Nov 2019 15:56:40 +0100 From: Jiri Olsa To: Alexey Budankov Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Namhyung Kim , Andi Kleen , linux-kernel Subject: Re: [RFC] perf session: Fix compression processing Message-ID: <20191111145640.GB26980@krava> References: <20191103222441.GE8251@krava> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: Ov9PzoJrP_udTUFq1cP-gQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 11, 2019 at 05:38:49PM +0300, Alexey Budankov wrote: >=20 > On 04.11.2019 1:24, Jiri Olsa wrote: > > hi, > > > --- > > The compressed data processing occasionally fails with: > > $ perf report --stdio -vv > > decomp (B): 44519 to 163000 > > decomp (B): 48119 to 174800 > > decomp (B): 65527 to 131072 > > fetch_mmaped_event: head=3D0x1ffe0 event->header_size=3D0x28, mmap_si= ze=3D0x20000: fuzzed perf.data? > > Error: > > failed to process sample > > ... > >=20 > > It's caused by recent fuzzer fix that does not take into account > > that compressed data do not need to by fully present in the buffer, > > so it's ok to just return NULL and not to fail. > >=20 > > Fixes: 57fc032ad643 ("perf session: Avoid infinite loop when seeing inv= alid header.size") > > Link: http://lkml.kernel.org/n/tip-q1biqscs4stcmc9bs1iokfro@git.kernel.= org > > Signed-off-by: Jiri Olsa > > --- > > tools/perf/util/session.c | 8 +++++--- > > 1 file changed, 5 insertions(+), 3 deletions(-) > >=20 > > diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c > > index f07b8ecb91bc..3589ed14a629 100644 > > --- a/tools/perf/util/session.c > > +++ b/tools/perf/util/session.c > > @@ -1959,7 +1959,7 @@ static int __perf_session__process_pipe_events(st= ruct perf_session *session) > > =20 > > static union perf_event * > > fetch_mmaped_event(struct perf_session *session, > > -=09=09 u64 head, size_t mmap_size, char *buf) > > +=09=09 u64 head, size_t mmap_size, char *buf, bool decomp) >=20 > bools in interface make code less transparent. >=20 > > { > > =09union perf_event *event; > > =20 > > @@ -1979,6 +1979,8 @@ fetch_mmaped_event(struct perf_session *session, > > =09=09/* We're not fetching the event so swap back again */ > > =09=09if (session->header.needs_swap) > > =09=09=09perf_event_header__bswap(&event->header); > > +=09=09if (decomp) > > +=09=09=09return NULL; > > =09=09pr_debug("%s: head=3D%#" PRIx64 " event->header_size=3D%#x, mmap= _size=3D%#zx: fuzzed perf.data?\n", > > =09=09=09 __func__, head, event->header.size, mmap_size); > > =09=09return ERR_PTR(-EINVAL); > > @@ -1997,7 +1999,7 @@ static int __perf_session__process_decomp_events(= struct perf_session *session) > > =09=09return 0; > > =20 > > =09while (decomp->head < decomp->size && !session_done()) { > > -=09=09union perf_event *event =3D fetch_mmaped_event(session, decomp->= head, decomp->size, decomp->data); > > +=09=09union perf_event *event =3D fetch_mmaped_event(session, decomp->= head, decomp->size, decomp->data, true); >=20 > It looks like this call can be skipped, at all, in this case. not sure what you mean, we are in decomp code no? jirka