Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1621293ybv; Fri, 21 Feb 2020 00:26:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwyDAOeEfNnnkKfRmljcIEX3KBaQ75TU5L33K5Cks7MyrrNd7GdPPlAaKNsGyuf7Ye2kIOO X-Received: by 2002:a05:6830:1e2b:: with SMTP id t11mr27392447otr.81.1582273619328; Fri, 21 Feb 2020 00:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273619; cv=none; d=google.com; s=arc-20160816; b=sDcjJ9GG2byV1rWRGHLML2a3igZ04M7+7gYIn7eQ0cnwp2lRomd7YRrVKc/wioSYHm XnKLOTvE/oFq/mKVDVSlZvU9jQfALalQdVRYmsBS+V6kt5i7cU3WkX9BNjOMqE8JU7R1 0CGqmq/b3l4fEoZ1C0Tm1cwjLEOsK+zQbQx18LCFF0pAVW3fJK5DjSgclo1wkEIfk8Iu 23RbS5PFNLXsEjz3M6kzkPi/QED8WnWO878Uin9QHRsZ/mQfaYJT7bPkgB60wB7hGWup 3RLolCBFWDezf9KgYog2MWZg/ZKvV/XojT+wtFF4dIjF4Oc8R9P2d7GV+iZekHdeWZ4Y Vn+g== 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=ivFNmugODUFeGDdtohrWY4iO3WTMvLab1fTmwwsxjqw=; b=DM3r97MMZ5BFBC4nqRNbBpCD8YcnYFFd3G+UfcIxLMn8IZTJzd+O25IPvnIwOkbmmB bTdlNT2eh580ibMV1eFXcG95PWzpA6qQ2wnyckrVSlsIGo6gSP7WBCBO1xbkd7W4Frwc v3FR9uRXZZz8uM7Mj1Y50HMussdctcWGYLaCfD4dGGusyiEWu6FGOFcRRwBjtan2ICfD ZmyqL574JcrWhhnWB6NpxKMtL5sST0OPtAAMX2ivkQOQ3jwQBAcNkRi23gYTfIpmol5z yVHmlxZyhLJxzrsiw5pMTDNAAmJFYtog03JaNcUFz1voIidwFHPPIUI4+mGvTAMJ629h HuGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gDWDsbiE; 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 x207si436505oif.193.2020.02.21.00.26.47; Fri, 21 Feb 2020 00:26:59 -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=gDWDsbiE; 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 S2388786AbgBUIZR (ORCPT + 99 others); Fri, 21 Feb 2020 03:25:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:37948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388482AbgBUIZL (ORCPT ); Fri, 21 Feb 2020 03:25:11 -0500 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 98AED246AA; Fri, 21 Feb 2020 08:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273511; bh=UvVanc2Y8drvz0lTCD+gBtMmeB+L03JmO7eGDGY6rxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDWDsbiE2g6sVnkLhYoLSynQunmp2OVTjF5Nik9CNVREsqHjJg9en4h3DgzhSxuho j+J0L32+Tp5VQrZLWDpOYHXtPmS3exmqvIjuJ/B82ZKqJIaZV2a6VNQo0Hh2vamdZ1 25Z/1DM0RkvTtqn4GqtVxY3x9uJahz4TR/Gg9uA4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasily Averin , "Steven Rostedt (VMware)" , Sasha Levin Subject: [PATCH 4.19 174/191] trigger_next should increase position index Date: Fri, 21 Feb 2020 08:42:27 +0100 Message-Id: <20200221072311.633212807@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Vasily Averin [ Upstream commit 6722b23e7a2ace078344064a9735fb73e554e9ef ] if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output. Without patch: # dd bs=30 skip=1 if=/sys/kernel/tracing/events/sched/sched_switch/trigger dd: /sys/kernel/tracing/events/sched/sched_switch/trigger: cannot skip to specified offset n traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist # Available triggers: # traceon traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist 6+1 records in 6+1 records out 206 bytes copied, 0.00027916 s, 738 kB/s Notice the printing of "# Available triggers:..." after the line. With the patch: # dd bs=30 skip=1 if=/sys/kernel/tracing/events/sched/sched_switch/trigger dd: /sys/kernel/tracing/events/sched/sched_switch/trigger: cannot skip to specified offset n traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist 2+1 records in 2+1 records out 88 bytes copied, 0.000526867 s, 167 kB/s It only prints the end of the file, and does not restart. Link: http://lkml.kernel.org/r/3c35ee24-dd3a-8119-9c19-552ed253388a@virtuozzo.com https://bugzilla.kernel.org/show_bug.cgi?id=206283 Signed-off-by: Vasily Averin Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Sasha Levin --- kernel/trace/trace_events_trigger.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c index b05d1b6a62911..9300e8bbf08ac 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -115,9 +115,10 @@ static void *trigger_next(struct seq_file *m, void *t, loff_t *pos) { struct trace_event_file *event_file = event_file_data(m->private); - if (t == SHOW_AVAILABLE_TRIGGERS) + if (t == SHOW_AVAILABLE_TRIGGERS) { + (*pos)++; return NULL; - + } return seq_list_next(t, &event_file->triggers, pos); } -- 2.20.1