Skip to content

NAS-142826 / 27.0.0-BETA.1 / drivetemp: fix error handling and parsing in the SCSI LOG SENSE path - #348

Merged
creatorcary merged 1 commit into
truenas:truenas/linux-6.18from
eschultz:fix/drivetemp-scsi-log-sense-bugs
Sep 8, 2026
Merged

NAS-142826 / 27.0.0-BETA.1 / drivetemp: fix error handling and parsing in the SCSI LOG SENSE path#348
creatorcary merged 1 commit into
truenas:truenas/linux-6.18from
eschultz:fix/drivetemp-scsi-log-sense-bugs

Conversation

@eschultz

@eschultz eschultz commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Jira: https://ixsystems.atlassian.net/browse/NAS-142826

Split out of #347 at review request. One commit, drivers/hwmon/drivetemp.c only, no ABI change and no behaviour change on a drive whose LOG SENSE succeeds. The temp1_crit to temp1_max retier and the subpage 02h read stay on #347.

All in drivetemp_retrieve_temp_log(), the SCSI log-page path added in 06ff843:

  • scsi_execute_cmd() returns the positive scmd->result on CHECK CONDITION. hwmon_attr_show() only rejects negative returns, so an uninitialised stack long reaches userspace as the temperature. Normalise to -EIO, as drivetemp_scsi_command() already does since upstream 82163d6 (which we also carry on 6.12 as 42268d8).
  • param_len is a u8 holding buf[i + 3] + 4. A length byte of 0xFC wraps it to 0 and the loop never advances, hanging the sysfs read with st->lock held. Use unsigned int.
  • The loop checks i + param_len <= page_len but reads the temperature at buf[i + 5], which a parameter shorter than six bytes does not cover. Skip such parameters.

Base truenas/linux-6.18 @ 580caa3. Applies to truenas/linux-6.12 unchanged with Fixes: 43ff910ef5cc.

Verification: drivetemp.o cross-compiles clean for x86_64 including W=1 (x86_64_defconfig + CONFIG_TRUENAS=y + CONFIG_SENSORS_DRIVETEMP=m). checkpatch.pl --strict reports no errors or warnings. Not run on hardware; nothing here alters the success path.

@ixhamza ixhamza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to compact the commit messages and squash into one commit as well.

Comment thread drivers/hwmon/drivetemp.c Outdated
Comment thread drivers/hwmon/drivetemp.c
Comment thread drivers/hwmon/drivetemp.c Outdated
@eschultz
eschultz force-pushed the fix/drivetemp-scsi-log-sense-bugs branch from 45d5766 to 98d48fb Compare September 4, 2026 22:28
@eschultz

eschultz commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Squashed to one commit with a compact message, on the same 580caa3 you reviewed. Picked up all three inline points; the param_len wrap is a real hang and is called out in the message. Compiles clean at W=1, checkpatch --strict clean.

@eschultz
eschultz requested a review from ixhamza September 4, 2026 23:33
…SE path

drivetemp_retrieve_temp_log() has several problems:

 - scsi_execute_cmd() returns the positive scmd->result on CHECK
   CONDITION. hwmon_attr_show() only rejects negative returns, so an
   uninitialised stack long reaches userspace as the temperature.
   Normalise to -EIO, as drivetemp_scsi_command() already does since
   commit 82163d6 ("hwmon: (drivetemp) Fix driver producing
   garbage data when SCSI errors occur").

 - param_len is a u8 holding buf[i + 3] + 4. A length byte of 0xFC wraps
   it to 0 and the loop never advances, hanging the sysfs read with
   st->lock held. Use unsigned int.

 - The loop checks i + param_len <= page_len but reads the temperature
   at buf[i + 5], which a parameter shorter than six bytes does not
   cover. Skip such parameters.

No functional change for well-behaved drives.

Fixes: 06ff843 ("hwmon: (drivetemp) Add SCSI drives support")
Signed-off-by: Eric Schultz <eric@startuperic.com>
@eschultz
eschultz force-pushed the fix/drivetemp-scsi-log-sense-bugs branch from 98d48fb to c7ed4ce Compare September 5, 2026 20:56
@ixhamza
ixhamza requested a review from amotin September 6, 2026 13:48
@creatorcary
creatorcary merged commit abbc98f into truenas:truenas/linux-6.18 Sep 8, 2026
4 checks passed
@bugclerk

bugclerk commented Sep 8, 2026

Copy link
Copy Markdown

This PR has been merged and conversations have been locked.
If you would like to discuss more about this issue please use our forums or raise a Jira ticket.

@truenas truenas locked as resolved and limited conversation to collaborators Sep 8, 2026
@ixhamza ixhamza changed the title NAS-142826 / 27.0.0-BETA.1 / drivetemp: fix on-stack DMA and positive SCSI status leak in LOG SENSE path NAS-142826 / 27.0.0-BETA.1 / drivetemp: fix error handling and parsing in the SCSI LOG SENSE path Sep 8, 2026
@ixhamza

ixhamza commented Sep 8, 2026

Copy link
Copy Markdown
Member

backport

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants