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 intoSep 8, 2026
Conversation
ixhamza
requested changes
Sep 4, 2026
ixhamza
left a comment
Member
There was a problem hiding this comment.
Would be good to compact the commit messages and squash into one commit as well.
eschultz
force-pushed
the
fix/drivetemp-scsi-log-sense-bugs
branch
from
September 4, 2026 22:28
45d5766 to
98d48fb
Compare
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. |
…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
force-pushed
the
fix/drivetemp-scsi-log-sense-bugs
branch
from
September 5, 2026 20:56
98d48fb to
c7ed4ce
Compare
ixhamza
approved these changes
Sep 6, 2026
amotin
approved these changes
Sep 8, 2026
|
This PR has been merged and conversations have been locked. |
Member
|
backport |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: https://ixsystems.atlassian.net/browse/NAS-142826
Split out of #347 at review request. One commit,
drivers/hwmon/drivetemp.conly, no ABI change and no behaviour change on a drive whose LOG SENSE succeeds. Thetemp1_crittotemp1_maxretier 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 positivescmd->resulton CHECK CONDITION.hwmon_attr_show()only rejects negative returns, so an uninitialised stacklongreaches userspace as the temperature. Normalise to-EIO, asdrivetemp_scsi_command()already does since upstream 82163d6 (which we also carry on 6.12 as 42268d8).param_lenis au8holdingbuf[i + 3] + 4. A length byte of0xFCwraps it to 0 and the loop never advances, hanging the sysfs read withst->lockheld. Useunsigned int.i + param_len <= page_lenbut reads the temperature atbuf[i + 5], which a parameter shorter than six bytes does not cover. Skip such parameters.Base
truenas/linux-6.18@ 580caa3. Applies totruenas/linux-6.12unchanged withFixes: 43ff910ef5cc.Verification:
drivetemp.ocross-compiles clean for x86_64 includingW=1(x86_64_defconfig+CONFIG_TRUENAS=y+CONFIG_SENSORS_DRIVETEMP=m).checkpatch.pl --strictreports no errors or warnings. Not run on hardware; nothing here alters the success path.