From patchwork Tue Sep 29 12:26:20 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rickey Castillo Valenzuela X-Patchwork-Id: 2313577 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hvXpZ3gp7z1y1S for ; Wed, 30 Sep 2026 08:26:45 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1xBgHT-0001Mo-2I; Tue, 29 Sep 2026 22:26:35 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1xBgHP-0001LU-9C for kernel-team@lists.ubuntu.com; Tue, 29 Sep 2026 22:26:31 +0000 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 203C43F2BB for ; Tue, 29 Sep 2026 22:26:31 +0000 (UTC) Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-815f2b1ecc3so590833a34.2 for ; Tue, 29 Sep 2026 15:26:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790720790; x=1791325590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=p+TI3sUzRnurpdVRpwsE3lsb2r1l8cyyuhqGTuLBatU=; b=XC7U/nSx+35zaceTe1W8BREVNG8q11YeDwF8vFatLoJxll3z+F9cV0bDAaeAFX53eI Tgx6W7+7Q5lpUNXvgTq5YzgCXln5m0dt7eUvzrLQd6gVRJcw+IlI6ex81hcCvhBlgyGD rSOPlgh/u2sBYAA5lcjj9JI5DS1VeLuv3vxpGFtnGRYrQgEq2LNGi4EeOl0dCuPD2GRD vsOPVJPHXrAbR57IKjy7QwkWsfCwCrMCSK7xwnki/XhfhKmeUL4PeD6xVyQTUt0fwVBM jN8kQX3y09tNwnb6G1UxQZThMo2HiR5F9aslUah/8I2C++xQfMhcCnf4VTimf0NGUz1x Th7w== X-Gm-Message-State: AFuF++kxfqBjWPFspUV+8hozehZWq6jtPixVvbcOIHXrolK6HZtHrVi5 RColsHgbYbqN205rdhng21+rBbepTvOAbRag6MQobbS+tlcnWW0OzfVaXNG6hggasUrn92MNfHr +8021v5LtzJKia6WXGjyj11sTXYdTI2aWO+RCGa4VbzwC3Re4Fhy0o3iX0OWAAZYP7U8KfPcwgM gkb5wbpohyqfhOxgGZ X-Gm-Gg: AYBFou3FS58R2AK0Rcw/8SjpN8AWnq4onHU2iB0v0OKpBgKGUC9juWK4mYLVY5OTgI/ 2K1OLHmEZ9n53kYLa2un+FpqZ7U+mxKKW9PlXtgwRwg0ucqkqLyzJCfc2g40JgvTsUIQUyv/dWK 5wvOCOsS08S5JXj2EmiYPgYMnWKI/bRL4poSrcgYVwB3/eEt8hxAVttgh7FTbP2/UAvKeA+oESD tuZG8xlbyRBf/ivEGfehRsI9VfLA5ZGd7OQ1BanehlhCHthKQZpOGr2l9J1nTwtl/4BY4I+AsTU tMOH3jNHpYBTlRcTyRHZEfYoy7yVQtwNFHyu/pTC4ekbieMu2/VLod1SKF5DPHZcPWF6QHQeeO+ UZjV26R/zkZYWAtY5qJxSXpKV X-Received: by 2002:a05:6830:61cb:b0:81b:8841:7dd8 with SMTP id 46e09a7af769-81fd71e50d6mr827229a34.29.1790720789713; Tue, 29 Sep 2026 15:26:29 -0700 (PDT) X-Received: by 2002:a05:6830:61cb:b0:81b:8841:7dd8 with SMTP id 46e09a7af769-81fd71e50d6mr827217a34.29.1790720789398; Tue, 29 Sep 2026 15:26:29 -0700 (PDT) Received: from localhost ([187.144.107.102]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-81faf30eafcsm1169263a34.14.2026.09.29.15.26.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2026 15:26:29 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 1/1] hwmon: (drivetemp) Fix driver producing garbage data when SCSI errors occur Date: Tue, 29 Sep 2026 16:26:20 -0600 Message-ID: <20260929222626.67642-2-rickey.castillo.valenzuela@canonical.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260929222626.67642-1-rickey.castillo.valenzuela@canonical.com> References: <20260929222626.67642-1-rickey.castillo.valenzuela@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Rickey Castillo via kernel-team From: Rickey Castillo Valenzuela Reply-To: Rickey Castillo Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Daniil Stas scsi_execute_cmd() function can return both negative (linux codes) and positive (scsi_cmnd result field) error codes. Currently the driver just passes error codes of scsi_execute_cmd() to hwmon core, which is incorrect because hwmon only checks for negative error codes. This leads to hwmon reporting uninitialized data to userspace in case of SCSI errors (for example if the disk drive was disconnected). This patch checks scsi_execute_cmd() output and returns -EIO if it's error code is positive. Fixes: 5b46903d8bf37 ("hwmon: Driver for disk and solid state drives with temperature sensors") Signed-off-by: Daniil Stas Cc: Guenter Roeck Cc: Chris Healy Cc: Linus Walleij Cc: Martin K. Petersen Cc: Bart Van Assche Cc: linux-kernel@vger.kernel.org Cc: linux-scsi@vger.kernel.org Cc: linux-ide@vger.kernel.org Cc: linux-hwmon@vger.kernel.org Link: https://lore.kernel.org/r/20250105213618.531691-1-daniil.stas@posteo.net [groeck: Avoid inline variable declaration for portability] Signed-off-by: Guenter Roeck (backported from commit 82163d63ae7a4c36142cd252388737205bb7e4b9) [rickey.castillo: fixed conflict in drivetemp.c due to upstream API migration. Kernel 5.15 still uses scsi_execute_req() and data_dir variables instead of the newer scsi_execute_cmd() and enum req_op.] CVE-2025-21656 Signed-off-by: Rickey Castillo --- drivers/hwmon/drivetemp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/drivetemp.c b/drivers/hwmon/drivetemp.c index 5bac2b0fc7bb..b4fea004b0b4 100644 --- a/drivers/hwmon/drivetemp.c +++ b/drivers/hwmon/drivetemp.c @@ -165,6 +165,7 @@ static int drivetemp_scsi_command(struct drivetemp_data *st, { u8 scsi_cmd[MAX_COMMAND_SIZE]; int data_dir; + int err; memset(scsi_cmd, 0, sizeof(scsi_cmd)); scsi_cmd[0] = ATA_16; @@ -192,9 +193,12 @@ static int drivetemp_scsi_command(struct drivetemp_data *st, scsi_cmd[12] = lba_high; scsi_cmd[14] = ata_command; - return scsi_execute_req(st->sdev, scsi_cmd, data_dir, + err = scsi_execute_req(st->sdev, scsi_cmd, data_dir, st->smartdata, ATA_SECT_SIZE, NULL, HZ, 5, NULL); + if (err > 0) + err = -EIO; + return err; } static int drivetemp_ata_command(struct drivetemp_data *st, u8 feature,