Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp467466ybi; Fri, 26 Jul 2019 12:54:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOd7DCV1F/opP5J0eLqfrDrdwuaRa0KR3fmhQm8I5egBn+fzM/aWeiF8d1J1s6HOdy4oY8 X-Received: by 2002:a65:5c4b:: with SMTP id v11mr50222454pgr.62.1564170868883; Fri, 26 Jul 2019 12:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564170868; cv=none; d=google.com; s=arc-20160816; b=UHvMfQ60OxAItT2h+Qm5PNxUkMSRLfYsOjIyANUSAqL9Vuerjj+0eT+7RPQggeTn0r j5a3N617LiBWlo6+NAgjxdTWJtlHGeuKhkuDRLSZIDD9fHiAz9nZ06QQvaLlZQKBPfT4 xLPVUKqY26KYayIAltIXbIuOybXnL1u2LCITRMn6KJCH6zFkYjXyVMNBKv/xSEb+SRYc lFcDjHjjrGjRyxxyghMLJqas/3Cwi7JOIlpYVkssBpQP3DgjzrHrtZ4zShFall1b8BOC NxyRcObzj7pf+ycTQ2nQa8NBUZFsY4SzCKIEP1S+EOa1YbfjXbzF9sucvt/aKFP/2s7S yT6Q== 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:date:from:dkim-signature; bh=PZsF7ZJaphMWN9qRy4bD4vHayPMKRYnmzgQEknbb+i0=; b=0TslduDrpaF0+dLqEb9IV++dB5SFgDAF0TjwmeIaA2HiV7R8lVrQp9RpOiIZo4r2ea ufb+pRSAfYds7GIzf/Bn3GmbitRH8d8quNigTHS7OT+34dc+t0LoST06VK7Qm/iFeTZk 1hiD3EskMZR5MlBxD04blVTToTakfJDvnPQ1GvtLdNlb8oz+LRSqmdya9claSnClNWEE ghhEVxgOKtMfcF/BqjIY5FonZeXCpZM8BHEfI/st5MCSXy0kS2h3svoxEsOHeQmYEn44 w9fQCocadVIjEBz3A1xXZte8YdYRRyjGHm9zh6LDsKm+Zh33A7Sye3PlyBotL1yIR7L2 UxGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WJPUMagw; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a15si8759693pgk.523.2019.07.26.12.54.13; Fri, 26 Jul 2019 12:54:28 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WJPUMagw; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388367AbfGZTFp (ORCPT + 99 others); Fri, 26 Jul 2019 15:05:45 -0400 Received: from mail-qk1-f174.google.com ([209.85.222.174]:34183 "EHLO mail-qk1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388306AbfGZTFp (ORCPT ); Fri, 26 Jul 2019 15:05:45 -0400 Received: by mail-qk1-f174.google.com with SMTP id t8so39841476qkt.1 for ; Fri, 26 Jul 2019 12:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PZsF7ZJaphMWN9qRy4bD4vHayPMKRYnmzgQEknbb+i0=; b=WJPUMagw7mekaMPendP9T8PCqp3BQckjVCLd/rndL+nv6DRii3ypfgbKqyA/+Ft+Xy dpzkPuuqAfKJE15w8Osb6Lic9i9WqW2sRZGbLbwk3sHuewiKkYHtXjBtukBUf+EXxF1Q 6veZXcnwd/9NQ257Kg2/gCMTuXXYoQ6HlAHTrycpTwzv7BX9MtH6BZUI+4e3gAY/V+Nf SSCpge7pQhmNGsaqBt6jABGVgEy6VzTamIunWf7XpH1WTtRjkAFfCQMup8C7ZhzwQgd6 UbrHjeAX6qAfK1qveWIR+ZD7F8BpsQfA8BgRnb9B6x2d7H4rF+/iYZ5tLU6Zk7frCW+5 bMmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=PZsF7ZJaphMWN9qRy4bD4vHayPMKRYnmzgQEknbb+i0=; b=XJGG77p1XNjYxJhIUiD5NdCrXpQvd4Xw7/z1zXYUOilFjIuJHCtagCoZzz3WTsDelY G0rnPXjRydXpJEyX5b5IUm6evXZnbeCnsovGeZ9d3q+6h9+n86I0bDvxurt2o/085Bl+ 0s8W7c8yWSdX5J/MzGhQgKDV1TDXUT2D72xBIskDOg49ndr6GdvOJBtVAWHo4A9dTqoh x30i16OI0uG8iCji/8u6/0IbfR8A2CeYk4otxSBOBnjYf/oDMHPxwxnenYtA7OVe6O8i 1ILLhex7pPgXS3mhMAqhDs72l8VmIZRnuYcaDxnIpvpTPZmtCmcFQd4D7I7pc6a7n0an S24A== X-Gm-Message-State: APjAAAXGkLufVoG5MWWYNK0xGfJ9aK8kC9KEu0ip1Ip7CKeIdfsww48y 1qs7bCJNKaKo8GVjvw0bc0o= X-Received: by 2002:a05:620a:1006:: with SMTP id z6mr31170851qkj.312.1564167944308; Fri, 26 Jul 2019 12:05:44 -0700 (PDT) Received: from quaco.ghostprotocols.net ([179.97.35.50]) by smtp.gmail.com with ESMTPSA id i1sm23987910qtb.7.2019.07.26.12.05.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 26 Jul 2019 12:05:43 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 846FA40340; Fri, 26 Jul 2019 16:05:41 -0300 (-03) Date: Fri, 26 Jul 2019 16:05:41 -0300 To: Vince Weaver Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim Subject: Re: [patch] perf tool buffer overflow in perf_header__read_build_ids Message-ID: <20190726190541.GC20482@kernel.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Jul 23, 2019 at 04:42:30PM -0400, Vince Weaver escreveu: > Hello > > my perf_tool_fuzzer has found another issue, this one a buffer overflow > in perf_header__read_build_ids. The build id filename is read in with a > filename length read from the perf.data file, but this can be longer than > PATH_MAX which will smash the stack. > > This might not be the right fix, not sure if filename should be NUL > terminated or not. > > Signed-off-by: Vince Weaver > > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c > index c24db7f4909c..9a893a26e678 100644 > --- a/tools/perf/util/header.c > +++ b/tools/perf/util/header.c > @@ -2001,6 +2001,9 @@ static int perf_header__read_build_ids(struct perf_header *header, > perf_event_header__bswap(&bev.header); > > len = bev.header.size - sizeof(bev); > + > + if (len>PATH_MAX) len=PATH_MAX; > + Humm, I wonder if we shouldn't just declare the whole file invalid like you did with the previous patch? - Arnaldo > if (readn(input, filename, len) != len) > goto out; > /*