Message ID | tencent_7FC26D7C2FA56EF89584E89EEE52CD20790A@qq.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-11402-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp727976dyb; Mon, 25 Dec 2023 23:37:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0xBJx8fe1nvges892jBmN5uRxh5HvIflbTpGXrDS/zo3PvApxsjhyN3Z+NkCQ5PYmphuB X-Received: by 2002:a17:906:5306:b0:a23:6c6e:6b4b with SMTP id h6-20020a170906530600b00a236c6e6b4bmr2975946ejo.45.1703576257942; Mon, 25 Dec 2023 23:37:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703576257; cv=none; d=google.com; s=arc-20160816; b=ftpJgi4wQjCDH6ozKhr5g1gVpPFmW92WIC8Ue6GUJYNjA+yJw+TkBexV0Lu0VpQy9x aOarhiseic9dt+g1QjR2iFXE00PRW2c8YA8PG34sjyfrXMBux/nYEkZn+GoOjyVYRNMM mg9tryM4/zgq3mew9Ilt+Ca1F1weje3m2sbuGllBxGQgM1V7konLZj6eFYW9jOknXve0 0TqTDsKJ5WCYyuByh1koDgMf3PZyrhennRsPbqOXLz03CO+nF31oQDSgXmYg0KSOqG0z PNkwhphVlsfbJkc5VQDb9fGl0VFUiZjwcBj7SEwTABYTVBxX6Ko2cuzPhHx1/QvDXt5c W9Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:date :subject:cc:to:from:message-id:dkim-signature; bh=CiicMmIx0APWzq6sNOUP+NQF+kg54apWQ0fTN/fttXc=; fh=Dy1Bhl31hk1SeeCYuwQgSpZaVEbLjKUC81Tqz5lp47o=; b=a1TM8s7vnoeOEKlwgV7vft1V6qFDoTR+Efa4iGAczrBGIAf/cOTNLMQWRNmeKZPdwa Hnf2Nl2y8+a3gNGX0N+TPzUVM/PbsZlwFOc+zlkuZFP7Z+oK2JpvBHruF7L9UHNMzRI6 Hz7MOan0D19Anm1B7kxIuyC72E8h9P9MmPsCzTclHDYZnc+NXy6DGomV5HzHSayEaFPh whOTh3wdinbwskKCG9bKfFOehHZHtRndAiMIyIVj7ZLuSoN8QWooFbSXSatYGccn2zk9 2qOJhLjn5H/pN/bbl2qGOCuQNcq7cmBm+zmGFvXf9l37BtOUxwbdrpm7ZTcncJR6jSZ3 0Stw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=AoLUqkTH; spf=pass (google.com: domain of linux-kernel+bounces-11402-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11402-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n7-20020a170906724700b00a26c8bfed4csi3437193ejk.561.2023.12.25.23.37.37 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 23:37:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11402-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=AoLUqkTH; spf=pass (google.com: domain of linux-kernel+bounces-11402-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11402-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 821CB1F227D9 for <ouuuleilei@gmail.com>; Tue, 26 Dec 2023 07:37:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DB444CB58; Tue, 26 Dec 2023 07:37:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="AoLUqkTH" X-Original-To: linux-kernel@vger.kernel.org Received: from out203-205-221-240.mail.qq.com (out203-205-221-240.mail.qq.com [203.205.221.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E51E24CB43; Tue, 26 Dec 2023 07:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qq.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1703575928; bh=CiicMmIx0APWzq6sNOUP+NQF+kg54apWQ0fTN/fttXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AoLUqkTHYSAge4AfA5cQbKzDTHtaStVQvfFIZWJ/nACwi98T0PqAvgox5obMsYcN8 pJ22eST0TFKEwWMXzSxG9HRaUWDEpElegZUb2dm/CNzQIdb7msQdcks196dfrcCiD1 6MbstCQwTaOv79YcpQNvLXq3OXwbAk/edQTd5eR8= Received: from pek-lxu-l1.wrs.com ([111.198.225.215]) by newxmesmtplogicsvrszb9-1.qq.com (NewEsmtp) with SMTP id 64E8CC40; Tue, 26 Dec 2023 15:25:14 +0800 X-QQ-mid: xmsmtpt1703575514tsxp5k6n6 Message-ID: <tencent_7FC26D7C2FA56EF89584E89E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MRINFO: Nq+8W0+stu50PRdwbJxPCL0= From: Edward Adam Davis <eadavis@qq.com> To: syzbot+07144c543a5c002c7305@syzkaller.appspotmail.com Cc: acme@kernel.org, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, irogers@google.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mark.rutland@arm.com, mingo@redhat.com, namhyung@kernel.org, netdev@vger.kernel.org, peterz@infradead.org, syzkaller-bugs@googlegroups.com, xrivendell7@gmail.com Subject: [PATCH] perf: fix WARNING in perf_event_open Date: Tue, 26 Dec 2023 15:25:15 +0800 X-OQ-MSGID: <20231226072514.1272529-2-eadavis@qq.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <0000000000005b23dc060d58ee7a@google.com> References: <0000000000005b23dc060d58ee7a@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786329177846598610 X-GMAIL-MSGID: 1786329177846598610 |
Series |
perf: fix WARNING in perf_event_open
|
|
Commit Message
Edward Adam Davis
Dec. 26, 2023, 7:25 a.m. UTC
The new version of __perf_event_read_size() only has a read action and does not
require a mutex, so the mutex assertion in the original loop is removed.
Fixes: 382c27f4ed28 ("perf: Fix perf_event_validate_size()")
Reported-and-tested-by: syzbot+07144c543a5c002c7305@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
kernel/events/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Comments
On Wed, Dec 27, 2023 at 08:34:57AM +0100, Jiri Olsa wrote: > On Tue, Dec 26, 2023 at 03:25:15PM +0800, Edward Adam Davis wrote: > > The new version of __perf_event_read_size() only has a read action and does not > > require a mutex, so the mutex assertion in the original loop is removed. > > > > Fixes: 382c27f4ed28 ("perf: Fix perf_event_validate_size()") > > Reported-and-tested-by: syzbot+07144c543a5c002c7305@syzkaller.appspotmail.com > > Signed-off-by: Edward Adam Davis <eadavis@qq.com> > > hi, > Mark suggested another fix earlier [1], but I haven't seen the formal patch yet > > jirka > > > [1] https://lore.kernel.org/linux-perf-users/ZXwubNIxKH9s7DWt@FVFF77S0Q05N/ For the sake of the archive, that went out as: https://lore.kernel.org/lkml/20231215112450.3972309-1-mark.rutland@arm.com/ ... was picked up in the tip branch: https://lore.kernel.org/lkml/170264057897.398.420625380438569608.tip-bot2@tip-bot2/ ... was sent to Linus: https://lore.kernel.org/lkml/20231217202613.GAZX9ZZWMM%2FytA74VC@fat_crate.local/ ... was merged in v6.7-rc6: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.7-rc6&id=177c2ffe69555dde28fad5ddb62a6d806982e53f ... and can be found at: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.7-rc6&id=7e2c1e4b34f07d9aa8937fab88359d4a0fce468e Mark. > > > --- > > kernel/events/core.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/events/core.c b/kernel/events/core.c > > index 9efd0d7775e7..e71e61b46416 100644 > > --- a/kernel/events/core.c > > +++ b/kernel/events/core.c > > @@ -1924,6 +1924,10 @@ static void perf_event__id_header_size(struct perf_event *event) > > event->id_header_size = size; > > } > > > > +#define read_for_each_sibling_event(sibling, event) \ > > + if ((event)->group_leader == (event)) \ > > + list_for_each_entry((sibling), &(event)->sibling_list, sibling_list) > > + > > /* > > * Check that adding an event to the group does not result in anybody > > * overflowing the 64k event limit imposed by the output buffer. > > @@ -1957,7 +1961,7 @@ static bool perf_event_validate_size(struct perf_event *event) > > if (event == group_leader) > > return true; > > > > - for_each_sibling_event(sibling, group_leader) { > > + read_for_each_sibling_event(sibling, group_leader) { > > if (__perf_event_read_size(sibling->attr.read_format, > > group_leader->nr_siblings + 1) > 16*1024) > > return false; > > -- > > 2.43.0 > >
On Tue, Dec 26, 2023 at 03:25:15PM +0800, Edward Adam Davis wrote: > The new version of __perf_event_read_size() only has a read action and does not > require a mutex, so the mutex assertion in the original loop is removed. > > Fixes: 382c27f4ed28 ("perf: Fix perf_event_validate_size()") > Reported-and-tested-by: syzbot+07144c543a5c002c7305@syzkaller.appspotmail.com > Signed-off-by: Edward Adam Davis <eadavis@qq.com> > --- > kernel/events/core.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) Thanks for the patch; this should be fixed by: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.7-rc6&id=7e2c1e4b34f07d9aa8937fab88359d4a0fce468e ... which is in v6.7-rc6. Mark. > > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 9efd0d7775e7..e71e61b46416 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -1924,6 +1924,10 @@ static void perf_event__id_header_size(struct perf_event *event) > event->id_header_size = size; > } > > +#define read_for_each_sibling_event(sibling, event) \ > + if ((event)->group_leader == (event)) \ > + list_for_each_entry((sibling), &(event)->sibling_list, sibling_list) > + > /* > * Check that adding an event to the group does not result in anybody > * overflowing the 64k event limit imposed by the output buffer. > @@ -1957,7 +1961,7 @@ static bool perf_event_validate_size(struct perf_event *event) > if (event == group_leader) > return true; > > - for_each_sibling_event(sibling, group_leader) { > + read_for_each_sibling_event(sibling, group_leader) { > if (__perf_event_read_size(sibling->attr.read_format, > group_leader->nr_siblings + 1) > 16*1024) > return false; > -- > 2.43.0 >
diff --git a/kernel/events/core.c b/kernel/events/core.c index 9efd0d7775e7..e71e61b46416 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -1924,6 +1924,10 @@ static void perf_event__id_header_size(struct perf_event *event) event->id_header_size = size; } +#define read_for_each_sibling_event(sibling, event) \ + if ((event)->group_leader == (event)) \ + list_for_each_entry((sibling), &(event)->sibling_list, sibling_list) + /* * Check that adding an event to the group does not result in anybody * overflowing the 64k event limit imposed by the output buffer. @@ -1957,7 +1961,7 @@ static bool perf_event_validate_size(struct perf_event *event) if (event == group_leader) return true; - for_each_sibling_event(sibling, group_leader) { + read_for_each_sibling_event(sibling, group_leader) { if (__perf_event_read_size(sibling->attr.read_format, group_leader->nr_siblings + 1) > 16*1024) return false;