Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3360397pxu; Tue, 8 Dec 2020 09:58:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeiBuB9C/debrgSYVwdmSz8qgwz3yaUEQ/lbt0elgUXdypmu5jC5ZuGRc+dJOqX9LFd3RA X-Received: by 2002:a17:907:7253:: with SMTP id ds19mr25529624ejc.166.1607450307957; Tue, 08 Dec 2020 09:58:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607450307; cv=none; d=google.com; s=arc-20160816; b=WA5IghRHAjxC3OkJMfhNw+6VK+FZEQFxjQtSdvGrHIu6fZMh/Koo81jvDSienprBkl mR3RzIcayJCCwXgZXN4c7yWMOZeEeLIX/933oDLeHzTkFyOmBJKafiDDbc+5w8F34Zsy XsqwlpKOpTkZpSwW4NruGs1wMq7Qtt9nNdW333u/fXtPdzrxW4B0fks4yD6jVgIsDOia UJ+ANfJ5CZImG636HfmIr2o1p11wVeCg2Ggs393J2haXRhLEwPiIsqmvRObrUjnQ/++P CR9vt40iBV2d2kP0pDvlmLAtCziMQhH4YTRYRSdwa2s4rvpCsLHLiN4WenFelH/0tBsp UdsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=xYSMQvmamJYg7dFsfvnNmrmACp12z1ZbbJsw9ogl2tM=; b=K/5kPau0Bfhyu0x74xiqf6zpJgPhKONwrYDcEvbd2y4YqKBWnre4ODw+pp0QMK/MNX lCNwFDg5d+dgDnKfh/deiL5YRh3wdjiOxTU+jm4uIMM3kg5jWvnUhPOUabw2Rx3L21Wr S8fmvqluZn0mMhqBdJ7DaoGRrEO1iHa/Px/5xnz1vyLAOBLxxHOj6Ta0h6kuNB3aXZOc diTvLiIpDmfXKmvEHnl0fYRPdnKe7HuTMEv3QpWlBFXrGTTPEgDiZSTcNxTUXwSCbKk8 pEj2Ah8Q4mPlhM8N/QUZXZZIbvCAbMpNRwWk5vMr0gcAmDkBTIbJDVeyo0pDNaVQeZgD yc+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs7si11226050ejc.125.2020.12.08.09.58.05; Tue, 08 Dec 2020 09:58:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730576AbgLHRyX (ORCPT + 99 others); Tue, 8 Dec 2020 12:54:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:41062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726810AbgLHRyX (ORCPT ); Tue, 8 Dec 2020 12:54:23 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 17E3223B7E; Tue, 8 Dec 2020 17:53:42 +0000 (UTC) Date: Tue, 8 Dec 2020 12:53:40 -0500 From: Steven Rostedt To: Tom Zanussi Cc: axelrasmussen@google.com, mhiramat@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/5] tracing: Update synth command errors Message-ID: <20201208125340.407150f2@gandalf.local.home> In-Reply-To: <44b9e471f0d3b77ab0a2bf11024e2e72c1f1a80d.camel@kernel.org> References: <8671adc7ce95ff1d5c7b037d371467e96f7f2914.1603723933.git.zanussi@kernel.org> <20201207201304.627bfe48@oasis.local.home> <44b9e471f0d3b77ab0a2bf11024e2e72c1f1a80d.camel@kernel.org> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 08 Dec 2020 11:34:41 -0600 Tom Zanussi wrote: > Unfortunately, you're correct, if you have a script that creates a > synthetic event without semicolons, this patchset will break it, as I > myself found out and fixed in patch 4 ([PATCH v3 4/5] selftests/ftrace: > Add synthetic event field separators) [4]. > > So whereas before this would work, even though it shouldn't have in the > first place: > > # echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > > synthetic_events > > it now has to be: > > # echo 'wakeup_latency u64 lat; pid_t pid; char comm[16]' > > synthetic_events > > So yeah, this patchset fixes a set of parsing bugs for things that > shouldn't have been accepted as valid, but shouldn't break things that > are obviously valid. > > If it's too late to fix them, though, I guess we'll just have to live > with them, or some other option? I would suggest allowing the old interface work (with no new features, for backward compatibility), but new things like "char comm[16]" we require semicolons. One method to do this is to add to the start of reading the string, and checking if it has semicolons. If it does not, we create a new string with them, but make sure that the string does not include new changes. strncpy_from_user(buffer, user_buff, sizeof(buffer)); if (!strstr(buffer, ";")) { if (!audit_old_buffer(buffer)) goto error; insert_colons(buffer); } That is, if the buffer does not have semicolons, then check if it is a valid "old format", and if not, we error out. Otherwise, we insert the colons into the buffer, and process that as if the user put in colons: That is: echo 'wakeup_latency u64 lat pid_t pid' > synthetic_events would change the buffer to: "wakeup_latency u64 lat; pid_t pid;" And then put it through the normal processing. I think its OK that if the user were to cat out the synthetic events, it would see the semicolons even if it did not add them. As I don't think that will break userspace. Does that make sense? -- Steve