Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3071394pxa; Tue, 25 Aug 2020 10:36:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoyjk+oU/9cGFwMaysaanmKSz2qq+HKnNAqHVdGTdIDlwBUsCjtR5HgVeg0G92UDiyXUKk X-Received: by 2002:a17:906:40c8:: with SMTP id a8mr11541781ejk.536.1598376966535; Tue, 25 Aug 2020 10:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598376966; cv=none; d=google.com; s=arc-20160816; b=Mj+fwgKRxG1MIv77btqjhohNgU2HU5zFXQz2fgPpFFfa7jEc2iwZ28al9/vUbUsQlL IT+LHSMC31Ol449nll5Unxsoea6EoIZzhfHhC8r1S9R7EAhrGHk9XYwimOKecNirI6uu wm6iaFd3Sez/jve1x5CzevAR6Nyf+1Ybj6qYHC9lEz8ahJPW2BD3jnxGLWpYApzT2Pbm eiQ+Y7UKT9ulr7wnRiBdxdBCs4ExWzyhkTi3SC4B3xExXFp70Cbm19guuJ0ThM2V+zJz MP7lw2CenopAkTWRyYKSOeeH7pqgABZ32IFrDTdro5aEiK8uUMnENqx3pKxgpdnmOmuS SfuQ== 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=3Zb3O25WoLFkngCfCQG+fPmc0tqenZMw1StPfudPSEQ=; b=tBJav5U/ME3pXn5ZVfpXgAdKdVmjrigSwg+8JiSsZa1PdWstPAXS+pV678vva4XUYX FAo9UpHF2IKNQv/xwYREqckhLh+/ihbp+uaj5MzuAa2IMOoXKwodyxedCFbM5Ei4u3sR y7sDhQPIQoJl6jYMeRnaqWsOW40jhSoY53jNKP6cGibAuFfqD985zrVrYPp8vjdk8+AZ Mb21dl3unyHmUmiVsmE7yDUWfZG/1yBpVcZC0ciQWZJYwTHJBT5dXr0A1H6n8JV0O67A 8jE21LUyLN+7q9uc4UQCtqOOolvkFlXmoCf8MYMNpAQGvnZRMp3fTmFCiNLhl+snek8G e5Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=g6o50Bxw; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si5116868ejc.206.2020.08.25.10.35.43; Tue, 25 Aug 2020 10:36:06 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=g6o50Bxw; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726739AbgHYReK (ORCPT + 99 others); Tue, 25 Aug 2020 13:34:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbgHYRdu (ORCPT ); Tue, 25 Aug 2020 13:33:50 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEEBCC061574 for ; Tue, 25 Aug 2020 10:33:49 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id 5so8226881otp.12 for ; Tue, 25 Aug 2020 10:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3Zb3O25WoLFkngCfCQG+fPmc0tqenZMw1StPfudPSEQ=; b=g6o50BxwHog+DdqQpMPOSsEmmzcZL4EmTrGrMO8bNYnEHjeNPoEolgwpY0zAuIIzk6 uKUDjGHyjfglmrpJu+MyUxvfrbhkEpZ0u9SKab0HqB0lIzrd1+x/tzSB3oT7PlIL/rXy YLrZ+XkuduT1lhKAfI0CJWfv2WISTmCSokoAX36MY0BKtI83p4Jpy5TJEc2n4+lekaXu xjJTaTIEpOaj1PXnvy94XUE4W6qSsxCITbtZfrgATKTp6PuFzK9Kuu59A70SpcXvOkGS BCksbHv9mVvOR6yh2iy6YJg2qT/JdFuAZ959VMqoA/L/bL6ytzVSk+0ZOhkk4irxnh7h jFFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3Zb3O25WoLFkngCfCQG+fPmc0tqenZMw1StPfudPSEQ=; b=ZYU3zeRNWbfy891cLA0JYkM/U0sb6cRmrcNggzNtEI4TZ+YtfhZbk8/kwdDhT4Vr46 ZrL/VlM9KiKSU7919ULjFkIqqyDx+HVDxeyq4AuOsn0CGvZZH5bZ5dcdYtBJRn4oinUo r0sCdByp2r1kAU+3fwyxGuTvAmN3gjmRD0QXGYqqlDLgA1oz/nTEiIRwrCSQ2/cGxcMf pLAQevhuf9SiqL2FXhqWlYLEKP2AT4a0mclH5PDtHjYT97wh+b7cpgcD94/hNqhdE8Av NKZfcn2ZyTs4pNrxzy0ixh4m8hJD2IC53NNmx+U/c3RTie4uvseV5vpzDX3eQziYLCQW NOyw== X-Gm-Message-State: AOAM531cYZPFFpbvdNAyjP27g/gMQWATihtabPKAU7QqAhHNVyw4zqWu kgDkHV13yB3fZnodusRWk+U= X-Received: by 2002:a9d:ea5:: with SMTP id 34mr7731340otj.199.1598376829090; Tue, 25 Aug 2020 10:33:49 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8203:5970::c4c]) by smtp.googlemail.com with ESMTPSA id x11sm3214168oot.0.2020.08.25.10.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 10:33:48 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: Jim Cromie Subject: [PATCH v2 3/3] dyndbg: fix problem parsing format="foo bar" Date: Tue, 25 Aug 2020 11:33:39 -0600 Message-Id: <20200825173339.2082585-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200825173339.2082585-1-jim.cromie@gmail.com> References: <20200825173339.2082585-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 14775b049642 dyndbg: accept query terms like file=bar and module=foo That commit broke on a tokenization modality where a word could start with a quote, but couldnt continue with one. So the above would tokenize as 'format="foo' and 'bar"', and fail hard. This commit fixes the tokenizer by terminating an unquoted token on the '=', avoiding that problem. And since ddebug-parse-query will never see a combined 'keyword=value', revert those parts of the previous commit. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a23b5d153153..04b851117eeb 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -237,6 +237,7 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) { int nwords = 0; + vpr_info("entry, buf:'%s'\n", buf); while (*buf) { char *end; @@ -247,6 +248,8 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) if (*buf == '#') break; /* token starts comment, skip rest of line */ + vpr_info("start-of-word:%d '%s'\n", nwords, buf); + /* find `end' of word, whitespace separated or quoted */ if (*buf == '"' || *buf == '\'') { int quote = *buf++; @@ -257,7 +260,9 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) return -EINVAL; /* unclosed quote */ } } else { - for (end = buf; *end && !isspace(*end); end++) + for (end = buf; + *end && *end != '=' && !isspace(*end); + end++) ; BUG_ON(end == buf); } @@ -373,30 +378,20 @@ static int ddebug_parse_query(char *words[], int nwords, unsigned int i; int rc = 0; char *fline; - char *keyword, *arg; + if (nwords % 2 != 0) { + pr_err("expecting pairs of match-spec \n"); + return -EINVAL; + } if (modname) /* support $modname.dyndbg= */ query->module = modname; - for (i = 0; i < nwords; i++) { - /* accept keyword=arg */ - vpr_info("%d w:%s\n", i, words[i]); - - keyword = words[i]; - arg = strchr(keyword, '='); - if (arg) { - *arg++ = '\0'; - } else { - i++; /* next word is arg */ - if (!(i < nwords)) { - pr_err("missing arg to keyword: %s\n", keyword); - return -EINVAL; - } - arg = words[i]; - } - vpr_info("%d key:%s arg:%s\n", i, keyword, arg); + for (i = 0; i < nwords; i+=2) { + char *keyword = words[i]; + char *arg = words[i+1]; + vpr_info("key:'%s' arg:'%s'\n", keyword, arg); if (!strcmp(keyword, "func")) { rc = check_set(&query->function, arg, "func"); } else if (!strcmp(keyword, "file")) { -- 2.26.2