Received: by 10.213.65.68 with SMTP id h4csp2114639imn; Sun, 8 Apr 2018 20:04:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Hryo0b9lUFMcorjiQFqj2rLbmDVkmBQSu8SF0fQxzmLjJ6JVkXHnu0SYjjN/0DlEbOY1t X-Received: by 10.101.82.138 with SMTP id y10mr3842887pgp.343.1523243099056; Sun, 08 Apr 2018 20:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243099; cv=none; d=google.com; s=arc-20160816; b=Yz+O2Am/5gItnxiyk8iXzWDJQGrhRGeNwiSMLlXthUhca1j+qYX7s8g+KRzuVHmkxm f+DhijYr6phdER9DDWyVUVRjqTrcutICs8iDTlcfx0t4pLlQHkMj/IylaQbz2oQ1T9SU eKvPRRUFMPx1M1fSuFV6aK4zD4uxvbAZGqoegodAVFjM8MR3Is6qoJh9KdO5FVcYDx7o I7xjTiftQf0GutECQWI0jVjCt6dwTdv6PsY0yPFxdZVGDn+wgD7mmHQ0tdLFwNpjHqUi E2xiYXtQk5ElxWcqw30GNrD6Rc3xnKKpSKsaJMjRvO2g+KUGX6bi+Zexn2V5wEKHVzKe xLTg== 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=E0axDY/jvaqF2Q9PFqMXorU3u+/Wul/TYIz4yhShMgY=; b=ES+23pjYgUr+Pb+BFoUB/QP7Dj35ntgx3/Dz1Gc+WTGu+yE7X/VVewngxKfxf57B3D SXUOZ208l8dEFXKIdHKTqOuxcXB2MVPcAS+NC4UDfN3kxAkfju0RWdKvZ55c+JmCVATY 127b+7mzjv052wgfeVytMOaIJaECssK1GhsGN8yjKwiOv8NAQj5718sYHaqQUExlmDcr w58kHyGaSmeMPqg7+ROoIetvyJo2L7baonDcW+ABdZBrFs041dapyk9X+TiLajIduPwl Pgpj/SCsxUiZVkeWcCl0GZDAWYkm0xUpav2IlaQa2r+wAh88Jj4p41oEF+H2y1YY37Ud 31rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=H/ijBaC+; 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 l7-v6si14620437plk.380.2018.04.08.20.04.22; Sun, 08 Apr 2018 20:04:59 -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=H/ijBaC+; 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 S932873AbeDIAhx (ORCPT + 99 others); Sun, 8 Apr 2018 20:37:53 -0400 Received: from mail-sn1nam02on0135.outbound.protection.outlook.com ([104.47.36.135]:3040 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932823AbeDIAhq (ORCPT ); Sun, 8 Apr 2018 20:37:46 -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=E0axDY/jvaqF2Q9PFqMXorU3u+/Wul/TYIz4yhShMgY=; b=H/ijBaC+JHz82EsLFV2DoxBB8HMstlTR7ZqPWTXzpKM3oqhd3H3Y7GgDuUQkFftK5osZo+Tif0UT/DiMtLSdGdktOSJYoQe5jvK4D3DejXyL1vqyFVoe3lYpmh/Jg+o1VOhPnT3WcCOaGxUvZzaQkl3OimxcaEM/XFdwlKevHzk= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1031.namprd21.prod.outlook.com (52.132.128.12) 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:37: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:37:42 +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.4 098/162] powerpc/perf/hv-24x7: Fix off-by-one error in request_buffer check Thread-Topic: [PATCH AUTOSEL for 4.4 098/162] powerpc/perf/hv-24x7: Fix off-by-one error in request_buffer check Thread-Index: AQHTz5m/pWiV1HL4yEeMbOiFqc9YDQ== Date: Mon, 9 Apr 2018 00:28:56 +0000 Message-ID: <20180409002738.163941-98-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-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;DM5PR2101MB1031;7:V6+a7tdPWRLwtQveGLshGDjQ3KEz1lNXsHOxvYcpPTtMcSaVfBFUbJla44tzs1S51BnSOZxMAVxLmal8DNgLX4cjZYpagc2rhwSkbMGAbnmQ2H+DeMkC4YNOqeAcyIfvjrUzmiSTmm9T+pb413YrBEgpXM/vIDswkPpZPEn7lo0fh3CrTUsPPWZcS0uuhvSVY9kc0yZoHdnqXM27tLT8TLi6B9cT7npec7DswKZznJ+USJI7YPQzdEmXcFwjNuaL;20:2BcgOqlrR+qh4vOGfw/e0tD+2UE69OVB8lKQ5jkh/LVpfyhbXHiMpoxFXT3psh+nly1YZK3iawN8DA+0hprahesdE0i4b0KLdzD5hADznq2QCvGrcc2b5PxsSl8TRM43ZDfKNhYxo5vnuxxlAoOou0F9Nwn9SN+c9bH5VwR3VZs= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 8a6614d5-90ab-4fe6-f2a5-08d59db21b33 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1031; x-ms-traffictypediagnostic: DM5PR2101MB1031: 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)(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:DM5PR2101MB1031;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1031; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(376002)(366004)(39380400002)(346002)(39860400002)(189003)(199004)(2900100001)(10290500003)(99286004)(76176011)(14454004)(7736002)(11346002)(26005)(6666003)(86612001)(72206003)(478600001)(36756003)(106356001)(66066001)(2616005)(186003)(22452003)(86362001)(68736007)(305945005)(54906003)(102836004)(486006)(59450400001)(110136005)(316002)(6506007)(446003)(107886003)(53936002)(4326008)(105586002)(6436002)(6486002)(476003)(6512007)(5660300001)(5250100002)(25786009)(3846002)(6116002)(1076002)(97736004)(3280700002)(2501003)(2906002)(81156014)(8676002)(10090500001)(81166006)(8936002)(3660700001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1031;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: GufQSjtJJIjerPCJmuqPvLXA6tdXsJ+wHWt6VXSgGITITV1/Gx6zUwHX6MGgv/ELp/wq6whfEz2VjWDff8wP9WHSdHezK92Y9q07ITKac19HAdIUu2DTc97Lq/4erKeDGopb/57/Xvdxk0KVCKLlRnPCuRjDYA6JQ979aiCOwqVH82TYaNwIMBHv1SS/bGUklcsL7emrORebkvkiG4UfpCsUBe2RbbOuIbxVJoQbBosBlaPW0vvNmQMHL3xAhQ/EYtXz6AOAxoA1e8USTGiMU1PsxIf5o7Iu9dKhAqV+oIH6hC5v5wJmn5mUmri4fyjhCX8cZlGgxp2WZ5N4eOn7fldYRd/DIX8aT2CBFXQFlTZBkBzlcaugkgW0EkdnFLphmaLX4ytmwU+6z9gMimqb7zswWoqmqT1wIpTHZbhKQyM= 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: 8a6614d5-90ab-4fe6-f2a5-08d59db21b33 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:28:56.7553 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1031 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 e267f4c3e51d..8e80882d8f6d 100644 --- a/arch/powerpc/perf/hv-24x7.c +++ b/arch/powerpc/perf/hv-24x7.c @@ -160,6 +160,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; @@ -1083,7 +1087,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