Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2076622rdb; Mon, 9 Oct 2023 11:40:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHw6EAnN6I+iiuQYyrl1Rm7tgNYRm7sK6wY526mGoPs5xX16NlDfk3VUMIcyiJDPMy1fZeN X-Received: by 2002:a17:902:a983:b0:1c7:2697:ec09 with SMTP id bh3-20020a170902a98300b001c72697ec09mr11889097plb.59.1696876801927; Mon, 09 Oct 2023 11:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876801; cv=none; d=google.com; s=arc-20160816; b=shngYrfcYb4LFD2en4WxTlrjbLtgWQCiRevvLo+YXzQAnjnw1J7xJvp/G92e59bk8X y7CvgkMLCuyz6WZaW6zEloQFPw+WDPN9PNqWMDnOKqCUXWUtsurA/lmoIihCEjoosy6h DxSv2wpT4ASvrQnK2aNFaf8+MgwpTGycOV/TCq8dQ1xHU427nKk1UBhYf/Jh9NAeAmWf b1VXPsbdK00Vqug54Bg9ZESJiPa2cqyXovUyuyOGeT5DlDRFjnyD2u5FIzxCAu18n7sC YF1JFurhfrcWTHUMf4I6QgbY5+6z7zaOC5g2h7A0PU+qrV8yYZErZRI4e+mtTrjwSYni F6Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=MTpWBQgPQVQy0TAZXLEWpBVQQ2YTPMy6ZmoyjFN0GGE=; fh=8uoRd8OfBKdrcgzCS0TCbKG83gg6rx5b6zeE6Tx82zI=; b=OrGlVYUqB6GMSgcgjMudH/5bbZaFEKtoj4ycpMvQvO8svQMy/cydIWeQ/WBuuspSE+ mpzKCYBw3R1ZgINTjOChRYsc788a6rgLQlgcxEhGzIdHKYKq47nMkr2SHjoRycM2T2mD nZc7QDHiNc1uAJwH47D6hjHjdzgD4IL86WmS2qWFP2h/badO+anxicQUndIPBxumd6UX V9WN/dUW9+b1L+vh/RMAX0egQKufJPM+E1sUoUZ6hbUSuerRMH03lmBBKBBln38PAFHM pyw1JRjRi2KerO96yJGX/6Huih7VoXOP1kcZV5B7voFbdQWQOzRprg5hGIHQG+CBrZHQ A2yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qmHE39qm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ju4-20020a170903428400b001bf1005924csi9619366plb.321.2023.10.09.11.40.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:40:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qmHE39qm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E5CCD8038F9B; Mon, 9 Oct 2023 11:39:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378203AbjJISjy (ORCPT + 99 others); Mon, 9 Oct 2023 14:39:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378233AbjJISjn (ORCPT ); Mon, 9 Oct 2023 14:39:43 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7855FE9 for ; Mon, 9 Oct 2023 11:39:41 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d9a45e7e0f9so427375276.0 for ; Mon, 09 Oct 2023 11:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696876780; x=1697481580; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=MTpWBQgPQVQy0TAZXLEWpBVQQ2YTPMy6ZmoyjFN0GGE=; b=qmHE39qmWSQLTvMKSb2BXWkZwWApobrmAKmtm7mq0rdAfERykcCz8xuEv/bWuEJrqR tnmKKm+FW/8n87xQW6j46XHC1I69IvsnbrRD+eq7avKDUZjaaLT5NPpL2+QH4kMMJGxF oLHBfuj8Ay9PG2bb1Xsvc5TFt1eA6gldWFNmCUu8A+Xmbb9HNYFwanXrIysLcHzqhQng xQghqyRJxKTcDczz03ooQZrEV0ZqSOoTmcEDLoIV6iQGziWpRLIGJechrq5dlMksBYPL iZL+Iogh3FbQHeZ/KNso2dBNHvlndvgG9Ia5W3q4vZXjUmeOI2uE+gvt5XMCvqQ65947 T9wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876780; x=1697481580; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MTpWBQgPQVQy0TAZXLEWpBVQQ2YTPMy6ZmoyjFN0GGE=; b=h4q8ZBNlDZ/rfX1I9bjr2G6cuzsPi01ySZxGsAefV1qt1oBEhKZnR9jvy9ZEwGHeOh +YI4VBBUKiZhCpdcvoN9eaYcd0dDsX6/kqtxj9mXts1+2tpsuYDOXyvvZyciQWcd301F qEXnF5D1hhEUH4u/UeSbau7F8W+VDsZZLBkwm/LEnYdmrdIkZsDG+XSYkO55M0/recw5 8fpx/n+S9tEDFa03MVhEYdIJDmbtMaapFxe1aKPndcqXB+uobv7fhbwOQqGSzAUXJw6Q P9WhVDLyb2MP88/1XtilA/rXhpkkTCzMZlbSXQSq5g0/A4lIDVvgRIB5/kthyPU5WrSo a4Zg== X-Gm-Message-State: AOJu0YzbzYRycaIdUoQlEBBNGrc4uZ+ixDB7p9MfZF+c1s81ayjNKZIQ uqurHWMP8BlESivvYUEm3oAvAwBrj4JM X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:ac4a:9b94:7158:3f4e]) (user=irogers job=sendgmr) by 2002:a05:6902:181a:b0:d89:3ed5:6042 with SMTP id cf26-20020a056902181a00b00d893ed56042mr268371ybb.11.1696876780144; Mon, 09 Oct 2023 11:39:40 -0700 (PDT) Date: Mon, 9 Oct 2023 11:39:07 -0700 In-Reply-To: <20231009183920.200859-1-irogers@google.com> Message-Id: <20231009183920.200859-7-irogers@google.com> Mime-Version: 1.0 References: <20231009183920.200859-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Subject: [PATCH v3 05/18] perf buildid-cache: Fix use of uninitialized value From: Ian Rogers To: Nathan Chancellor , Nick Desaulniers , Tom Rix , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Yang Jihong , Huacai Chen , Ming Wang , Kan Liang , Ravi Bangoria , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 11:40:00 -0700 (PDT) The buildid filename is first determined and then from this the buildid read. If getting the filename fails then the buildid will be used for a later memcmp uninitialized. Detected by clang-tidy. Signed-off-by: Ian Rogers --- tools/perf/builtin-buildid-cache.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index cd381693658b..e2a40f1d9225 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c @@ -277,8 +277,10 @@ static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused) char filename[PATH_MAX]; struct build_id bid; - if (dso__build_id_filename(dso, filename, sizeof(filename), false) && - filename__read_build_id(filename, &bid) == -1) { + if (!dso__build_id_filename(dso, filename, sizeof(filename), false)) + return true; + + if (filename__read_build_id(filename, &bid) == -1) { if (errno == ENOENT) return false; -- 2.42.0.609.gbb76f46606-goog