Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-53951

lsof hangs when nofile is unlimited

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Normal Normal
    • None
    • CentOS Stream 9, rhel-9.4
    • lsof
    • No
    • Moderate
    • rhel-plumbers
    • ssg_core_services
    • 3
    • None
    • None
    • None
    • None
    • All
    • None

      Description

      When the nofile limit is set to unlimited, its actual value defaults to 1073741816. The lsof codebase contains the following segment in the main function:

      #if defined(HAS_CLOSEFROM)
      (void) closefrom(3);
      #else  /* !defined(HAS_CLOSEFROM) */
      for (i = 3; i < MaxFd; i++)
          (void) close;
      #endif  /* !defined(HAS_CLOSEFROM) */

      In environments where {{HAS_CLOSEFROM is not defined (which is the case in linux by default), this results in a loop that attempts to close file descriptors starting from 3 up to MaxFd, which is approximately 1.07 billion in this scenario. This causes the execution of lsof to generate billions of syscall operations, leading to significant performance degradation or the process hanging indefinitely. This issue calls for a review of the fallback mechanism used when closefrom is not available to handle such large values efficiently.}}

      Please provide the package NVR for which bug is seen:

      4.94.0-3.el9

      How reproducible:

      Steps to reproduce

      1. change nofile limit to unlimited in /etc/security/limits.conf
      2. run lsof -i :4444

      Expected results

      Results should appear very quickly.

      Actual results

      lsof hangs.

              jrybar@redhat.com Jan Rybar
              leavelet@163.com Yuanhang Sun (Inactive)
              Jan Rybar Jan Rybar
              RHEL CS Plumbers QE Bot RHEL CS Plumbers QE Bot
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: