Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-20814

l_getsepol: errlog() clobbers errno with ENOTTY

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • None
    • 3
    • 9223372036854775807

      In lustre/utils/l_getsepol.c, every error path calls errlog() and then does rc = -errno.
      But errlog() calls isatty(STDIN_FILENO). When the kernel runs l_getsepol through
      call_usermodehelper(), stdin is not a tty. So isatty() returns 0 and sets errno to
      ENOTTY, and the real error is lost. Every failure is then reported as -ENOTTY (-25).
        
      openlog(), vsyslog() and closelog() can also change errno.
       
      Fix: save errno at the start of errlog() and restore it before returning.
       
      Also in errlog(): the same va_list is passed to vsyslog() and then to vfprintf(). Reusing
      a va_list after it has been consumed is undefined behavior. Use va_copy() for the second
      call. This only matters when l_getsepol is run by hand from a terminal.

      Found while debugging LU-20119.

            hnishida Hiroshi Nishida
            hnishida Hiroshi Nishida
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: