Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp3066123lqt; Tue, 23 Apr 2024 09:24:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU7DIgERpqKKmO7ZrxEGgdx3vY8WA7UicQkyhb+dgSpCaBr0bi5+Hi/wFXSVNY61FO941fHZ68NSIrOKRxnkEVWdBLMg3DO3FH7u8nETg== X-Google-Smtp-Source: AGHT+IElQAp9vhx1o2+XhvGrvjVB8XpL3Z3t/72hNnxMDZ0lUARKFp1Zri6okZZST9SmJzkeLRh6 X-Received: by 2002:ac2:4c01:0:b0:51a:f571:bebb with SMTP id t1-20020ac24c01000000b0051af571bebbmr17782lfq.51.1713889462424; Tue, 23 Apr 2024 09:24:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713889462; cv=pass; d=google.com; s=arc-20160816; b=TNBYLGo4hXFsiQW9jH4fXNmWTAeCFMVOtAWeLAd0QRn5kG5FnLbtmCLY0EXkuOD2jy nN4lw1y6f17RX5ZjN+rp3a90fOdvq/HXKs/K8ky47H+DXgcnLglBipwMgIJ8MwQ4pGRd pmHf0tXQr7UqVULrBO6XtfG/lWxpK+jt2xQWwyd0yOpcVFe42p+bagqhDBKd9gTEGTzO /5By/ish2aseVI5cg2eG+KttkTWrt9qx8451BkKLlCdHhXoh9lqoD45l5LN620e/u78k 5c5GM7AzWvsjzHBdmAEeGUzAmi8BfZEGZmeDLH/k0yQ26WOUpnYFBHBFwGfv717+ax5i ETeQ== ARC-Message-Signature: i=2; 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:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter; bh=GrfTFKMTYc6Wjy1jyI4qZjJ77SgqBxd4tOudBF1fvJM=; fh=+1p5GoW/Fj2wsGQaZOHY54bywTWT4jZUcLLDaZNLqH8=; b=BUthqsdb/dYSQ1VEkL24jJi++0SvZp2ygmxOxEc0OlztX3+BxdhDuDpT5sSpi4sw7b cr3p0XSOnA+XuC/XVsG+dLaYEnDj0ZOZFo0NUGTAtEc8EjHpEzuilH4UsSzIifRaP4N7 fgg2ePKZWP9KHG1hQBlkOTqon4mRcrTT0rnPcn3RnP6ny+wwRPr03jRND1Yagr75vmvI QO1r3tfvfjFQm2kaQXDmB1lW0np9NKSE4dCYGwHu7gabjvTldI80RgUMJh1K6QW3fjPQ xQ8+VtbXNf6nwqaOp2Pvimk2ZVnOwf92sOYDJY34izHyhKssNpa6QI9/7/Eo6Zp8PcCr MS1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="Ui2S+e8/"; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-155553-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155553-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g16-20020a17090613d000b00a5887f917b7si207504ejc.532.2024.04.23.09.24.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 09:24:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155553-linux.lists.archive=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=@linux.microsoft.com header.s=default header.b="Ui2S+e8/"; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-155553-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155553-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.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 269A41F232B9 for ; Tue, 23 Apr 2024 16:24:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 773CF13D2A1; Tue, 23 Apr 2024 16:23:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="Ui2S+e8/" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BA0213D254; Tue, 23 Apr 2024 16:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713889425; cv=none; b=sGQ3nuiXnlB5XjKkVE+FuuSvWpobmHlaNNP0zFaSDqh8/JuuH5NBLR147nSnVdxG8n4GQakAgPgzniUTx/OLPGgjb7XegOxCyNljN6KBdfeZby7CIZ49i0V1F3Yewx/c32t9DihogdbKAxVhSkkWNxX4lRCsSLzeQvXElv9RvHU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713889425; c=relaxed/simple; bh=w4YN+H4gxVX9bCiaMWUd1g2Z7829wyxFUEczrxYlHHs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=OVVIhUx3m1rQlahzmiJqoD6LwHf4yRpEAtlc7mELY8UhoUo+oV71ptLDrGXo4QtRQEZDUWBC+57Up0PBPiqjO/4jvZB2TY8ds2eFZ0jPxqm+rLp1g1mIex0e+eeOTUpmcclLgD78PqKVNmcgPjVcF41tlUOQVUw1hF80GAw/rKE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=Ui2S+e8/; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from localhost.localdomain (unknown [4.155.48.122]) by linux.microsoft.com (Postfix) with ESMTPSA id E383120FFC15; Tue, 23 Apr 2024 09:23:43 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E383120FFC15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1713889423; bh=GrfTFKMTYc6Wjy1jyI4qZjJ77SgqBxd4tOudBF1fvJM=; h=From:To:Cc:Subject:Date:From; b=Ui2S+e8/ZOoBfqQWBZGQFYfxPL50UYJviLZAhEGrWvpaqpNJBFVzBA65qc1L/E+WL bfFnYSV8pL4M+PdsJm4oijDL+X3T1T6Ex1h2FUbiPPtyLkqSAqIao47Fs7WYdAUN4w KKnqSbkTNJTeAyhzRPEg0BmyQ0g6J24G7jR4tA+k= From: Beau Belgrave To: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, dcook@linux.microsoft.com Subject: [PATCH v2 0/2] tracing/user_events: Fix non-spaced field matching Date: Tue, 23 Apr 2024 16:23:36 +0000 Message-Id: <20240423162338.292-1-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When the ABI was updated to prevent same name w/different args, it missed an important corner case when fields don't end with a space. Typically, space is used for fields to help separate them, like "u8 field1; u8 field2". If no spaces are used, like "u8 field1;u8 field2", then the parsing works for the first time. However, the match check fails on a subsequent register, leading to confusion. This is because the match check uses argv_split() and assumes that all fields will be split upon the space. When spaces are used, we get back { "u8", "field1;" }, without spaces we get back { "u8", "field1;u8" }. This causes a mismatch, and the user program gets back -EADDRINUSE. Add a method to detect this case before calling argv_split(). If found force a space after the field separator character ';'. This ensures all cases work properly for matching. I could not find an existing function to accomplish this, so I had to hand code a copy with this logic. If there is a better way to achieve this, I'm all ears. This series also adds a selftest to ensure this doesn't break again. With this fix, the following are all treated as matching: u8 field1;u8 field2 u8 field1; u8 field2 u8 field1;\tu8 field2 u8 field1;\nu8 field2 V2 changes: Renamed fix_semis_no_space() to insert_space_after_semis(). Have user_event_argv_split() return fast in no-split case. Pulled in Masami's shorter loop in insert_space_after_semis(). Beau Belgrave (2): tracing/user_events: Fix non-spaced field matching selftests/user_events: Add non-spacing separator check kernel/trace/trace_events_user.c | 76 ++++++++++++++++++- .../selftests/user_events/ftrace_test.c | 8 ++ 2 files changed, 83 insertions(+), 1 deletion(-) base-commit: 0bbac3facb5d6cc0171c45c9873a2dc96bea9680 -- 2.34.1