Received: by 10.213.65.68 with SMTP id h4csp2130292imn; Sun, 8 Apr 2018 20:29:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/FvblwWFZ4hL0XrLyMX0oeNdwG1Edt/3fPjEZJdxUr/f4ot+KqPqh+u+46gmJB6TV6JBRP X-Received: by 10.98.61.206 with SMTP id x75mr27553651pfj.233.1523244554089; Sun, 08 Apr 2018 20:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523244554; cv=none; d=google.com; s=arc-20160816; b=gSdrCNVDenNviLpgfXWj1zYIcKm87zck0Koo/UJjabBNlazeNzXm5Cl3Eh273kcu+M kjrMyLOe4sJPizstF0uoXfOZsXCwhpEHbabTg+I27GeJl4dog91+E9eB01Nxl+BxZx9u CJef4ScRhWmykTh4R+LFtqaRSjV2ehdV4NPg7h1MGUTZRTfAEEFG9/+8W/BkYHP3FH1E gojiLnNF0e//xyW7dsCbl0b0t9IZsQappbIkzggHrZ3UqcFHPtqIh8Q/fWsPr/86UwDl FBJm+aBIbCLk6e3DJX2a3BDBGYz+4+qArD0i+nb1lsrqHf4hpKOJ14PMX5glDF/y+aOc 9Dfw== 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=XLxUOB5nxDOfwuWvV00kWiL1KAmT83aoRdDNN9cMTJcKsx0agg0cRAzLbcpMhZIOXb xmGllwR5Kp30/ByCpAQvywbBlca7L7/rsYR5uCf87moqrD3WXdbLZe4aL60v8c5xD30o mX8NuA3MmUDLsoi20P2s9k7CCQDINYhMcC90h2hGem1sbgqoXYJVxEtj56JY7YUiVIXe LRGNUYGcq48EBW2LvsS5MLEYXENUkDA8YPGljeNtC9n6l3qM5ytf0joO4nUyBQoo2uvV O/NitIvXrGxdL+EQUbb1GD2WxRw1Y8/+941Lbr/+GBO+BBpBdjBkVt29lAlbEdXC+AhX FpNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=XqiaEc4d; 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 h10si4897625pgq.514.2018.04.08.20.28.36; Sun, 08 Apr 2018 20:29:14 -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=XqiaEc4d; 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 S1754204AbeDIDYX (ORCPT + 99 others); Sun, 8 Apr 2018 23:24:23 -0400 Received: from mail-sn1nam01on0122.outbound.protection.outlook.com ([104.47.32.122]:20813 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753540AbeDIAWp (ORCPT ); Sun, 8 Apr 2018 20:22: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=XqiaEc4dRxRqJ/x5t3kbPJlBlqht0Lq7BJUN7/CuMqobQVTegmCMowiMydlQLA4cKp0u/5xJszz8OZN7G0irMJ4OwIZE09wgSYMtioKzD5p7hkKQzpNCEJnnqOpuDszzx2CJwCyiKMQKiO03sj8hYlg90Qh70UNLOba28D31TqM= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0966.namprd21.prod.outlook.com (52.132.133.24) 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:22:42 +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:22:42 +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.14 028/161] perf record: Fix failed memory allocation for get_cpuid_str Thread-Topic: [PATCH AUTOSEL for 4.14 028/161] perf record: Fix failed memory allocation for get_cpuid_str Thread-Index: AQHTz5iCvKBL1vK1U0G/HCzI7w2c/g== Date: Mon, 9 Apr 2018 00:20:05 +0000 Message-ID: <20180409001936.162706-28-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB0966;7:5krUUkYN8bQx+x5YyzzM6U6mPcXzNIGHLgiksFPognjMqHHHLio69udQarhWFOUtKdrMl4MJkW0+Go0gA0CviQXTBS8IOWOuTzO/q5KJ+NJW2go9yVsQ7ZV5CjpbIxXNvGMBM0Gpf/MYF/eyt0w+ZLzkT3lTxcbuHveBc+ubrgsLc+/n1Va6w0FCAwd1PEYbbyg0PPXRq/lbk/AKzSNbadnFns7+W2HWy+h4XPM4qtpiyNLSZpV/iiHC3UCD4T9F;20:r35ViTvKFdkQuamBrGFVNSIpkcTsiSDgFmSQyWUcLN5VqFSZxSN3jYDCzScPLfxJVVR6ic7chQM6ucE/+lTK/3s6kj7/m0ZnGb2Tp/HQQzMgeT9pulXvzGcByH618YSIZBZj7mc+U6OoreQFIU5+aL3ulDC98AeCLWv73t33gGc= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 4bf07abf-b6f3-41e9-4bed-08d59db00261 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0966; x-ms-traffictypediagnostic: DM5PR2101MB0966: 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:DM5PR2101MB0966;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0966; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(39860400002)(39380400002)(396003)(366004)(199004)(189003)(6512007)(316002)(59450400001)(6436002)(186003)(6306002)(6666003)(2900100001)(966005)(8936002)(486006)(6486002)(6506007)(10290500003)(81166006)(22452003)(25786009)(1076002)(81156014)(53936002)(106356001)(10090500001)(5250100002)(107886003)(102836004)(76176011)(8676002)(66066001)(2501003)(446003)(476003)(36756003)(99286004)(478600001)(86362001)(72206003)(2616005)(68736007)(5660300001)(305945005)(3846002)(6116002)(26005)(86612001)(14454004)(97736004)(3660700001)(4326008)(2906002)(110136005)(54906003)(3280700002)(105586002)(7736002)(11346002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0966;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: q/QKxeVnYG8M/12W8SxIoDEoHb3Rro7Ju4N+F+VSks+4dqZ7oFjEBF/IH1lIPaxNpYKThiAoeIzQizpb+9yqTodmpoWtU9d0WWy8kqnv9aB/TTvf27HNyMk1F1CfXmnKd06NOuZoKhlfJS/9ZnQyWNmkT/ne9/XyZiXdDQHjlfADnXuzZaOlx3HZHzN6DzHLLGFBqnyZRgLEmNrt4qwbCOW7YLQkEpbSfWz25Hledx8KYZUy+NwUVd54T+hs5uszwuOl8mCH1F7fMZFiVpeu7jWKKneK/rGw2aBy+H4J9RZMcvARin/Zj5Zq83AoMysfRQBX/HEQ5YjmdHrIBJ3KqS5Z+vRbsobbiyTqgMYb9VOaeW18W9raDNLN8roygZHvehztG0+QEyR2dW4zzfKQzOI4GHtqFeNPC/fXZFeuYFQ= 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: 4bf07abf-b6f3-41e9-4bed-08d59db00261 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:20:05.1448 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0966 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