Received: by 10.213.65.68 with SMTP id h4csp2119199imn; Sun, 8 Apr 2018 20:10:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx49MMtY9HACEHYlUrm/qipu5dWTzZGRnNr2DroKzGn1cKvANVJtpSwLnSl9Z1kr7hcZEB8hF X-Received: by 10.99.61.202 with SMTP id k193mr23877669pga.435.1523243446584; Sun, 08 Apr 2018 20:10:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243446; cv=none; d=google.com; s=arc-20160816; b=ikcOlkQdJK5igdAfnd2bgb2g3UeEXu/OBwysVDQ3muVSSdVEl5Lo7AYyTdkHRLyMMB zKa6vXfXr4R+aX5DPAU4R0hq9ro52WGiK08at5c9nSl4R4jDnmOygUWYb4KwynD6hpyW LUtlE14DZ/sATjgw6BZGvZIe8CJXfI+a+g/SWmdUjjUYmoqS+uVR8J8FCMuQ3s1+QlLC sDpoXl1FdBnS8ftsOmzwKyTJQ1moAC/droNL0rYPmxBCeFM63JwO4AtzTlGvY0INcNDh 9MR2f1V/DeOz7tje3ORZku/euRktP8ZlCWv9ttP7fqEMwq+3Uug5p8PofaW/kyAbjrrH K4Cg== 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=paVkpnR0WK3nrFXj/QrAZJTZV8+ALcukEC0hwXPyDSE=; b=TU3j8zjOSP/oLKc9kavvbZtuqfWCUslOFLNWY5MmNLJZDcq55sFYZohl6tdR37DvGn LQEyAXwzwrC0e8CSBgMCYNAAtkGjXnUutsk+ChFk6qUfxGEzzsJWu7Q++tZWm/m5QuWy XTd3jk+11/XHNa4HpcsZtfI9BF8F06WSDVmlNGrggNtOF1MGSwf7Q3bW/7UmWp/vvPno TNbL3rySirWDiKzUIOJdDurfYJYotjmtynao5f3GWklp0oek5mrMZBuAkbi9qqht0n+Y UhdF3vF6c1aHADnujZ+tSOrDyszzwRP7G6+9ya6cWRwTcmfpvBkSXl0oO7Sv8jrZyQ2p 7lRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=SBbpjwj+; 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 a1-v6si2068249plp.22.2018.04.08.20.10.09; Sun, 08 Apr 2018 20:10:46 -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=SBbpjwj+; 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 S932747AbeDIB4O (ORCPT + 99 others); Sun, 8 Apr 2018 21:56:14 -0400 Received: from mail-sn1nam01on0097.outbound.protection.outlook.com ([104.47.32.97]:22599 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932167AbeDIAc5 (ORCPT ); Sun, 8 Apr 2018 20:32:57 -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=paVkpnR0WK3nrFXj/QrAZJTZV8+ALcukEC0hwXPyDSE=; b=SBbpjwj+VySnByvzrDPQOlI7kfLDhTlvRX1W+gVC+vsXMpqLPNxpABSa5Auo/hBtMvUkcx57iiM8HoasGyXgCx3MARszeYFQtkfi5uwksYYYlLpwIFvcesFyaQ0Eq/jnKPQ2a/5uAEtQMQZvLZLoXvAKwbBmjgMhxb9zhQ6jOWA= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0902.namprd21.prod.outlook.com (52.132.132.159) 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:32:54 +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:32:54 +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.9 224/293] perf record: Fix failed memory allocation for get_cpuid_str Thread-Topic: [PATCH AUTOSEL for 4.9 224/293] perf record: Fix failed memory allocation for get_cpuid_str Thread-Index: AQHTz5lPJdji/cI8IUKOSbwOf750RQ== Date: Mon, 9 Apr 2018 00:25:49 +0000 Message-ID: <20180409002239.163177-224-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0902;7:EfZc8PzMx9mXcUhac8lPAoqGCv0yjpO4BRmG8QeFtH6jxUF4kTrKH6NomB7wG74SLdzwJLL9Ifu9+qUjWaeg2j6+KNic5tvtlusp2MqoiLkziKQYAh/JgAyz2pzVZyKqfKaTNeb4ATW0g6gk9doSsI23/8A0hGr+WcBgrpeVX12sDBtbYdf4dU8SGrEMyJzQDYw+i0W7yAlY9JORFBim80adqzFBVCKani82Zm5ThjbyO9ATlguviik6/9yHk1UI;20:CLCCMgSWJrwgSAnLf0q6OQYttwskmDSLI13HmnZJ/FHTq5GQHt1P644zvnj4V8uBNo6Hn5OMhe0NkCx1r55YodkxRw8m/1Z53PxOzefaFJK1Dcrsg0ffxaI2xb44Xczh4B4ev2SpRIChbQpTV1DOrir4nTSSw4mSs/jl8/Q574w= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: cc3535ba-a9f1-47e3-06e7-08d59db16f82 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0902; x-ms-traffictypediagnostic: DM5PR2101MB0902: 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)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0902;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0902; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(376002)(396003)(39860400002)(39380400002)(346002)(199004)(189003)(5660300001)(478600001)(86612001)(3846002)(6116002)(106356001)(25786009)(6486002)(72206003)(10290500003)(8936002)(6436002)(76176011)(2616005)(6506007)(2900100001)(97736004)(26005)(486006)(10090500001)(36756003)(81166006)(8676002)(81156014)(59450400001)(102836004)(2906002)(99286004)(11346002)(476003)(3660700001)(66066001)(6512007)(86362001)(6306002)(53936002)(966005)(105586002)(186003)(5250100002)(14454004)(22452003)(6666003)(2501003)(446003)(7736002)(316002)(1076002)(110136005)(3280700002)(68736007)(54906003)(107886003)(4326008)(305945005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0902;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: CWaaifOesKQIVFrCQQqlsSHyj4jQ0ix8lO2rufR/gV5XWXAcUW3jNRIIvVYbq4FhCBHPAHoIZH+AbDy2P+NNSxYM5kCemZF1vKuHiplPfYCyePeySli41ZHgBKXkgfjR4PBcYaud5BT6zWXx2A1DFAZrTz1xMSvAecL1SJB86FICj9ZH/XFI3tb0TGKFuRgTgDTMyNDKkyNreoyIidav5Ij5COB5Rg7nhB+8qT62BoCeMEpOtGpl1MMjkt1cj63KqoOk8F2LOcyKglMVRQwVH8+WWzDk82QFu9ImXBWfQ2UTPsZtbFuEtCTX3uBuZVfQcz4U6blrXxzV7FXt5fuiT37R+6n7YPIOcKgPWpC7hGASUlwshYXzYodhZuADW5wT+1hvxgsHwv7fU1bvdZ3mFdM1IRSd++WyQ7/8W23iYy0= 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: cc3535ba-a9f1-47e3-06e7-08d59db16f82 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:49.1129 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0902 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 a74a48db26f5..2eb11543e2e9 100644 --- a/tools/perf/arch/x86/util/header.c +++ b/tools/perf/arch/x86/util/header.c @@ -69,7 +69,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