Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2738066pxj; Mon, 31 May 2021 09:29:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn8llAS+gvgRc5kdby+yiYoFfK+Lh/8cGCUNcdA+Mrcweo6iK299Rt1irwSyKfGwNuIlTL X-Received: by 2002:a5d:9842:: with SMTP id p2mr17665095ios.132.1622478581156; Mon, 31 May 2021 09:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622478581; cv=none; d=google.com; s=arc-20160816; b=AFnmV+BGvtuU6eJDOUo2rbOYkywhQ7Glwu9ckiLxxg79WHK5r6h+LJ+NQQnHt/EdO8 nxY2wAesb2F1OX1riSMINVefFgLG0SGJETdlHl/mA+ZRry1Km+hf08xYozENCiD5aQC5 kmbuHLzL6m9x0ss4N8SMIK/PtBCOsXJFognrvfqLG7bO5Yb0MbQvL9fhjb30m9knuObm spPqhdYdxjh6L5qswukFQX/AHowKCSmeeprs4wVFxgop7/isNYLruqEGFY3xlKmsolRw W/nW3UUNibOiQfnOjgEqZC3l3bz9Y1jBO6bDSenMVEMlN22Au3mjmWEYpwSzifVvk3Ro ancw== 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=N6xS8/BvqTsNFacOXZJcaXrBEgqdQrp9n4EKI/G8/qs=; b=qxGcf/J4zkMn9+nVhLRsBaLLSQDVsFEPm+Lu3D9w7MfOVJW95LD9pvJNpLisdlt+eD w0VF4WJPhFJZkUCzLcsBDZr7mS9xLarfCSOc/+/tVSl4SvVKInMjE7sMcY2O45yyyScE cUDOs0xTYV4yObHT9cWee0gPD+CEJDpZM4dhm7Sr4dFi2F6YM99lC2QbSQtLBqtqvFIb Nz32/ae35l3w2K6wJIhHfa1vJ0fpZJVGaJk2LmxsJaI/P0KzwNMzLO2lO1PF0rDoi12e E015Aktvhp8uQQmasoyvqjdp2YfBqaocTHis6NdVLiV1HCsyaY7e2lhEwKxr2PiWWOQl OWPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WT+0Y5iH; 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 k25si15187660jap.38.2021.05.31.09.29.24; Mon, 31 May 2021 09:29:41 -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=WT+0Y5iH; 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 S234706AbhEaQaI (ORCPT + 99 others); Mon, 31 May 2021 12:30:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:39882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232057AbhEaOpj (ORCPT ); Mon, 31 May 2021 10:45:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 31E2061C7C; Mon, 31 May 2021 13:55:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469325; bh=I5a+M1mq2tbIyq1O9E0WWCz4d2J/neNykuabz8sEmh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WT+0Y5iHZLWx1NzRd+AFGoaZbN45Z6kyKSgmR+I6WF4LBreDysVBytwxC57+t4OKu 9je27jvalKchi7we0g4qW2MqJDHRKLQKPF9l2fPIvgf3Vo6+Bh0BGp0FnaNVwbFABz IwWV8qhOJqnbiE7pdY0A2IvNUnzdtBxQMOkypdxM= 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.12 155/296] perf jevents: Fix getting maximum number of fds Date: Mon, 31 May 2021 15:13:30 +0200 Message-Id: <20210531130709.076907449@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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 @@ -958,7 +958,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; }