Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp217228rdb; Thu, 25 Jan 2024 12:59:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTN2zJhW+tkW3068ZuE5Sw4wh0Icjh6kZWIp3G+MTZbpAwWE84SAZEh5C+nZK0nsc9PsyO X-Received: by 2002:a17:902:ed97:b0:1d7:6301:96e0 with SMTP id e23-20020a170902ed9700b001d7630196e0mr318127plj.8.1706216390814; Thu, 25 Jan 2024 12:59:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706216390; cv=pass; d=google.com; s=arc-20160816; b=iFY+1+fMzUEkGjFR9iUC/SXQoQ2l3B6e4013aQEf/c9fIJqLomb39ECG40D+G+282w qW3kLpI/dkPXgb6qzu8gcm+F9PHUEAtqEr0DTfwqwUYF+Bwcad8qPjT4v0jpmTBJFX4F yfxOq6PjZjNZElfmuQQ+K+s+XT2goUzo8h75sPFxF990C2f8vA89YrAOBdsPCFNLxRlg CoMnUkp26AjzxsTDT7s9wWWlY/WXrwUrIfjsMIFgPHg9CoIYQ1RQUQ+6Wm3EldjMjpaC ZH+02xyVxOzP1jXLJVCpOAxOcz2YCrP+r9pEJuFlAuVBlufARYqgRJnLYkIFmCPtZt8C hZyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=fxhQjCPn4Rmv3lAxNtNAmeDVJacck3kwKzoL0OQKBYo=; fh=tpGJkfiUspgur2RwrOQQ2DnIH5+9yLOCR1h5/m95ufE=; b=jfR5EaQphVb+JEH7cXyK9P5GrkmBgud4Vj6lCimry/0xoKYUKe8XksqCm5x9w8wQHm DfXxWjT9i0jxZGyIcbxTaW6ChT9WQrPLEx0irwqxxQsq4PcXqzDG+wDem1Iw5VDsWVCj 0qEtZqKGgz0fAr5lmRSPha2waVUiwZ4X2LKjZk8aDArMao43tTNGR4dEaRo6+028E0kB BkM0GyQNzb61VmtOIlQrjnQgaKMln2ks+d42N5WA46GdwyXr1whpczn0FlWf2dmi1l58 22KHXDuy6kyXSjsFKXshN7TeUPqAVXRtgZWdHKr9IUVkUZMqR1cYiimp6TcjE+2qCshr R7vQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SMe0vKK4; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-39271-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39271-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y11-20020a170902700b00b001d4e20ce9a7si14036678plk.33.2024.01.25.12.59.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 12:59:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39271-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SMe0vKK4; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-39271-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39271-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 684CB29B82A for ; Thu, 25 Jan 2024 20:59:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D798E1386CF; Thu, 25 Jan 2024 20:59:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SMe0vKK4" Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3B5F13665E for ; Thu, 25 Jan 2024 20:59:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706216382; cv=none; b=Mj0sg4I8LqJwhhA0kFufObg1No4GV5ARqJbZbrpKE4XyHPQL8eJc86M/mQLVCuv2e3/Iv8+bb6ZlToHt/4/hHNXnj5Pn+NYB5EhZ34vTspSNQx16Wv6wdmcpQvjGDwv0EEH1F9wfqQFJiVIcLGK9fCjSvrudeX88zEoP33ymS50= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706216382; c=relaxed/simple; bh=kugWdLPRbZv+nvzTzXeYEHDhAGQHx+mp0pJFpgLrtHU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=uiuvTHrCtxVRRk4Io7flrtMk0ovWrL3baZNV5H4AxV6jd1O0xPNsx+ES3QL6Wgj66rhJzwf8STGg0Rb1x1qq6eaZA4jE4JjJrpikAiBq7OWXtSReZqaa9su5aAUS7VwbmVQRSAL49IExlT/P6OOIf2v+vdmWhFKX0MM5CmWfzTk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SMe0vKK4; arc=none smtp.client-ip=209.85.166.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-il1-f178.google.com with SMTP id e9e14a558f8ab-361a829e012so17215ab.1 for ; Thu, 25 Jan 2024 12:59:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706216380; x=1706821180; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fxhQjCPn4Rmv3lAxNtNAmeDVJacck3kwKzoL0OQKBYo=; b=SMe0vKK4SSoZ8TR2ECS4eYh2DX7n11XvgPG2OIGXfJf2LSunohim7xvl+TvkNOzMnI Pf37y0CNYNq5Pk0lkrGmN54EzrUZVezz9C2So+O0nhuKfmTVFjEyxl3MCTYUBhpCM3z5 s/tFi9rRLwE0yYxx+++17WEAl1yVnrKY1hBLFm2BvZuhz5U8UEmQDVviVzm+kYNXDyRY rR82/b26bOiLhflumVwkStXiQlM+MEEoVy58JRawyt+eAWYxesZWwm9rVvQIfUOumLhv xA9RVLLBmkDRgeZGmorJWEIB2wgc1VfiYlOoYrOGBDuTm1NUsCooYzHDIHW0EsMc7nS9 zSvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706216380; x=1706821180; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fxhQjCPn4Rmv3lAxNtNAmeDVJacck3kwKzoL0OQKBYo=; b=Tbqn9P/w8T5pAd37xMdBgNpSWuUlhK2qMNHz+e86HXECs0GAnD7PdYA8mPAWsDigQC pQYzqEI7anReLze07agjSE8G6RUVjeW97j8A6Hq2KEXM4onCtzgezi611iROTiutUk56 FvO8lq3lHSwWUx8xt8rt9uFMkPC/ZsZ9rNnZTPu4gZ1v5kxHfNzPDv5rd20fjP6FdPOP Lo5pBTiVCCPsmlbPCQsJBgx0Kdw2aGoMzCIY21+G36DesrLJqCttmq1+tmQr9SZy2uCi 8NrVOHlsaSwIDY+fV0sz4KS9MXkgqpcGdQRQWyvXEjeODnmknf/WGDvNDHQmjY0gTXyC gM8w== X-Gm-Message-State: AOJu0Yyhoxz+rHO2CJoKOpEcflA/HCmuafohQKA2XeMFtJUCMe5Wk8pP PKQsEZyZuoM201jpqehzvH2MhGMnPgX9R2ipvo6aS1LctRWhiuqmfUzu2fUxpToxz3NMi6QM1Pu 1JuTSu3Pr1PK+uLBazmVoM5NrDLq3B04EAwiA X-Received: by 2002:a92:d4c9:0:b0:35f:6f66:286 with SMTP id o9-20020a92d4c9000000b0035f6f660286mr3777ilm.11.1706216379661; Thu, 25 Jan 2024 12:59:39 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240125184411.30757-1-kotborealis@awooo.ru> In-Reply-To: <20240125184411.30757-1-kotborealis@awooo.ru> From: Ian Rogers Date: Thu, 25 Jan 2024 12:59:27 -0800 Message-ID: Subject: Re: [PATCH] perf data convert: Output empty string for null pointer To: kotborealis@awooo.ru Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 25, 2024 at 10:44=E2=80=AFAM wrote: > > From: Evgeny Pistun > > Providing ill-formed input to `perf data conver --to-json` > causes it to crash with segmentaton fault. There's a bug in > `output_json_string` functon: input string is not validated. > This could be reproduced by crafting input that does not specify > hostname/os-release/etc, which are written to 'headers' section of > outputted json. > > This patch adds a null pointer check. If `output_json_string` is > called with a null pointer, it should output empty string (`""`). > > Signed-off-by: Evgeny Pistun Reviewed-by: Ian Rogers Thanks, Ian > --- > tools/perf/util/data-convert-json.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-c= onvert-json.c > index 5bb3c2ba9..f8fd22bd7 100644 > --- a/tools/perf/util/data-convert-json.c > +++ b/tools/perf/util/data-convert-json.c > @@ -42,7 +42,7 @@ struct convert_json { > static void output_json_string(FILE *out, const char *s) > { > fputc('"', out); > - while (*s) { > + while (s !=3D NULL && *s) { > switch (*s) { > > // required escapes with special forms as per RFC 8259 > -- > 2.25.1 >