Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1937740ybv; Fri, 14 Feb 2020 08:32:03 -0800 (PST) X-Google-Smtp-Source: APXvYqz+rufvb/DrJKPNn6wRdcY7shQZJXhNQFa7AdpHtXvg60XX8JJ/kKQ1ELdCV/bTevoIObWs X-Received: by 2002:a05:6830:1042:: with SMTP id b2mr2957725otp.306.1581697923755; Fri, 14 Feb 2020 08:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581697923; cv=none; d=google.com; s=arc-20160816; b=UygwoFXF2UYMJd7Agvc1kah8dtlpmBa3B0ltpA/1UKugO/w7sEfU/oSjiDy5kcGw9u DgiGMp+JQqnbaz8UxeMMoe8ULaA4YtWo/VdEUitVsa+2BCLlExvqpTwfxlLF96olCkl9 8RoX5vJ2TFWkr5wzqL6t9TtyPjtUagJkVXNS4GOXutD8D/MnuI5JX/ofr0fsIF4sTzXg CA6Zfz/w4jKavAO+vBbCIj04u5YbLKfsreIfg743tic+TVkIuhjd+Vy2vvz7c5kBchmI 8/m9aQmvzRhFPbWzGULZVgtcKXRZvinozJkPSF2fXe+GHZ321707/Su+KqlM5KNhuRCA jW8Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MWSbP1kHL02DL2+RgZNVNM1LEEEkK4ExryRlk0jwLxo=; b=UbS5JJRa0IFYWfe/HZ5mksdaIhYADHE/Q9eZwreQqOd/qJPauxFwV7R9S30/MYvIjX D5NrM2HQ0OjMQTAM9xA3tC9dEyIQMZMd1SdQNfZNRm3o2L2gpPtJgF2GRB4OwM9gYX/o QJ6hB499ONMMNycRGwGPIk3r+Ayc5DrWgt0DuwmEtNyEV3pqSR1/NSpzKc2Or/4GJ5ya L7BxF1cvkj/0M8zAuxrq4UBJagTzhye+UUT2RYQS9BE9KzVtAJcLVdstL2u5M9jXsOuQ YUjhVaCQCqSZPNDI352BWUtr9kMGNv6Y/qHdYRSecjnMzfICHUNY3eu9+GE15qAFe23/ v2DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YOx9KsDM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f14si2880242oto.46.2020.02.14.08.31.52; Fri, 14 Feb 2020 08:32:03 -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=YOx9KsDM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406320AbgBNQ0K (ORCPT + 99 others); Fri, 14 Feb 2020 11:26:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:60672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405805AbgBNQYF (ORCPT ); Fri, 14 Feb 2020 11:24:05 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A36324790; Fri, 14 Feb 2020 16:24:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697444; bh=/5tkRGL7RFRgg+Lxu3NtXFouIi6LPnsmZ5Gf5BgDzf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOx9KsDMlfsBXWOEiURfv5rfPjiL53twn3i5EjpIQSdothVKC4TqyA3Z705XdHkun AnEo51fIyDm/msDmqN2dTmmOQoySlLFoFRbfyWKOWIFbGhUCf0bwTiiBAOYnWYbOb2 OSFASQyNzYDoV7VtFfA8gazhgemmka5PFuNi08Cs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vasily Averin , Steven Rostedt , Sasha Levin Subject: [PATCH AUTOSEL 4.9 130/141] trigger_next should increase position index Date: Fri, 14 Feb 2020 11:21:10 -0500 Message-Id: <20200214162122.19794-130-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 7e6971ba95417..8a88e85c8c615 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -126,9 +126,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