Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2228598imm; Tue, 10 Jul 2018 15:59:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfvkTbVwlJRKxoyXUSQt7wmIuTe86WXj0m2ZevfcS+OylHKw5tKb3M/Tpj5RhXeWVUfLO/q X-Received: by 2002:a65:5cc5:: with SMTP id b5-v6mr24100383pgt.425.1531263556908; Tue, 10 Jul 2018 15:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531263556; cv=none; d=google.com; s=arc-20160816; b=UpD4yrzVgpY6qbIPjNsChvRhXlwBvM5LkgzsJt7o14ILRO3ep1oNtQDF58K9ahQVjq BDNJrHELW6+GPRETyoYeRxrWGIqunAE+6AqKFoCCnt1yvP49AJZap2+h3yuaHsCM5cop MknfLSPa3I5WuVZSp+89p9bouoEpAiVu62mcFpkwzPoKFiCvQE1Qk56tTeeZvnia8vnj 8jYGkwqWdLdLv4aA0fEzbdq9IRSeC+6xLPBzcI9c5kTlDKH7TjIQIogQdSvU+/Jil/n+ DlTln7/T6RnX/46ORWGRJCYp0BcJ/MNbiNOdpI7Vw7//WHNd2RhC7+m9/M9CVSe45lEZ y0vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=BueH1j/bru/OprjIhHG+iKfut8Fh/wOEYHuTqZyn8Q4=; b=HWz6Y0yfriKutskgzPnYdyGetROreffY0wRFQNk/zbQ1n5+48p8UIzXLS+IjND3h75 N4ng2RnuIQucwG4lSZl28XLICxLy7/wL3dtMWqPhQy1pmfBBQ8RFOCdcEygRDX5sVRya M+2VEgysnozwz798vaClz80Zqy1jeQF1WeRAXTVnWR40Z/DR8yEkTw0gpuhxH7T2N5n8 P8vEUNsCKVeYqTGwhsP93Jemss+jPyUQ+KBKvS5Z6RekxX6J72lsSk5dCvFtZYbbMufE OoE9W6RwrtSSf9LSbnpjZI/PcZISCNjof2HvHiPE6qi7lZeX3YtKPWyhSzybgVkLw4D7 tv1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j193-v6si16967236pge.689.2018.07.10.15.59.01; Tue, 10 Jul 2018 15:59:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732292AbeGJW7p (ORCPT + 99 others); Tue, 10 Jul 2018 18:59:45 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43856 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732264AbeGJW7p (ORCPT ); Tue, 10 Jul 2018 18:59:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A31481663EE; Tue, 10 Jul 2018 22:58:27 +0000 (UTC) Received: from krava (ovpn-204-33.brq.redhat.com [10.40.204.33]) by smtp.corp.redhat.com (Postfix) with SMTP id C3D2B1C4C3; Tue, 10 Jul 2018 22:58:25 +0000 (UTC) Date: Wed, 11 Jul 2018 00:58:24 +0200 From: Jiri Olsa To: William Cohen Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, namhyung@kernel.org Subject: Re: [PATCH] Check jvmti_agent snprintf return value to avoid build failures with GCC-8.1.1 Message-ID: <20180710225824.GA11928@krava> References: <20180710182716.21801-1-wcohen@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180710182716.21801-1-wcohen@redhat.com> User-Agent: Mutt/1.10.0 (2018-05-17) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 10 Jul 2018 22:58:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 10 Jul 2018 22:58:27 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 10, 2018 at 02:27:16PM -0400, William Cohen wrote: > Newer versions of GCC perform static analysis to determine whether > string truncation is possible with functions such as snprintf and > provide a warning if truncation could occur. The make for > jvmti_agent.c uses the compiler option that treats any compiler > warnings as compiler errors. For GCC-8.1.1 in Fedora 28 this causes > the build to fail. The return value of the snprint is now checked to > ensure snprintf produced a NULL-terminated string. If the string for > the path is invalid, the code does attempt to use the string. hi, I posted fix for this recently: https://lore.kernel.org/lkml/20180702134202.17745-1-jolsa@kernel.org/ it also covers the perf_regs.c, which was failing with gcc8 for me should be pulled in soon thanks, jirka > > Signed-off-by: William Cohen > --- > tools/perf/jvmti/jvmti_agent.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/jvmti/jvmti_agent.c b/tools/perf/jvmti/jvmti_agent.c > index 0c6d1002b524..30f14eafe4b3 100644 > --- a/tools/perf/jvmti/jvmti_agent.c > +++ b/tools/perf/jvmti/jvmti_agent.c > @@ -227,7 +227,7 @@ void *jvmti_open(void) > { > char dump_path[PATH_MAX]; > struct jitheader header; > - int fd; > + int retlen, fd; > FILE *fp; > > init_arch_timestamp(); > @@ -249,7 +249,10 @@ void *jvmti_open(void) > /* > * jitdump file name > */ > - snprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid()); > + retlen = snprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", > + jit_path, getpid()); > + if (retlen <= 0 || ((int) sizeof(dump_path)) <= retlen) > + return NULL; > > fd = open(dump_path, O_CREAT|O_TRUNC|O_RDWR, 0666); > if (fd == -1) > -- > 2.17.1 >