Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2641106pxj; Mon, 31 May 2021 07:11:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3xQQ1md9zw0HpxAGvcqclussla17REubgBEQHZZW4zNLfHfAXZeSg6qLN6lBbcrm6YeKo X-Received: by 2002:a02:354c:: with SMTP id y12mr20728057jae.144.1622470318162; Mon, 31 May 2021 07:11:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622470318; cv=none; d=google.com; s=arc-20160816; b=rnH/LJSRsxQPwp/d0WQSxFTIR4cNEkd8AzX0tvgymXrUOBDJFQaiyS48QdlCef9DQ1 QGbAdzAbKnKRvjI6ehWoBXgVhdWxWZewqKv9xnXiIb4z42GvX3sgnO+Mmjpp5pIVxE21 n/tPqqLO20XzVJ31R7cFM/a2VwWrmSoXYKU/h71M+L8D/uRsmtYdf7jSxozJUpija4fC srS4e9cYBjYNPiEa6zrM6ZLYRiI4ouMRH+wncoDNbG4b6wMKOQ2sRhAYU/8qFIHzKEJk dhqHDZaL/jNjI74MuwwMKIwKpClCJOXAOI5GYpW6Ha9DiXDGeFfz8f2XHVgXkmloJSKp lVUA== 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=fcXSepullL23qVroz1g/YPvIQOE2oh1r5KLerY2E0lU=; b=OAoUEd/iZdq35NvqyV+l678Mim9rQ+DNEZ39UQ8hBZtwvNKkstH8ITQMZtujr8g2CQ 8L1g4g/CNUleRYV7wfXKws3VkFNkzR7HnpwTo+fFQ5nsl0DVg9Xk8nJp32627o8J4rJL pmgZPqya0YWf298hs9ClpWBSyVhoYqxBMt3aZV3+ash2hEmGSS5bVBMY4nyZitSttg+s Y7malmaUtdrlMIncCuv8Is8wy9WXjaAo8TBG1vryKWmILoEV5e3TmPdmMoOjw53WngXE yM3RuxSZOFwKsjwlz5NisW1y+7ITspzCkYGEds83Afm26neLJAiz/ROhgXJyMzQoRDjh /97g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ByU3bgjj; 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 m14si13942550ili.85.2021.05.31.07.11.42; Mon, 31 May 2021 07:11:58 -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=ByU3bgjj; 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 S233042AbhEaOMX (ORCPT + 99 others); Mon, 31 May 2021 10:12:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:49808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232045AbhEaNpT (ORCPT ); Mon, 31 May 2021 09:45:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 995C661419; Mon, 31 May 2021 13:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467787; bh=rjfLzi4GdaoCptzth+N35afL7ymT6jOwOEUoIP75kD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ByU3bgjjA/jY+PmfxueHYLE2fYOmn2e2RRV/Zsl59f7Ny8anLtdppEBMn4KTm5RDC ZYzdLjYSYX3jOC5oRhjjeg0zVvwfNrZ6TLANPeklyzpkvfm1jXrcizUx+stbUQj4u9 23ZNXi3pkncsddAiMrj8sLa9ijElT0aL3hvW16mA= 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.14 44/79] perf jevents: Fix getting maximum number of fds Date: Mon, 31 May 2021 15:14:29 +0200 Message-Id: <20210531130637.423794948@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130636.002722319@linuxfoundation.org> References: <20210531130636.002722319@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 @@ -695,7 +695,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; }