Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp909716imm; Wed, 15 Aug 2018 08:10:30 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyFKwXR5rCOs+hihNWA1N0hDhi4daV83yT59TNbMGUyY0XX8n8U5Jv4Stg1cAXj+q3wRzLx X-Received: by 2002:a17:902:7592:: with SMTP id j18-v6mr24648344pll.72.1534345830688; Wed, 15 Aug 2018 08:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534345830; cv=none; d=google.com; s=arc-20160816; b=su1yTp9WmtL34/Tj1TrYhO0kBNlIGXq2tXB6fH2XS2ryEWsT8Qp600KzpJtOtA9Jnb Xbi9hwAyYnFNZ+qqVqFXeRuZF2QA8ipNPKjHBV4wDqIP5oV4TbnZVMmrrH+tPVAHhxGn xt25h33b736c2QzNgBYBlW5HEgmvAWgb/qwm6ULUWJhajkuKyUQfoDYPbi/7oeplw5jY Ij55FwV+DUsV/XPmWGNM7BUqpWAD0yyBHMSC8b2B6k1GRWGBNx64qfQ5G0yT4UqSAi+d TlCcfFHkC5L7xDjiJPW4kJ0fPIAKQ8rw4H85pCQAf1dWykX/M8Vk0vXL1MNDirT7ZbFS N6mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=0qzTvWi9vQ03pRD9J0okAINsgvcnAtKZMNdTL8rXKdI=; b=VX59CKEPBIEtS3GLmx0niIN/5Dodxnef1sx2FielzCCnYXKAhlhOw5iNNa0UTVZPqY fhK+4UxknSzZHvKV4OKrAcq4lYtLE/OvHGfkUrZX91/ehX3zKSCuhZm+c2o9f/KXnDl6 XblwI4VXHhUToMlCVaXW6rhS86HMkfkKIBcJgJ8uLiTj1+ZfEVaLoTPM9Xcqr+gU44EK CH8NiZWPVqtwIgd/vv1xIFqWa24fHyyXooQHTw9NcCoVTX1nej/KaEl0a1A1w/vq6PC7 YGF4i7ib4xn4IB9ANSjTr69FYkzYL4LrOO+ViTmeuE//dflRuqL8dmmMK17DX+Z6Vk76 nByw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PdXwQVDb; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v17-v6si24093392pgk.135.2018.08.15.08.10.15; Wed, 15 Aug 2018 08:10:30 -0700 (PDT) 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=@kernel.org header.s=default header.b=PdXwQVDb; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730585AbeHOSA4 (ORCPT + 99 others); Wed, 15 Aug 2018 14:00:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:50770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730492AbeHOSAz (ORCPT ); Wed, 15 Aug 2018 14:00:55 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 937ED208B1; Wed, 15 Aug 2018 15:08:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1534345703; bh=8fngLSdOYWIqdRBHfxFfFhBmRxrcT0oKsMtbTUqGfVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PdXwQVDb18uiCbnnCHKJCLh29b1cJm7dLxbBOjlaGGGNDUi4Z+uceM9FEorHJV35k Uv+Mcjf+IwtDneOJ6kka5QchmPmrs2mufW8r9w+0PiJYrDhZyYFXyerjx3fieR3tIN Da07CRo1Y3s38sw0LoNpkO/gmy1kRzGmOLkfwY7k= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Benno Evers , Alexander Shishkin , Jiri Olsa , Krister Johansen , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 26/35] perf tools: Check for null when copying nsinfo. Date: Wed, 15 Aug 2018 12:06:02 -0300 Message-Id: <20180815150611.32080-27-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180815150611.32080-1-acme@kernel.org> References: <20180815150611.32080-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benno Evers The argument to nsinfo__copy() was assumed to be valid, but some code paths exist that will lead to NULL being passed. In particular, running 'perf script -D' on a perf.data file containing an PERF_RECORD_MMAP event associating the '[vdso]' dso with pid 0 earlier in the event stream will lead to a segfault. Since all calling code is already checking for a non-null return value, just return NULL for this case as well. Signed-off-by: Benno Evers Acked-by: Namhyung Kim Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Krister Johansen Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20180810133614.9925-1-bevers@mesosphere.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/namespaces.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c index 5be021701f34..cf8bd123cf73 100644 --- a/tools/perf/util/namespaces.c +++ b/tools/perf/util/namespaces.c @@ -139,6 +139,9 @@ struct nsinfo *nsinfo__copy(struct nsinfo *nsi) { struct nsinfo *nnsi; + if (nsi == NULL) + return NULL; + nnsi = calloc(1, sizeof(*nnsi)); if (nnsi != NULL) { nnsi->pid = nsi->pid; -- 2.14.4