Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2661361pxj; Mon, 31 May 2021 07:40:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/itUVzgUz10yQdLRoTZgnr9g6/fedmlW2IfwcFZukuU5vOYRmRhEhnXe6JmsIV5BO+dbM X-Received: by 2002:a17:907:3e96:: with SMTP id hs22mr21944499ejc.313.1622472021692; Mon, 31 May 2021 07:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472021; cv=none; d=google.com; s=arc-20160816; b=SyRMGnjiAy0DUEgZSRBI850JcgRqoriUmmPu1Aa1OiaA9m7Rx7GVVX/rYc+fVKvpdw ZynzOwtXFeeXqDEm/+Ayt227MjoVpt76do1ijyVnUnQWceaQJm4Eyjpe/wyoJB0kX8/8 SzjMWzlCoZUWM+KyFZh9YyP9JmRg0MCpdTGlXU9yapntOVbs93jsscLJRltSOO3x2Wo8 cpTpydO0kKzb4ab+x1tqIC4WXiBUm3OgFnns/00s9GGClDKlhSU08Jr+X65xt4DKH/yl w8RUC0qdMU5DEpcKBassSWLFd4EuEioLQ5XCR+9xqB/3Xx7ix4NGH8UeCBxMSTpxKiMi AWdw== 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=r6m10XOga8oj8FQrk9rbG8rMqGglNIMaRtR9smpwaLc=; b=0dnDPEV9roGJ6zir/Kt+n17HZJR3jdgkatv/3owNutVxyyZoLjvZPST9lCqa/pghia QS+SuKJhY26wSerjrMXbBEsMr1eIVVqYnQdTOpAf0NhHe2332ZImz3Tf2Qn5hn0sf3oC eHI8lahfGvjcsY6ZdZNBvy3Tg+juwaXS2L6Asu/5tNxiTCYbiBbjI0n15g7fXOKIsTr1 AQ8tSWWG6Ixz6l+DxUExPohuSRHDyEO44K+CuEvk5FzsBoSdERDyLvzHGnEpwbbfX/I7 4Va10VaxsohYOjBCapc68vIvJSWLktxGm9ecF0OyHr+0cEVu89f87FeiUuKGqVu+eqjf 1tlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vqa5vVYE; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga2si13018716ejb.249.2021.05.31.07.39.58; Mon, 31 May 2021 07:40:21 -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=@linuxfoundation.org header.s=korg header.b=vqa5vVYE; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231985AbhEaOkp (ORCPT + 99 others); Mon, 31 May 2021 10:40:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:60396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232876AbhEaN5x (ORCPT ); Mon, 31 May 2021 09:57:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B90C161931; Mon, 31 May 2021 13:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468121; bh=I+ov7eC9ynns4Nlwi+HAhlLqeUzVweIKirRbx7tHue0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vqa5vVYE6aE/vrT0xbzchXj3eIKUcnwoFoeEQoGUYbwAEWPw3zks5b3aConXF7qIo YScJdDN+3PPojuuR2gMJqLlnpslgsZQP4HPspgoMsNijf+I0MY/2kEkOXhExU2LXE/ pjHRGBTNB5JDitrNSSLeeeUmYkaxEpW7UX/yhYEE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felix Fietkau , Alexander Shishkin , Andi Kleen , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Sukadev Bhattiprolu , Arnaldo Carvalho de Melo Subject: [PATCH 5.10 125/252] perf jevents: Fix getting maximum number of fds Date: Mon, 31 May 2021 15:13:10 +0200 Message-Id: <20210531130702.254918785@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Felix Fietkau commit 75ea44e356b5de8c817f821c9dd68ae329e82add upstream. On some hosts, rlim.rlim_max can be returned as RLIM_INFINITY. By casting it to int, it is interpreted as -1, which will cause get_maxfds to return 0, causing "Invalid argument" errors in nftw() calls. Fix this by casting the second argument of min() to rlim_t instead. Fixes: 80eeb67fe577 ("perf jevents: Program to convert JSON file") Signed-off-by: Felix Fietkau Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Sukadev Bhattiprolu Link: http://lore.kernel.org/lkml/20210525160758.97829-1-nbd@nbd.name Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/pmu-events/jevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -894,7 +894,7 @@ static int get_maxfds(void) struct rlimit rlim; if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) - return min((int)rlim.rlim_max / 2, 512); + return min(rlim.rlim_max / 2, (rlim_t)512); return 512; }