Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2472208imj; Mon, 18 Feb 2019 06:36:58 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib+Hv7cVCWhvJ94gpwmoOs7jVjs2mVESWOdTFmQpyjj2oSkcL6+0ROweoPo1ohX5EcUWrLP X-Received: by 2002:a63:2a86:: with SMTP id q128mr19331254pgq.424.1550500618016; Mon, 18 Feb 2019 06:36:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550500618; cv=none; d=google.com; s=arc-20160816; b=ygHWBGp6Y1BA/4isXeaK8eHmVN0Zwic7gybZ965F7BEBZ9+gf49mWflKPMjw5X37pp 5B/8fV1MAXzqzY0lW2CF8dW4apbUJ0Mp83f4m2ITX+SPg9nKmiNFbPGEhBwo0j9Svthp Y8cLfNS5u3EvbLM/ehcjJdkaY7fevwi9dxCEauWRSI/nOqU0ECOw3NvywkgZsl/a4yPO JPTL4slPAGjtUaO60GvcXPYMTto4CgEF6F6HJ0OwugXXV/qLjXvqDfn5Y8L0lAtASqwH vnBMcVAf94U2ZUZo8hx0c0lfli8/UIe0/DBwhHNjKAOmlJoxdyKBUiG+VJG+NvQovmoK AmzA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nN27Lf8cGZ0O0PYdvQIIM815Mr4Ii2ILNfNpaI2/Gy0=; b=Xhe+eQU7Pu+6nikCBKncY0LOIUcri3DFCPChg4IPiuU5/WrElM7VQBhstC2O4JwHQF MBPqt98UXRUZcGXWN/aV+m4EDuWNOwo3rACUjWvmDSaAW9zzb3+wDD1GYA5/QYDaoS9U WsBwcg05ZFZKCYEWgb7v5VjztF5dSjHrZqhGlT1mvX5aHZB+ejKBQW4NhBBImKdZWN8w cvJSJHZx47QV7Q4A3qRN6SJujVF39NyLTZiL6e0LDhFMrpMmRq+sAKyaxFv7Q8nznhZl VPPz7dlykcqCRjZwzXwcFHFAaCNf02Ciz7Dd3INdvY4XRnqc0acSYnQxFS2q4zii239d b+vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lnbYqk4g; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13si12867318pgq.404.2019.02.18.06.36.41; Mon, 18 Feb 2019 06:36:58 -0800 (PST) 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=@kernel.org header.s=default header.b=lnbYqk4g; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387661AbfBRN4G (ORCPT + 99 others); Mon, 18 Feb 2019 08:56:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:36160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729984AbfBRN4B (ORCPT ); Mon, 18 Feb 2019 08:56:01 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2C5A220842; Mon, 18 Feb 2019 13:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498160; bh=kuSksr68v4wttPCml9hDtdGbSwJCSp1GlLmCa+8guKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lnbYqk4gSunw2FJyVklSVo84C2iSUNLH1tqjDfUePrqrr0cKVYMQ10jRsOYK0We8r 3kuknoaQRxX4rA4oIXOFL61c5WtVBDmrFev4YU/xYAbQ/TmQyonAw+DUSYmc57G/Is zwXBj4MJFxvGpeYiGwOW4ooNdkViiFUIrGUNAOeA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jin, Yao" , Julien Thierry , Mark Rutland , Alexander Shishkin , Arnaldo Carvalho de Melo , Jiri Olsa , Linus Torvalds , Namhyung Kim , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov Subject: [PATCH 4.14 42/62] perf/core: Fix impossible ring-buffer sizes warning Date: Mon, 18 Feb 2019 14:43:48 +0100 Message-Id: <20190218133509.482525110@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133505.801423074@linuxfoundation.org> References: <20190218133505.801423074@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ingo Molnar commit 528871b456026e6127d95b1b2bd8e3a003dc1614 upstream. The following commit: 9dff0aa95a32 ("perf/core: Don't WARN() for impossible ring-buffer sizes") results in perf recording failures with larger mmap areas: root@skl:/tmp# perf record -g -a failed to mmap with 12 (Cannot allocate memory) The root cause is that the following condition is buggy: if (order_base_2(size) >= MAX_ORDER) goto fail; The problem is that @size is in bytes and MAX_ORDER is in pages, so the right test is: if (order_base_2(size) >= PAGE_SHIFT+MAX_ORDER) goto fail; Fix it. Reported-by: "Jin, Yao" Bisected-by: Borislav Petkov Analyzed-by: Peter Zijlstra Cc: Julien Thierry Cc: Mark Rutland Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Greg Kroah-Hartman Cc: Fixes: 9dff0aa95a32 ("perf/core: Don't WARN() for impossible ring-buffer sizes") Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- kernel/events/ring_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -719,7 +719,7 @@ struct ring_buffer *rb_alloc(int nr_page size = sizeof(struct ring_buffer); size += nr_pages * sizeof(void *); - if (order_base_2(size) >= MAX_ORDER) + if (order_base_2(size) >= PAGE_SHIFT+MAX_ORDER) goto fail; rb = kzalloc(size, GFP_KERNEL);