Received: by 10.213.65.68 with SMTP id h4csp2114065imn; Sun, 8 Apr 2018 20:04:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Nl3QZUr9oRq7ZCcFBzrPZv9z2LCi1r50ugTFeLO9NBXOSMBF+iTZVtdF/HzknzgOzM9CC X-Received: by 2002:a17:902:43a4:: with SMTP id j33-v6mr37778707pld.260.1523243053127; Sun, 08 Apr 2018 20:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243053; cv=none; d=google.com; s=arc-20160816; b=R1pcxo6OrRWzyvC1TIIV4XPOm9LivxbcrC1Vbp8Y1l2DcO/UD/Tgh8zMDDSDKTB2vJ BxjfKwFat3dzEfQph4oEgkk0PO6nT+RPeP8yyCB5b5v2V93JxLyfAiQ3O5m4gW775JKH OrfsW2fXZ5ktOG2mrNgK9ogiax20jh/gq84f7R5ycikjl/SNjKb3QbNL2Fb3Zz9zkZkl Fc69AhrdgMVTFW6+u4pusH4WwWtWfVaSNCPnAt77HJPLmKn6Ndcgntq1/LtKheuijVZE vbNyhoSVeuhTd9bopdP/+3Q+S0YvKlnzRMzQzVaaw1vhGz+aPiA7h0vWHXetux3dIBMk Lkug== 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=9C791992OgCPWpWMPwqr3g+O6JZUao+IoG0Od02ZA1g=; b=ENX7q/MmS5Y8sQePNVYFe0HHrYuxgWR1G85jh+O3kAHuWyo0CU9TQHxIKPTtz3hCqb 8jh9u70HlkdZHpMin5QKxkF13P6PV+BiXF1LLEOjsyo5exgVvGOmvUobeSfDRQ3BVwb0 5rOW/FAb7CDefKAXoW3aC6x4cDlwfChWAtFVfxONyvL/d9puiQf42n7CHu0gLMfshGHB uWj5lo5pB8K78HtQ+Zhm1eDuBiZaqJ2h8VB2+LWTj+8xGOzXVvjfe0qWnbzIITU1Nil0 OkcOiymvVazTz0Z9y3TbTSYHdvktTixmT28OfCKjs7X4lxRPfwY26lF4dn4x25SVjYx0 +i4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=c23lzkE8; 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 o14si8366506pgn.36.2018.04.08.20.03.36; Sun, 08 Apr 2018 20:04:13 -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=c23lzkE8; 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 S1756467AbeDIAcO (ORCPT + 99 others); Sun, 8 Apr 2018 20:32:14 -0400 Received: from mail-sn1nam01on0103.outbound.protection.outlook.com ([104.47.32.103]:45281 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756413AbeDIAcH (ORCPT ); Sun, 8 Apr 2018 20:32:07 -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=9C791992OgCPWpWMPwqr3g+O6JZUao+IoG0Od02ZA1g=; b=c23lzkE8tV4fmk6BEToXSIqez8SFXswjiArzJ5fyFcupk8DbA0Bwg3dCrSmAECSwgKSTqeHiYupkIrX2XNJFDjcUVts901JxOQ+S2PkQedbXdj/B3W4vIP9f1dLE7Nrhkuuptxa1qh11zZehcsxAmx053mUmjZdP45xADARO77s= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0870.namprd21.prod.outlook.com (10.167.110.165) 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:04 +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:04 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Thiago Jung Bauermann , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 195/293] powerpc/perf/hv-24x7: Fix off-by-one error in request_buffer check Thread-Topic: [PATCH AUTOSEL for 4.9 195/293] powerpc/perf/hv-24x7: Fix off-by-one error in request_buffer check Thread-Index: AQHTz5lBPAh1Q+LS2US5Ki4v92fbtg== Date: Mon, 9 Apr 2018 00:25:26 +0000 Message-ID: <20180409002239.163177-195-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;DM5PR2101MB0870;7:J9769E28BJ/u1tMMQWwgAufRwM8tjciv9lmqWAXusBAg8qAxHB1vCeNtSd/1MXfL5NquVRHl1dnu/Qls40zvIUyuWD01oir57Od0cQv39j8mwSTHgEy0JkfbK3qfv+hCv2zlmHsIWWhh+dss7newUReMtLHYP0KBBEeJSf+hTDL7WvZ8c2xuMrUCoK2p+283dm6MpR5IV0bI/qbwCZMxVphGUpmax8g1XO8gewgMN7nbNvI/yakXGea0jEl+AtcL;20:KECM8bLvbGSP4wiZQmcXNjx2RVyu1AFBWzL1ZsbAnyi+w6zMzUiCW7Kr8eu6adn+UdhBEAGtlqhH/R4T+kAj3I4vyC0aE4rnAlflLv1IGOGy/uwOja9M/F8PJG7+RCuCvKPV8FC0qHS6wlxWQ5ixpQaA1e3FJUIFEMAzXqXSTjA= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 32adcc6f-7992-48c8-2ca0-08d59db151b2 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0870; x-ms-traffictypediagnostic: DM5PR2101MB0870: 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)(104084551191319); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0870;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0870; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(366004)(396003)(39380400002)(376002)(199004)(189003)(53936002)(2906002)(6512007)(102836004)(2616005)(76176011)(14454004)(446003)(10090500001)(11346002)(476003)(486006)(107886003)(59450400001)(2900100001)(97736004)(66066001)(6506007)(6436002)(106356001)(99286004)(105586002)(3660700001)(6116002)(86612001)(3280700002)(6666003)(2501003)(10290500003)(26005)(8676002)(8936002)(478600001)(68736007)(5250100002)(5660300001)(316002)(4326008)(72206003)(186003)(110136005)(6486002)(7736002)(25786009)(3846002)(86362001)(36756003)(22452003)(81156014)(81166006)(305945005)(54906003)(1076002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0870;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: NW6x9VErKczmv8U71EnWnpe9uMaLAFBpjS0nHSqrtLqsVaEN5wxH5++m/ck/XkU2KT0onozeOH576zvgW864Pk1uy3ZzuKSG84kXTSpJYHklaBCxcSfufz8hN3q5Rn2r489EdRnlmxeRXGSkMRjuPcS/CuSlkNCvAWF8TxhtNAsH0gW82Qkno+Ldkf8M6MRkxOYhOwtRTZGSEM9c2QCzPdNzCEVAYW0IIK18cmprUy2RZTxHH0gIUbyR+GUbIUKW4VpumBfeKuQ7Am/uFlI5TakwF/+ie67gIhGfLMMxyLxPIrsTyEcTNqv3RmsXtU/T4Rtj1dQTlv3vk9L73S7daZ28JC5zAumCVPPCo5DPXa0zwJw5BlkFaz1rOH7nDOyD8kDjvFgCg4NV2UcrY3VAdoqijs2lOw6B7/Jcs/iAb3Y= 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: 32adcc6f-7992-48c8-2ca0-08d59db151b2 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:26.6127 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0870 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thiago Jung Bauermann [ Upstream commit 36c8fb2c616d9373758b155d9723774353067a87 ] request_buffer can hold 254 requests, so if it already has that number of entries we can't add a new one. Also, define constant to show where the number comes from. Fixes: e3ee15dc5d19 ("powerpc/perf/hv-24x7: Define add_event_to_24x7_reques= t()") Reviewed-by: Sukadev Bhattiprolu Signed-off-by: Thiago Jung Bauermann Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/perf/hv-24x7.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c index 13cea4e8c56d..9fc2be138e32 100644 --- a/arch/powerpc/perf/hv-24x7.c +++ b/arch/powerpc/perf/hv-24x7.c @@ -166,6 +166,10 @@ DEFINE_PER_CPU(struct hv_24x7_hw, hv_24x7_hw); DEFINE_PER_CPU(char, hv_24x7_reqb[H24x7_DATA_BUFFER_SIZE]) __aligned(4096)= ; DEFINE_PER_CPU(char, hv_24x7_resb[H24x7_DATA_BUFFER_SIZE]) __aligned(4096)= ; =20 +#define MAX_NUM_REQUESTS ((H24x7_DATA_BUFFER_SIZE - \ + sizeof(struct hv_24x7_request_buffer)) \ + / sizeof(struct hv_24x7_request)) + static char *event_name(struct hv_24x7_event_data *ev, int *len) { *len =3D be16_to_cpu(ev->event_name_len) - 2; @@ -1107,7 +1111,7 @@ static int add_event_to_24x7_request(struct perf_even= t *event, int i; struct hv_24x7_request *req; =20 - if (request_buffer->num_requests > 254) { + if (request_buffer->num_requests >=3D MAX_NUM_REQUESTS) { pr_devel("Too many requests for 24x7 HCALL %d\n", request_buffer->num_requests); return -EINVAL; --=20 2.15.1