Received: by 10.213.65.68 with SMTP id h4csp2177787imn; Sun, 8 Apr 2018 21:47:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx48N1NXONnp7Nr89qo9G2uDyIeIZryiirfXK10+ibA4lRB1b6AxiRNKij9rB4+UF46siortC X-Received: by 10.99.131.73 with SMTP id h70mr23555733pge.195.1523249228184; Sun, 08 Apr 2018 21:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523249228; cv=none; d=google.com; s=arc-20160816; b=jYXDoOoE/K1mW9vhhh9mkxXmUPu/EBv9wRmcnZR+bxD0kNGrNDmqMwIDzHun/YQLJr zNZWD8WkuwnM7Ya2CilhP5TIam292a76pwfoQKE0HaiIrA0Bpfj8Z4Zi2zZ18ZiISOKE XnLDitGLbvRCDLVPbBrOdjvxJTC4DaIp2Uet7GjdvlSpZG6icOq0WELUx4XNds8mxPMp 9JUCxtm8TDUdQegw29p9Jgh6uBxVYfOVW70OyjxC6M6VoKoolCUiigAJJWb38cF0gn26 U237HEJ1KwfWXpImAkI0Z8nNl3iC5Y353cg7II4cGPt1I3dge3JjUXsqfqgeCSC6xNj8 PN0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=uwZWruFT1s5izsM4iBlpLiSlqYuatOHH7dlzwegdLFI=; b=VmqCH7sam4W6REuKtzNl7AW5D8OoKq1lCtdxuI72TX0JMo3rdgphBKLuj5tIZX0KxS KEph0Sd9E1J4ysjnAGkSC0ntrS8EK/CfZt6JrYXUlWZXb9RdiEnfDl7UCZMYD7Wjmyvo 4jSvUjk5/jgc7dyS0qVtQeRNws2epKrnPN7kbazYnsJwKSJPRO8KVxxs57Yut+H2XZ1w oxqLjUE7Xk+A6gplGEqrfgKlP5rNtB7cpGHCFiBOjNHDHfaziLy4oORDM8DmEywVOcWO IO/l3Z41wh2X93VYVRGGK+xiSswv0uvA2ndgcttbSovR8POzVPLVQlarOzCIRPKgIwSy +zuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=O3w3mb0f; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g14-v6si1959918pln.526.2018.04.08.21.46.31; Sun, 08 Apr 2018 21:47:08 -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=@microsoft.com header.s=selector1 header.b=O3w3mb0f; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753199AbeDIARr (ORCPT + 99 others); Sun, 8 Apr 2018 20:17:47 -0400 Received: from mail-bl2nam02on0136.outbound.protection.outlook.com ([104.47.38.136]:51875 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753164AbeDIARp (ORCPT ); Sun, 8 Apr 2018 20:17:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=uwZWruFT1s5izsM4iBlpLiSlqYuatOHH7dlzwegdLFI=; b=O3w3mb0fdrCOx2RU6yQdmrzDZKonnJRRGIuQFlCGH+klt16yd0f6/pb5OmF1ymGOR5g9EUdbeV1QBE7Iz+iWue7Gkcg/sT8f5vG1dpZmEt4+Kc43Oh5XLS76ZlhAiViuCzdc4DdLwu9yIXuJjbDf6VqwcTI9WwSSHUE/phn8fZc= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1048.namprd21.prod.outlook.com (52.132.128.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:17:41 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:17:41 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Thomas Richter , Heiko Carstens , Hendrik Brueckner , Martin Schwidefsky , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 032/189] perf record: Fix failed memory allocation for get_cpuid_str Thread-Topic: [PATCH AUTOSEL for 4.15 032/189] perf record: Fix failed memory allocation for get_cpuid_str Thread-Index: AQHTz5gaV2dhpZ8b5UGuTO8xjGrF0A== Date: Mon, 9 Apr 2018 00:17:11 +0000 Message-ID: <20180409001637.162453-32-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1048;7:pGzsp5fo4nkDVcdfV4NO8F/oBZFXn/JN/eSQ1VRN5Gh1Pp26WQmViN8jGAuwJqdOce6xpcfeHWMlUQXCU7i73TwiJAwY4uhpB+yxf+ylHCj50cjcGKD3bVDDuFg2hLltUVkIpaCY5qQQwkClyBen5doCUiUxA6T2mwIk7j0HW0vu7NrCZizKvgVhlpzMSe2EqBII5Yd1kptoREcW+uMc2UEgZTE6xRZXesm7W3W1v4wVuezfMo7aRtKn/OPLITqM;20:+Fvq/e5LDupOlWTjunEQPeJWi3sAlZ+eSz0q4klURF7YcewvDIntHK8z3e2XAbeyRU+Go9j0KigkGUGZ5MiFQVM8n+8+rGiSlXOOSRPEsXt80M6ZiIxH3kjQRff62xhJOXtFs2PA3CJ7+t/gJGFzN7HRscOdQyXzcqjxCJMjsRI= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 17426a25-974e-4dae-8f8b-08d59daf4f39 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1048; x-ms-traffictypediagnostic: DM5PR2101MB1048: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(190383065149520)(42068640409301)(104084551191319); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB1048;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1048; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(39380400002)(376002)(39860400002)(346002)(396003)(189003)(199004)(86362001)(1076002)(99286004)(6116002)(110136005)(3846002)(54906003)(22452003)(3280700002)(105586002)(2906002)(76176011)(4326008)(6512007)(6436002)(6486002)(3660700001)(6666003)(7736002)(59450400001)(86612001)(25786009)(2900100001)(14454004)(97736004)(6306002)(53936002)(107886003)(68736007)(102836004)(966005)(36756003)(6506007)(26005)(186003)(106356001)(305945005)(5250100002)(72206003)(478600001)(2501003)(10290500003)(81166006)(5660300001)(8676002)(66066001)(316002)(81156014)(2616005)(10090500001)(11346002)(446003)(476003)(8936002)(486006)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1048;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: eHYUPvFykCkoW4EihIw/LB11t6ZBHN31FvXSjIonjn2HYh3ndTIJVjuIvAmYKZinIb6uwfejIncAE6xhMVdGC7QLB0PCoG2aj3w35AhKW2u4Hi4k9pFmrSQQLtKmUwcfx5zrqMiS5GqZdjYIekMBIH4ijGJhJPRViaiQqBdpIh3LbjGbrpyPoPeGCZaomvGFRqajd/x/0VK5pBQVakDcoQijtXRtDuwDeBT30ml3hsoYahNpcAO5jwkpbBWLJZ1hLZaX3BNForI3n4Ob2SypdPuAUrCATzO8QCEoJLn/JNZdiYDMc0lo3E/sPVjMkUa6OFgdSLMFuqAmYi82OenmC4MIL5CxbP+12uMc0H7xLs52cGfzxmW8DupqLSW2Ed7zcW4Nu0NJtd00neTXEsGeMdA/pSu5vch8SlzwR8WTHzM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17426a25-974e-4dae-8f8b-08d59daf4f39 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:17:11.9020 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1048 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.ib= m.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/arch/x86/util/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/arch/x86/util/header.c b/tools/perf/arch/x86/util/h= eader.c index 33027c5e6f92..c6b5204e0280 100644 --- 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 =3D malloc(128); =20 - if (__get_cpuid(buf, 128, "%s-%u-%X$") < 0) { + if (buf && __get_cpuid(buf, 128, "%s-%u-%X$") < 0) { free(buf); return NULL; } --=20 2.15.1