Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3795804ybv; Mon, 10 Feb 2020 06:34:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzyGodHS5JqwRChtbnMvblk2XWcXnFU/TeZGY6hW5/8+pc5JcqPad95DvaM0jp5wjlDzENx X-Received: by 2002:aca:d5d3:: with SMTP id m202mr946476oig.161.1581345249541; Mon, 10 Feb 2020 06:34:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581345249; cv=none; d=google.com; s=arc-20160816; b=IVetVgdNkznBEio1iCpUTHyOd8uIRdGfXlbciAgWbM4cvtpj/jxZaGOAN05VfmXm/u Rv4lcW8eiCtwyEnOk3QgPk9B1EyZL91u1aXZuUv5CNk3dXmgxdk5okPRC18Sg67DOEJP J8Iq53s+jqzGMPC3ISBnH/2PqtDsmjEGVN8g41rHJ60jgU3FVkh5DC2BodgFi7lil17N QhVwRyBxU/P7NGiRkzzNdO82ZjJKenItn/M3gA0Hjlz13Zn7fjgcmtA4m4L3dNXWgehV e0hPqG5Nz50edFSbVr5lnaVCYDCWbuRbyzb5tsUEp/YtI7zwzqbxkuXagNzRrlWCzR9B VNNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5JMAB8zAN2doKjfcBvZKwXv2it6+0l6lnm3pLm0Egvs=; b=K8NRSlEj4ySwgOJH+w5mHc2EyskC/AcAZKIkWj1h0fhdz+VVDWZY4sWH8QHBWuuGmc 68nPrIyfll/ppULfBJp+OGpYUeC7TLbH9Gy/+RFb50NE0a/b/vU/cU2rZE3+LN+cKXaj 8PFeUBQIq02cugBwWey6IxXfeW3CKBM6lifAxUQZLNlNB9TwWext+lTRZGd3pegUGLmB bD2TKaCS8GcDiK1iDkyAIHPbtShkF1HSwvdNglnH8SNyrHjawpWTyy+fquc9aKbudTPn HEsDXOOmoUhPrPSLmlFDbUIglRy9b3PmISO4uEx/hsnM9x8wXZGDyJ15MWPDosisNhxG Dpmg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t128si233565oie.176.2020.02.10.06.33.57; Mon, 10 Feb 2020 06:34:09 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728888AbgBJOcg convert rfc822-to-8bit (ORCPT + 99 others); Mon, 10 Feb 2020 09:32:36 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:20973 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728193AbgBJOce (ORCPT ); Mon, 10 Feb 2020 09:32:34 -0500 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-296-w69qbkjJP4qn1RIJf3pVWg-1; Mon, 10 Feb 2020 09:32:29 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E257F8010CB; Mon, 10 Feb 2020 14:32:27 +0000 (UTC) Received: from krava.redhat.com (unknown [10.43.17.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E99560BF1; Mon, 10 Feb 2020 14:32:25 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Ravi Bangoria , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 3/4] perf tools: Fix map__clone for struct kmap Date: Mon, 10 Feb 2020 15:32:17 +0100 Message-Id: <20200210143218.24948-4-jolsa@kernel.org> In-Reply-To: <20200210143218.24948-1-jolsa@kernel.org> References: <20200210143218.24948-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: w69qbkjJP4qn1RIJf3pVWg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The map__clone function can be called on kernel maps as well, so it needs to duplicate the whole kmap data. Reported-by: Ravi Bangoria Tested-by: Ravi Bangoria Signed-off-by: Jiri Olsa --- tools/perf/util/map.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index f67960bedebb..cea05fc9595c 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -375,8 +375,13 @@ struct symbol *map__find_symbol_by_name(struct map *map, const char *name) struct map *map__clone(struct map *from) { - struct map *map = memdup(from, sizeof(*map)); + size_t size = sizeof(struct map); + struct map *map; + + if (from->dso && from->dso->kernel) + size += sizeof(struct kmap); + map = memdup(from, size); if (map != NULL) { refcount_set(&map->refcnt, 1); RB_CLEAR_NODE(&map->rb_node); -- 2.24.1