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

"smartctl --json" occasionally produces invalid json, caused by text 'Pending defect count'.

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • rhel-8.10.z, CentOS Stream 8, CentOS Stream 9, rhel-9.9.z
    • smartmontools
    • None
    • None
    • Low
    • Patch, EasyFix
    • Customer Reported
    • rhel-base-utils-core
    • None
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • All
    • None

      What were you trying to do that didn't work?

      Text 'Pending defect count:{' breaks json output HERE.

      # smartctl -x /dev/sdx --json | head
      Pending defect count:{                  <--- HERE
      "json_format_version": [
          1,
          0
        ],
        "smartctl": {
          "version": [
            7,
            1
          ],
      ...
      

      What is the impact of this issue to you?

      `smartmontools` not producing valid json. Breaks other tools expecting json output.

      Please provide the package NVR for which the bug is seen:

      How reproducible is this bug?

      Sometimes (for specific disks).

      Steps to reproduce

       #  Run 'smartctl -x /dev/sdx --json' on affected device.
      

      Expected results

      # smartctl -x /dev/sdx --json | head
      "json_format_version": [
          1,
          0
        ],
        "smartctl": {
          "version": [
            7,
            1
          ],
      ...
      

      Actual results

      # smartctl -x /dev/sdx --json | head
      Pending defect count:{                  <--- HERE
      "json_format_version": [
          1,
          0
        ],
        "smartctl": {
          "version": [
            7,
            1
          ],
      ...
      

      Additional notes.

      This was patched in upstream; see commit https://github.com/smartmontools/smartmontools/commit/5689dea0d77713c984188db9cf6b8377081b880f

      This bug is present in rhel8, rhel9, HERE;

      *rhel8*

      ⬢ [dareynol@toolbx smartmontools]$ vi smartmontools-7.1-build/smartmontools-7.1/scsiprint.cpp
              switch (pc) {
              case 0x0:
                  printf("  Pending defect count:");   <--- HERE
                  if ((pl < 8) || (num < 8)) {
                      print_on();
                      pout("%s truncated descriptor\n", pDefStr);
                      print_off();
                      return;
                  }
      
      • Using printf() not jout().

      *rhel9*

      ⬢ [dareynol@toolbx smartmontools]$ vim smartmontools-7.2-build/smartmontools-7.2/scsiprint.cpp
              switch (pc) {
              case 0x0:
                  printf("  Pending defect count:");   <--- HERE
                  if ((pl < 8) || (num < 8)) {
                      print_on();
                      pout("%s truncated descriptor\n", pDefStr);
                      print_off();
                      return;
                  }
      
      • Using printf() not jout() HERE.

      Upstream commit already in rhel10, FIX_HERE.

      *rhel10*

      ⬢ [dareynol@toolbx smartmontools]$ vi smartmontools-7.4-build/smartmontools-7.4/scsiprint.cpp
              switch (pc) {
              case 0x0:
                  jout("  Pending defect count:");   <--- FIX_HERE
                  if ((pl < 8) || (num < 8)) {
                      print_on();
                      pout("%s truncated descriptor\n", pDefStr);
                      print_off();
                      return;
                  }
      

              mhlavink Michal Hlavinka
              rhn-support-dareynol Daniel Reynolds
              Michal Hlavinka Michal Hlavinka
              RHEL SST CS base utils QE Bot RHEL SST CS base utils QE Bot
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: