Received: by 10.192.165.148 with SMTP id m20csp571526imm; Wed, 25 Apr 2018 04:28:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Urcry3/Ac+239PFpCQMQbthG3ynD2Lub7BLssYxKgDlv2++IZ8cvsqnb+rH9abnhuGWtH X-Received: by 10.99.188.9 with SMTP id q9mr23165881pge.381.1524655717638; Wed, 25 Apr 2018 04:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524655717; cv=none; d=google.com; s=arc-20160816; b=AdYDr5ivUZWusdDCU1hSTCn/gRnYhrusvWUh6OIRhhGf/XmdTjqANaRDLbOmwTkcKr vRr6odXJhbw8U85TgYEsKfh7H7z1QUR1Moyy4mzrl7GdjhBkOXRI8wvo0JT8JiQ8OJU+ QETPhBvCsIHvT3Xcs0Hix7OW0snl8aMWynV3tAiqLO+8zew+eNPcWsIcMnH2Etxst0YH sZw03T1b9Ggwf3PcWhxLRUzEh7a7QvMESMMnU0Nmk/zqBcp42VmEJ30ubpNU/mvYFA5Z lzSBqQxYkUKslh/4m+FFuxVF3a4b4Apbzj1ln3r7HbNgPEeW7tNz8vqSvYft9UCSYhXF ET7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=fHrTNWMCIB/EmXuePiO5TofuznQYSL7Xw8f3mdjz+oM=; b=fZ+dnWYS1dQhL3lMFQAz1EZ1ADAjIVQLf20skvYV57Qdx/IOCghXfI36MS3EiIHLGv 38+Z2FiKJKR5+J5Pvh3DNzV4WFG3kpCQjtRPT76Bxrx2hGyW+DEs90vXO8UgWqhuGnwL 6XCmHh1OxjByel0KbSc4BFyH6Atud3Q0Ei1cB+sDQYc5qbUqesRvXaz5ps8nwUJAwp9o OrLhAxqK6hDXqDdLxvdKK914lGHAickyeS5GeaHBa8UUR//O4EgjZzkCEFKMypmQvWA8 40eIDD7y9qFzFI3WDN5czq6AfDvwsQ0dlWltv+xUvyvo5xpKQ0mCaMSDNu4f1lA+H4Uc qeuw== 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 h4-v6si16696023pln.468.2018.04.25.04.28.21; Wed, 25 Apr 2018 04:28:37 -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 S1751980AbeDYKio (ORCPT + 99 others); Wed, 25 Apr 2018 06:38:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51480 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753407AbeDYKic (ORCPT ); Wed, 25 Apr 2018 06:38:32 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 84B9F481; Wed, 25 Apr 2018 10:38:31 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Richter , Heiko Carstens , Hendrik Brueckner , Martin Schwidefsky , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.14 042/183] perf record: Fix failed memory allocation for get_cpuid_str Date: Wed, 25 Apr 2018 12:34:22 +0200 Message-Id: <20180425103244.258042823@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Richter [ Upstream commit 81fccd6ca507d3b2012eaf1edeb9b1dbf4bd22db ] In x86 architecture dependend part function get_cpuid_str() mallocs a 128 byte buffer, but does not check if the memory allocation succeeded or not. When the memory allocation fails, function __get_cpuid() is called with first parameter being a NULL pointer. However this function references its first parameter and operates on a NULL pointer which might cause core dumps. Signed-off-by: Thomas Richter Cc: Heiko Carstens Cc: Hendrik Brueckner Cc: Martin Schwidefsky Link: http://lkml.kernel.org/r/20180117131611.34319-1-tmricht@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/arch/x86/util/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/perf/arch/x86/util/header.c +++ b/tools/perf/arch/x86/util/header.c @@ -70,7 +70,7 @@ get_cpuid_str(void) { char *buf = malloc(128); - if (__get_cpuid(buf, 128, "%s-%u-%X$") < 0) { + if (buf && __get_cpuid(buf, 128, "%s-%u-%X$") < 0) { free(buf); return NULL; }