Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2627537pxj; Mon, 31 May 2021 06:55:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHjgeX7FFr4DO0PWgO6zuv2sz4ZjwzVElBZidFXUqv8UB44PZxVLJfWffe2J8L5GfQks1z X-Received: by 2002:a92:2a09:: with SMTP id r9mr17946991ile.300.1622469314957; Mon, 31 May 2021 06:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622469314; cv=none; d=google.com; s=arc-20160816; b=gJDDONGnvmfllfR8mabXHar8cZnwYVK4L05zdDeuwwtT4L9KivL3zQCR2XZ/w1dQGJ eKn9dwhkLoGM2hxkWFMeVIBADva5buRDKJzRDLLOH8w3aXmPdZuRqOZDNs7TCjjtQ5B5 3C+p90kdM166S2xGw+N0jbhG+2bZdjtAY9Fd6p5ek830m0uHFPLmLoTkx1+N2ZlzkOkw 4AVuvEZvFfAPtDD6iQkPYIgctDAQL9w6CTkcti/yf8opK5JM+iJH7SLA2CqTcSV8c8Jk ws3vLuPS652IPw8unUZ1r0mxq3pQx6n6Zj6FhehUIxSN2GHcMSG98bDh5XkuRU7PiuFE rYXQ== 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=Ow8gE9/FKUdrWi82cMpapR2JEoai7Iwjb/pqvw3G+xY=; b=g4wiE5sFds3nFeSFWRtFJD4JWGZSndX9exSS4wNiUDDchx3euj4LUqpaiEz3LyI8W7 IEw7xYUIefquCe7EHyeDieT1PV+zqJnAUTFXFoMpMo6BeJqRneNhlp2KrL1gcBrTlzJ1 X1sG8ExXdGvGiVM1IGQ2QSTPdnsukLPmVpEfzqMG2yiMX+rPgERYhqAwHlILUOVC3bcY HZJc6A/Vaa/tR+D6eisHMrX8synmFJL5PBh6X4Ck8cacB6hivnFEgeyioO9cfDjOtaEK W51Y6tyEXzLjaP7R2Rb7cZsKQSnI9HY+R7NZnnYhPQqk24YquPzkHMP+tDVB20shL3q3 jREA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rIQR+c1J; 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 k2si16279942iow.30.2021.05.31.06.55.01; Mon, 31 May 2021 06:55:14 -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=rIQR+c1J; 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 S232145AbhEaNz1 (ORCPT + 99 others); Mon, 31 May 2021 09:55:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:43270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232438AbhEaNgd (ORCPT ); Mon, 31 May 2021 09:36:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 48F916144E; Mon, 31 May 2021 13:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467555; bh=wT0KiccDgL3YqGubO7STzSzHp7Ml/7GG+9c2IcX3nXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rIQR+c1J2HcxKoq4lJEUndn7xVZoW9m/iB/8ImPsNApMlpch9Sr0CCFckqGiZ8ztz HEj/55SR3VEvLmz0s/w15D5kBGquQDr2NmlPBL2oLJKqVFwe3uIKAYcqKy2SHTh3wa xUPSoObHPu3FCgQDqWdfQhDWcPHOUQ/NnuoeQjhA= 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 4.19 074/116] perf jevents: Fix getting maximum number of fds Date: Mon, 31 May 2021 15:14:10 +0200 Message-Id: <20210531130642.661939901@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130640.131924542@linuxfoundation.org> References: <20210531130640.131924542@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 @@ -858,7 +858,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; }