Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp729192imm; Thu, 13 Sep 2018 06:56:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbypmslD3kV4jKwEqvknikLRXbwRFF5FDKB773ZGO4JcgkFoQgyIrR7+roT2qC6tVJZdgw5 X-Received: by 2002:a17:902:33c2:: with SMTP id b60-v6mr7405826plc.11.1536847007039; Thu, 13 Sep 2018 06:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847007; cv=none; d=google.com; s=arc-20160816; b=W9eGGhM5kApYYFWj810L51paCid/hPY/GYY2YUqbahDNrlY85Ui89JowW5/06VayOH I4tRrZNJTTS3OYkTeRyTcrSdLSBq/8qwfB9HeTDOz8tcytN1gB7PNolZpqXEGuwM10qz nqKkLMcMV7wghV0SwUp9uRZkFGxSHdwxNjOG00GbUNX7uKnRTjc/vG+jcCWv+ah9NptY KxnqeKY2Yj6H4AGYldKAJ2XJEnXA/xuzcm2z4ZGY4WE3Np/SNn1bIgIzZM+jWSohhf9i v7PGfCV35MAKdMnyNE8MoZgjs90K7TZI2PUb4Fr6H57FRDzO2u/mBsABtMAy3gpiUSvb 3YhQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=gdZg8pn1kg15Hi086IJIr19nYilxRvGRZXpuRcMOTpY=; b=KHzAy1K1a4xcAl5T2IZLll5Vg6JIxND00aU5NDsdIsifLswd2Cx7bVX0gy0ce+q+aw NGU2Njl1gIHKf1b3/B9VhPrIhs2/7IdMGjheLaVrYcmTq2vLqfxopjSvalGnA9kExOoz 8ljC3W6yFzbZHfJK1hmAEpMSe5RoOa/G19dCqj0GKnebl1ZJLMmRJ2nEmpbRCb6sD7sN K8IQDOWg705XSjDbMd7/yPA1FU+wd3WyzHCUNLIIHMNM6aP6hTKzfxIAI72+BG9nmWf3 /3xo6dlX2oWx6hkoc/AlPqGGoJKJOnW/zi/AEXKwVjb0Sf0aJEI6dRnNbHw7mDZvfYMp WaYg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11-v6si4148464plx.106.2018.09.13.06.56.32; Thu, 13 Sep 2018 06:56:47 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731383AbeIMTF5 (ORCPT + 99 others); Thu, 13 Sep 2018 15:05:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34154 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731079AbeIMTF4 (ORCPT ); Thu, 13 Sep 2018 15:05:56 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 17FBECE7; Thu, 13 Sep 2018 13:56:19 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benno Evers , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Krister Johansen , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.18 087/197] perf tools: Check for null when copying nsinfo. Date: Thu, 13 Sep 2018 15:30:36 +0200 Message-Id: <20180913131845.012438057@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Benno Evers [ Upstream commit 3f4417d693b43fa240ac8bde4487f67745ca23d8 ] 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 Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/namespaces.c | 3 +++ 1 file changed, 3 insertions(+) --- a/tools/perf/util/namespaces.c +++ b/tools/perf/util/namespaces.c @@ -139,6 +139,9 @@ struct nsinfo *nsinfo__copy(struct nsinf { struct nsinfo *nnsi; + if (nsi == NULL) + return NULL; + nnsi = calloc(1, sizeof(*nnsi)); if (nnsi != NULL) { nnsi->pid = nsi->pid;