Message ID | 169453406074.27769.6203574670118288482.tip-bot2@tip-bot2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1334489vqi; Fri, 15 Sep 2023 14:39:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpV9z0BsNfzbaLmrxDBk8ZOzALjLjI2xhf09CLWW25eWx00OkyFVlHMCuyhVkS3QToy2gz X-Received: by 2002:a05:6a21:3d82:b0:14c:d0c0:dd27 with SMTP id bj2-20020a056a213d8200b0014cd0c0dd27mr2879682pzc.44.1694813963873; Fri, 15 Sep 2023 14:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694813963; cv=none; d=google.com; s=arc-20160816; b=aS+OoU8tFjOgX6Y1MItbpuSeuhy8Huyry6wI45hwS8AZ2F03orTSD3E1LVdL6gPJsW thVDyiMm+ZzuQYGB/mciZ9KLzjhqb4CvCVnI2E/d4Yen9qBuSI0k9f8EeMd8C5CchOhu 95nYhaVJy/rBv+V8vqE6UhtN9WAZSHfPmlcccbmvnI0UtzLgFdDJntV7UnOf6Vh3JtaQ 7pPzp86ijN4GZ4jKMMW2oBsrId5fIlqZgS8/BH+ho5M0v0ncO+eaNJbRzqJNoQXkmSnG setKicgnC76c1D7+mEZFMmMn31uPeQByhxP0/X1X5gjkRjGDo0Co23resdgiwFLvQ+q3 jj9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=gdctCp4SB36RtTArjia2PAFFd/hzfAhFlWhKyRt4ni0=; fh=P8rsz3J4DqNn04QsKLEjuAGxveeHGuOjhLyiC1yw2V4=; b=xveTA+g5uRMFUs7/DrgoXYT4T3ALkZXjA9IeSL6Rs/qXpB0O/3AdtftO2UOKKn2NU4 hpGixaP1kxdlGWWYBHRTJtDqkKIX1jvAVSqPyaWG7WsT3JFKbftW45Z846e6PM79UkVd MH0osk7cfjSVv6t8sMUSrGZhyICozh0ORjPHnnSGwvfc7vh0NJYx/mU9HNghs8f8vfvk r2CSnnJMffCFaJXZJQz0+RFyNxozyGsi2992d5l1eGUToXroFdnT2txuxrsp95ou5EGK InpB420o30VItf5vX7nx3hT7Ow907NgyX1wKqXhKo4j+1IOwdWEkfplhWfUGokUS6w4A ZBhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4ak7XDCQ; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ij2-20020a170902ab4200b001bc6e60699dsi3884272plb.27.2023.09.15.14.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 14:39:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4ak7XDCQ; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2814080477B4; Tue, 12 Sep 2023 08:54:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236347AbjILPyc (ORCPT <rfc822;pwkd43@gmail.com> + 37 others); Tue, 12 Sep 2023 11:54:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236475AbjILPy0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 12 Sep 2023 11:54:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDA2B10DE; Tue, 12 Sep 2023 08:54:22 -0700 (PDT) Date: Tue, 12 Sep 2023 15:54:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694534061; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gdctCp4SB36RtTArjia2PAFFd/hzfAhFlWhKyRt4ni0=; b=4ak7XDCQveLQNiye5/EFV0t4h1EVQr4JGhhjZwLqmwQjOmGDzioY987orEK8dVlckgWKy2 bxrXOUyopU+ToDpeSCzT1ldnHL5XjKelkxmgpwmr1jBvzrfY+UYPrgGHKYdepy/r4Dx7aW w2VkkZumKdYDa57hJW8i80c12kWa6PsaRoMFRhrg8AnPWQPR5NEfj72w6Q5R1t8T4/fX9M xanp2dcPfo67kkuIoomNgjs/ynczMJ7UUt8yTEcqqGzOo/uxJ5HAYpSQHfmZ5l29SjlF8a Pss4uXtpQw57tt9IAGakhmD1HfFyclLfeWTLo+XZE9e/DWbn+jSBwoYp/VSbCw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694534061; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gdctCp4SB36RtTArjia2PAFFd/hzfAhFlWhKyRt4ni0=; b=83DKNWiHCE6ZB+nNAqskUSnsI+zKRXn4+vZClhWKdv1UGxuCp3BQT8y0ScRCj0cRmoJQoA /AH2fDV60fVl2hCA== From: "tip-bot2 for Shuai Xue" <tip-bot2@linutronix.de> Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/core: Bail out early if the request AUX area is out of bound Cc: Shuai Xue <xueshuai@linux.alibaba.com>, "Peter Zijlstra (Intel)" <peterz@infradead.org>, Ingo Molnar <mingo@kernel.org>, x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169453406074.27769.6203574670118288482.tip-bot2@tip-bot2> Robot-ID: <tip-bot2@linutronix.de> Robot-Unsubscribe: Contact <mailto:tglx@linutronix.de> to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Sep 2023 08:54:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777001098783476482 X-GMAIL-MSGID: 1777141247124155216 |
Series |
[tip:,perf/core] perf/core: Bail out early if the request AUX area is out of bound
|
|
Commit Message
tip-bot2 for Thomas Gleixner
Sept. 12, 2023, 3:54 p.m. UTC
The following commit has been merged into the perf/core branch of tip: Commit-ID: 54aee5f15b83437f23b2b2469bcf21bdd9823916 Gitweb: https://git.kernel.org/tip/54aee5f15b83437f23b2b2469bcf21bdd9823916 Author: Shuai Xue <xueshuai@linux.alibaba.com> AuthorDate: Thu, 07 Sep 2023 08:43:07 +08:00 Committer: Ingo Molnar <mingo@kernel.org> CommitterDate: Tue, 12 Sep 2023 17:46:31 +02:00 perf/core: Bail out early if the request AUX area is out of bound When perf-record with a large AUX area, e.g 4GB, it fails with: #perf record -C 0 -m ,4G -e arm_spe_0// -- sleep 1 failed to mmap with 12 (Cannot allocate memory) and it reveals a WARNING with __alloc_pages(): ------------[ cut here ]------------ WARNING: CPU: 44 PID: 17573 at mm/page_alloc.c:5568 __alloc_pages+0x1ec/0x248 Call trace: __alloc_pages+0x1ec/0x248 __kmalloc_large_node+0xc0/0x1f8 __kmalloc_node+0x134/0x1e8 rb_alloc_aux+0xe0/0x298 perf_mmap+0x440/0x660 mmap_region+0x308/0x8a8 do_mmap+0x3c0/0x528 vm_mmap_pgoff+0xf4/0x1b8 ksys_mmap_pgoff+0x18c/0x218 __arm64_sys_mmap+0x38/0x58 invoke_syscall+0x50/0x128 el0_svc_common.constprop.0+0x58/0x188 do_el0_svc+0x34/0x50 el0_svc+0x34/0x108 el0t_64_sync_handler+0xb8/0xc0 el0t_64_sync+0x1a4/0x1a8 'rb->aux_pages' allocated by kcalloc() is a pointer array which is used to maintains AUX trace pages. The allocated page for this array is physically contiguous (and virtually contiguous) with an order of 0..MAX_ORDER. If the size of pointer array crosses the limitation set by MAX_ORDER, it reveals a WARNING. So bail out early with -ENOMEM if the request AUX area is out of bound, e.g.: #perf record -C 0 -m ,4G -e arm_spe_0// -- sleep 1 failed to mmap with 12 (Cannot allocate memory) Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> --- kernel/events/ring_buffer.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index fb1e180..e8d82c2 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -700,6 +700,12 @@ int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event, watermark = 0; } + /* + * kcalloc_node() is unable to allocate buffer if the size is larger + * than: PAGE_SIZE << MAX_ORDER; directly bail out in this case. + */ + if (get_order((unsigned long)nr_pages * sizeof(void *)) > MAX_ORDER) + return -ENOMEM; rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL, node); if (!rb->aux_pages)