From patchwork Tue Jul 7 15:16:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11648907 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3F5E913 for ; Tue, 7 Jul 2020 15:20:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE697207BB for ; Tue, 7 Jul 2020 15:20:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594135204; bh=IKRcYbDIFHiIBRV8TpFGBWYGnR6Vj1rFMLD4iE/uvww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=btbko8LrT2E4YPpK1CytlOUSm2BQe7Kh8TN7HLh8Yz3/Cgy20D5E6X+SR/319nJbR 7a9rFnxlKXpNVLZNln7PiI9KoHZeNCpbbFrJeVQb2wStDBOAm5ljdg7vNACYaHXBj5 qDe+h7WNWIy32dyH78aOPJvdTw3lbt3olfR6/SV8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729458AbgGGPUE (ORCPT ); Tue, 7 Jul 2020 11:20:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:59732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728665AbgGGPTz (ORCPT ); Tue, 7 Jul 2020 11:19:55 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 CF0F52065D; Tue, 7 Jul 2020 15:19:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594135194; bh=IKRcYbDIFHiIBRV8TpFGBWYGnR6Vj1rFMLD4iE/uvww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u/gEFadkt2IeOzhPSikGLfnkNW34+z5L8CsNyGN4ZHMLaz+vuhAAY0y61k7AKs8D4 2TR0KN2dIKbTXpQuASSfgBNoQDYpVtt8dcH3yv3Qc3CT4yyFp+4lhy1XOOXHNCHzcC 0IOXulRQJ5E+Oe5uSH9aveAzoRI4zdn/8KXGcNmc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Steven Rostedt (VMware)" , Andrew Morton , Jaewon Kim , Jiri Olsa , Kees Kook , Namhyung Kim , Vlastimil Babka , linux-mm@kvack.org, linux-trace-devel@vger.kernel.org, Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.4 11/65] tools lib traceevent: Handle __attribute__((user)) in field names Date: Tue, 7 Jul 2020 17:16:50 +0200 Message-Id: <20200707145752.996517502@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200707145752.417212219@linuxfoundation.org> References: <20200707145752.417212219@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: Steven Rostedt (VMware) [ Upstream commit 74621d929d944529a5e2878a84f48bfa6fb69a66 ] Commit c61f13eaa1ee1 ("gcc-plugins: Add structleak for more stack initialization") added "__attribute__((user))" to the user when stackleak detector is enabled. This now appears in the field format of system call trace events for system calls that have user buffers. The "__attribute__((user))" breaks the parsing in libtraceevent. That needs to be handled. Signed-off-by: Steven Rostedt (VMware) Cc: Andrew Morton Cc: Jaewon Kim Cc: Jiri Olsa Cc: Kees Kook Cc: Namhyung Kim Cc: Vlastimil Babka Cc: linux-mm@kvack.org Cc: linux-trace-devel@vger.kernel.org Link: http://lore.kernel.org/lkml/20200324200956.663647256@goodmis.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/lib/traceevent/event-parse.c | 39 +++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 4bc3e1b906652..798284f511f16 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -1444,6 +1444,7 @@ static int event_read_fields(struct tep_event *event, struct tep_format_field ** enum tep_event_type type; char *token; char *last_token; + char *delim = " "; int count = 0; int ret; @@ -1504,13 +1505,49 @@ static int event_read_fields(struct tep_event *event, struct tep_format_field ** field->flags |= TEP_FIELD_IS_POINTER; if (field->type) { - ret = append(&field->type, " ", last_token); + ret = append(&field->type, delim, last_token); free(last_token); if (ret < 0) goto fail; } else field->type = last_token; last_token = token; + delim = " "; + continue; + } + + /* Handle __attribute__((user)) */ + if ((type == TEP_EVENT_DELIM) && + strcmp("__attribute__", last_token) == 0 && + token[0] == '(') { + int depth = 1; + int ret; + + ret = append(&field->type, " ", last_token); + ret |= append(&field->type, "", "("); + if (ret < 0) + goto fail; + + delim = " "; + while ((type = read_token(&token)) != TEP_EVENT_NONE) { + if (type == TEP_EVENT_DELIM) { + if (token[0] == '(') + depth++; + else if (token[0] == ')') + depth--; + if (!depth) + break; + ret = append(&field->type, "", token); + delim = ""; + } else { + ret = append(&field->type, delim, token); + delim = " "; + } + if (ret < 0) + goto fail; + free(last_token); + last_token = token; + } continue; } break;