Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp552240ybt; Wed, 24 Jun 2020 05:51:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx7AiAf6cA8C/7NPFmUAeXHD/3y02T3/jDeRs+rimX42XIDlnhTk0O8PsOj4ZHTISbf5dG X-Received: by 2002:a50:da83:: with SMTP id q3mr27484776edj.325.1593003110321; Wed, 24 Jun 2020 05:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593003110; cv=none; d=google.com; s=arc-20160816; b=F3lGfNMqNQ0DhViaLdS/dAVqN/NkxYee4k7Ydns8IntYVrsT3aBDh2bpL4/8PsSI5T cI4SpscxO4SSCustbKy1Cgfli5szhzJ81OmxFV6FW66/soV0ondepaSiHodsleE9kCIT 9Q4RtApkGlkph5YTs4KTPJiISBuMIwWh3WuU6NXHkeAGjulnjxgXHuRG114VA1KTbhcA UotH8tVMe5VPKC9uNS1gqUk3754m9qMRGd3PPIUKYG1D0hvIguVt098O+UGwwHKInPlV Tgv8/YXtxA4f9AIbQ6A5cDKnvTBkOo1OUC2iqrd2GttxW8V94kGlVqwLJXgtnMTvkLkJ VuJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=TOxBs2AuO1pUP4DqRoz2j9gAHwAjHmTBtWWCzWPuC7s=; b=np7VJrO+BJLk+RPJoaMx1PNJT/IBS0sZJLHdtjoxQDgfDGW3BbcsBHMg/1EmUrpm+w 9onBbjBpysJsawafvTQQEJi+VFwCsdyWcQxM7tXAwg6Z8EoerRSeBqjWab4BUj3LE1YN g+nQSauY94AWbqE5KwGbcu46ctMhlMBYIMr/6nwIZU6GohHw64n1LML/l3szSXzN4hQo usJvpBNAPbQ+lV1MVkWnTumTAbZ6aAUAqSFqJ94XbPM4s7493eCow/xjBO90pvhBEl5z XSk45hrUbuN6/Jo8R2+9b67SMO3ZXGhRAhikruY+gMj3Sd8dPEr0q1hc//vnkqin2Ld7 LkSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="jDSwQ/Sq"; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si12999109eja.471.2020.06.24.05.51.26; Wed, 24 Jun 2020 05:51:50 -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=@redhat.com header.s=mimecast20190719 header.b="jDSwQ/Sq"; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390896AbgFXMuy (ORCPT + 99 others); Wed, 24 Jun 2020 08:50:54 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:46204 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388942AbgFXMuu (ORCPT ); Wed, 24 Jun 2020 08:50:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593003048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TOxBs2AuO1pUP4DqRoz2j9gAHwAjHmTBtWWCzWPuC7s=; b=jDSwQ/SqqUko1So4/VlXpZlFPp2JbHcU2l5le+hOihZiN3AVAUNmIWD7YlTteo+ttc1O6y CE+pfv6asMEJRkUUZIC2ARnzbLtxK4xJ7B/5AFTlJMlBM8zoOcm31KqnxNDederHi3xF6X b0RMrME/FgQVwfvLjqKa0tCsU12IMEk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-264-igigxKaOM0ScstJE1tP5EA-1; Wed, 24 Jun 2020 08:50:46 -0400 X-MC-Unique: igigxKaOM0ScstJE1tP5EA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 20AC8800597; Wed, 24 Jun 2020 12:50:45 +0000 (UTC) Received: from krava (unknown [10.40.193.204]) by smtp.corp.redhat.com (Postfix) with SMTP id 48D1279317; Wed, 24 Jun 2020 12:50:43 +0000 (UTC) Date: Wed, 24 Jun 2020 14:50:42 +0200 From: Jiri Olsa To: Gaurav Singh Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Namhyung Kim , "open list:PERFORMANCE EVENTS SUBSYSTEM" Subject: Re: [PATCH] [perf] lsdir_bid_tail_filter: fix index check Message-ID: <20200624125042.GB2719003@krava> References: <20200624013524.10836-1-gaurav1086@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200624013524.10836-1-gaurav1086@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 23, 2020 at 09:35:22PM -0400, Gaurav Singh wrote: > Check bounds before accessing d->d_name[]. > > Signed-off-by: Gaurav Singh > --- > tools/perf/util/build-id.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c > index c076fc7fe025..8c35cbe93f10 100644 > --- a/tools/perf/util/build-id.c > +++ b/tools/perf/util/build-id.c > @@ -431,7 +431,7 @@ static bool lsdir_bid_tail_filter(const char *name __maybe_unused, > struct dirent *d) > { > int i = 0; > - while (isxdigit(d->d_name[i]) && i < SBUILD_ID_SIZE - 3) > + while (i < SBUILD_ID_SIZE - 3 && isxdigit(d->d_name[i])) hum, I guess it looks better, but technicaly this is not a problem right? isxdigit will return false on zero byte which is always present in d->d_name so it will never get out of bounds jirka > i++; > return (i == SBUILD_ID_SIZE - 3) && (d->d_name[i] == '\0'); > } > -- > 2.17.1 >