Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2702822pxj; Mon, 31 May 2021 08:37:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9mSFDZ6Vr2YIR6RHIAMhHeJqh+yKsol8K3ORc/HWTLmY2HU2liXTCTP2ZvW1+8Tsrb/ya X-Received: by 2002:a02:7348:: with SMTP id a8mr21082477jae.116.1622475451622; Mon, 31 May 2021 08:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622475451; cv=none; d=google.com; s=arc-20160816; b=kPyjjDNUSpEIEhj5uUs9WZd+kJXsowvib376ca3HXGFYm8Uy8d2/JsGoUck66QwTPl 7YLZvW/jAgzqWidBKD1aZZKpHkgYl2WGF53CVHvi2V4FJynPKleruVzP0J9TV4kU/ZHq BLRMU7q+vJXL80IbMcr4PhBTq8ApWvA9H6u5Rwtx9PpfMSbAI7G3bMrurSuIkbdNX9Ym PrEGugvzZx6Hg10U8c2mO9W165PTwT35axCISHi5Hg8WYJX0mn3zsUI6mjRUO8QpQFap LFRNrt9NoMmJh6B8kr03JhlDsK/8Hqz/LANa+dqzSiCo0ronJXp73QdSmka7MTQ2Tf4Y Czqw== 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=wBSRdiGwk6YAYuOtF8V2DRBfOxlNnDtQki/mRq/W684=; b=zFIrtm3EwViwWVcQg193AKMWO1LSqYe4QzqC5uRuWd9ymxh5R8QaHB1J4tHzpFwOWY pywzv3eZ8ldi1pQv4eUknJCXEgWJ/R87U71hd+DrveZJMbLUgJALSswocr+cNKntjtjj kzbPKs/Ea7eqF2d6sQzGp7T9mEUcuhKJsg9LWRQEYxBLlj7MwjPLi0ygdpcCMwJSSWOx nTrWCyfbB6POOFudugkzD9s284uCHL21FWiDsDPaZqB1waTnNPd2y1kTE4Qzqbtl3CJU ylq3ldo0m9ePwkkQU7RCkTmP45WeT51ZQ6IUsc9ELrdAEwr6G8Apv0O0LtQDTdchc18j cM+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EsSPhuVS; 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 m125si8818118iof.57.2021.05.31.08.36.57; Mon, 31 May 2021 08:37:31 -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=EsSPhuVS; 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 S233879AbhEaPgu (ORCPT + 99 others); Mon, 31 May 2021 11:36:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:48840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233853AbhEaOVb (ORCPT ); Mon, 31 May 2021 10:21:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F196E61574; Mon, 31 May 2021 13:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468698; bh=abyuK/7cMoBIHEFpK1YB4Eo1c7OwGPxpWxUKdGzQR+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EsSPhuVSfVHOyS9ImKyD6Cesy/yuDzdviJSLS5yWfCU2S16w3RJJ6pdh3TstExU/X rHr1+SeGjyDT16jKE5yaGW+PkOM73oCpeJr8hlFZy/gnKLsn6Qjf1L9BJrtwgyakYf 5yRs5D/3zK68TVOqRuBErjYpJ9TdS0OvoaxOUPwk= 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.4 085/177] perf jevents: Fix getting maximum number of fds Date: Mon, 31 May 2021 15:14:02 +0200 Message-Id: <20210531130650.838648032@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@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 @@ -862,7 +862,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; }