Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6823119rwn; Tue, 13 Sep 2022 09:26:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR78Ic+rPLGOusB5pZtiSmxyBLDfkYJc16+S7fClYmN50YEGt/yc7AdIIMD0Z1SoR9I4gsoe X-Received: by 2002:a63:3247:0:b0:434:6959:ba0e with SMTP id y68-20020a633247000000b004346959ba0emr28072304pgy.22.1663086385871; Tue, 13 Sep 2022 09:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086385; cv=none; d=google.com; s=arc-20160816; b=QPxOawZS20JXocW/pxTa2nXnv/CKBOwH0Vw1quoC4sfxPvAKqYQKzBgw2kGUAIx0Bt wTkjq3m3V+13hjmZXVaRbFPIWukLDfPxl/0vlYLklzUo3dPLr+qrwCgSS8MJMgg/2l/0 1ldY65G0DLBi2X+HuC0MUO3QImfhqzbhVjbVooYWdWq7wEikVn/yg4wq76iSmq9caBzl TrPF6hK3+wwii1hCt9TxSnIUjERPHxXF3aVimTgY/Z5kYoKBii7s9HqS6AbT6w7SL3GP qxE2HM10C/3n1dtGyYYmj15kCEFhCxnu1zeSs56g1jVwib1Qn+z+NFEPr7dsOZ9ptwki JoEA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mzxUNW6fOlQKQos0fV+k95YLfjseyy8zP19aD4bVNGo=; b=UAML1gk7L8igm55Yd++AVn6c865dvCwoeF/ggauROn4MSK1Y4PK3bpaLOIRtQOZE0R 777K96C0lW7z+K9nxyUSaY++pn9SGbHTxPg+cuWd8BI1zXadtC0gzufSHpXOPniTPhyJ oaLs0qezsVLPpEph89Pff0pDTmnoadppw9OVSP/rQfJLvGEcI98xAyIZTHA09fnUEzTG 9iLXH7lDWFza1X33Gqrg26O0cs1CoI4zZ0fAHxyqz2HQEEXXC7TF45AmrDwj+WNtlN5w Fu+atcj5HDw79ItsVQ0ptmu6Fvgn/rrsi0tpT5cpu6ZTo8fekxzNUQhTmxC8WABUC9fj ecag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mBk7lqiS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 198-20020a6300cf000000b0041c26691e57si12324904pga.725.2022.09.13.09.26.13; Tue, 13 Sep 2022 09:26:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mBk7lqiS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235609AbiIMPLM (ORCPT + 99 others); Tue, 13 Sep 2022 11:11:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235800AbiIMPJY (ORCPT ); Tue, 13 Sep 2022 11:09:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AEC877544; Tue, 13 Sep 2022 07:32:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5D623B80EF8; Tue, 13 Sep 2022 14:21:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C027FC433C1; Tue, 13 Sep 2022 14:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078886; bh=DCbveamGbgtaYN1SY5j/jewkUNGShxwvdYSd92uBLLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mBk7lqiScNrAMFE6LQQAeko8Ff2m7+tJhI9mdR8njL94i9aq1Ci/l8SrwCyVsVOmK sF/Ly2vnN2TZa/J9C/pYpBwBIsHd8jbhpSBSQiqgDZM88hGq/C3QZ2rAifGfXh+z+o zur6UB9Di1qL8m94D5MtzwZOmbHbtUed3H85qXaw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Ian Rogers , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo , Jisheng Zhang Subject: [PATCH 5.15 120/121] perf machine: Use path__join() to compose a path instead of snprintf(dir, /, filename) Date: Tue, 13 Sep 2022 16:05:11 +0200 Message-Id: <20220913140402.519862310@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo commit 9d5f0c36438eeae7566ca383b2b673179e3cc613 upstream. Its more intention revealing, and if we're interested in the odd cases where this may end up truncating we can do debug checks at one centralized place. Motivation, of all the container builds, fedora rawhide started complaining of: util/machine.c: In function ‘machine__create_modules’: util/machine.c:1419:50: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=] 1419 | snprintf(path, sizeof(path), "%s/%s", dir_name, dent->d_name); | ^~ In file included from /usr/include/stdio.h:894, from util/branch.h:9, from util/callchain.h:8, from util/machine.c:7: In function ‘snprintf’, inlined from ‘maps__set_modules_path_dir’ at util/machine.c:1419:3, inlined from ‘machine__set_modules_path’ at util/machine.c:1473:9, inlined from ‘machine__create_modules’ at util/machine.c:1519:7: /usr/include/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 2 and 4352 bytes into a destination of size 4096 There are other places where we should use path__join(), but lets get rid of this one first. Cc: Adrian Hunter Cc: Ian Rogers Cc: Jiri Olsa Cc: Namhyung Kim Acked-by: Ian Rogers Link: Link: https://lore.kernel.org/r/YebZKjwgfdOz0lAs@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Jisheng Zhang Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/machine.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -16,6 +16,7 @@ #include "map_symbol.h" #include "branch.h" #include "mem-events.h" +#include "path.h" #include "srcline.h" #include "symbol.h" #include "sort.h" @@ -1407,7 +1408,7 @@ static int maps__set_modules_path_dir(st struct stat st; /*sshfs might return bad dent->d_type, so we have to stat*/ - snprintf(path, sizeof(path), "%s/%s", dir_name, dent->d_name); + path__join(path, sizeof(path), dir_name, dent->d_name); if (stat(path, &st)) continue;