Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2870169ybd; Mon, 24 Jun 2019 14:21:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUcuiSY1DOv+v9NKjEFmhnbtkYZRzuWNR+GaoEnHQEevneDDFuiyDSL5nKXxuKUVQpoSLt X-Received: by 2002:a17:902:bd94:: with SMTP id q20mr64209878pls.307.1561411311334; Mon, 24 Jun 2019 14:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561411311; cv=none; d=google.com; s=arc-20160816; b=ozoouLHaDCinfD5G/OJ7mkqoUqHx31NVR6bbbgUXadJ5Nse8LvRn/W/+879BcVLeAs R2e/5vC8jd6P8dk3bt+xCJCP1e/2nZ/2cfXi19gRsq+Kz4NtgmahHt/FyVcH9XwD6iim HB9M3P3gu/GcBC+VDnMrxm/59aq+UqyXaiH12UxcpgIZMWahcciHsd6ZDj2xqQ9RfGYT mAScXUTaRvo0EMhoksUQcqiWQHL7XWwHZqmPQqffTq9O5f0kdYX09eHWyr2vu0dKbKae BbXfz5PxVqlrdEMg+HxQHFpddgFv0mvnlznRcb1bfulikgc4nQ7GD277XFwexUVBKDsm g8Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=OOkVPa+AyQ6eG7d3TWyELHRxLVaqCotPsPhYAwpLTcA=; b=izR+4aBxdjEuDRctmt/a9g6y4lZ6AOm3pShhjisHy8P8ZsZDOkQZnEAMsDZBaOvo8M lJRMSjoZwdMTUwO+IApJXGd7aThz2xiy8D2ZzRKc39ewriIw4f5p/Io7Rs3gDKVON6Rf wEUnd+Fp2yO39P2h3IcGVCLnyKRYcMZYu1xF0BhIVedVGtOmgUEO2yzwF8O4Ii7nbzq9 QegfgtOGKAvwU5fxilFtANHB2M9DERHdewpjAyW0e8zqk0+v9uTunN+k+QWhEpRUdki/ 9PJAqEz2sp/jy8KPUq7u44RIRUknvx77iD42kzH74uHpU/BoLOzvjIjJ19cEeteqQylV KRoA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d5si10869421pgc.596.2019.06.24.14.21.36; Mon, 24 Jun 2019 14:21:51 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732771AbfFXSTJ (ORCPT + 99 others); Mon, 24 Jun 2019 14:19:09 -0400 Received: from mga06.intel.com ([134.134.136.31]:50413 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727022AbfFXSTI (ORCPT ); Mon, 24 Jun 2019 14:19:08 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jun 2019 11:19:07 -0700 X-IronPort-AV: E=Sophos;i="5.63,412,1557212400"; d="scan'208";a="172073852" Received: from rchatre-mobl.amr.corp.intel.com (HELO [10.24.14.145]) ([10.24.14.145]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 24 Jun 2019 11:19:07 -0700 Subject: Re: [PATCH] x86/resctrl: Prevent possible overrun during bitmap operations To: David Laight , "tglx@linutronix.de" , "fenghua.yu@intel.com" , "bp@alien8.de" , "tony.luck@intel.com" Cc: "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" References: <58c9b6081fd9bf599af0dfc01a6fdd335768efef.1560975645.git.reinette.chatre@intel.com> <2b15f4ce814a425c8278e910289398c1@AcuMS.aculab.com> From: Reinette Chatre Message-ID: Date: Mon, 24 Jun 2019 11:19:05 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <2b15f4ce814a425c8278e910289398c1@AcuMS.aculab.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David, On 6/24/2019 6:55 AM, David Laight wrote: > From: Reinette Chatre >> Sent: 19 June 2019 21:27 >> >> While the DOC at the beginning of lib/bitmap.c explicitly states that >> "The number of valid bits in a given bitmap does _not_ need to be an >> exact multiple of BITS_PER_LONG.", some of the bitmap operations do >> indeed access BITS_PER_LONG portions of the provided bitmap no matter >> the size of the provided bitmap. For example, if find_first_bit() >> is provided with an 8 bit bitmap the operation will access >> BITS_PER_LONG bits from the provided bitmap. While the operation >> ensures that these extra bits do not affect the result, the memory >> is still accessed. > > I suspect that comment also needs correcting. > On BE systems you really do need to have a array of longs. > Thank you very much for taking a look. I believe that the lib/bitmap.c documentation is correct, it is me that misinterpreted it and to make matters worse I only provided the portion I misinterpreted in my commit message. Before the portion that I quote above it is stated clearly that it is implemented using an array of unsigned longs. Reinette