From patchwork Thu Oct 10 19:11:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bethany Jamison X-Patchwork-Id: 1995717 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 4XPfVt029bz1xvW for ; Fri, 11 Oct 2024 06:11:17 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1syyZ3-0004NW-25; Thu, 10 Oct 2024 19:11:09 +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 1syyZ2-0004NJ-2s for kernel-team@lists.ubuntu.com; Thu, 10 Oct 2024 19:11:08 +0000 Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.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 C0CC93F1F4 for ; Thu, 10 Oct 2024 19:11:07 +0000 (UTC) Received: by mail-io1-f71.google.com with SMTP id ca18e2360f4ac-8353bd6481fso18038639f.1 for ; Thu, 10 Oct 2024 12:11:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728587466; x=1729192266; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kvbWCAV/Dj+kq3DGmbMO9BGDidS+VqbB6oYcQrsYB5Q=; b=mocuTzTEDuvrCn5rU2Q26HsYChVVJ0tNZFg9vajvLjTSBURVZuKFHw/2TRGyTieOz5 4t2e6dF2nmhU2U9eqwgah9kSl2zFBzcs2LbGjN8lYVBNJHOI5Inem1V7MfqdYBNlraZt BXJg+nqW3jGXuYV1QreRkzYYzcS6qz2+TIaU8b/lHBdeqdbUkLp5hwuWI3ydC9xYklm3 v9YinN1IFaGG3P1pYAPsTRqWQCLo5SeSMg7DriqZMUjWbe2uYLpHDKOZZmNiIHTep0xC KHHo/U0Y/jf6VDwX4OhPuc+nTLeF4QCS0FNJ7xhUVM9is0BWHq0mAAVz4DRnHZ4FZVOp f6+Q== X-Gm-Message-State: AOJu0Ywx1LBRHsWW5odFFS4c47XoqaDAELfGySnWJ4dR4Ycy4EBTZBpg 4qhAgcEjW/vwsds0efBDesgDUnLSfvTsWOe8zCAMWo+MNt7ZwWLu+0wVjT7ywgcng2JL71G03M/ Eyof+2CBLfJ/OTlF+wjo36J7I30ld4AS5Xbj41mQ71ndGIAnjycjc9kSX3M9JUTG9EJ3nlWaGI+ Ai8B4JPJz+lw== X-Received: by 2002:a6b:7b06:0:b0:81f:7f2d:8391 with SMTP id ca18e2360f4ac-8353d50947fmr211624339f.3.1728587466497; Thu, 10 Oct 2024 12:11:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6T+AGddpPF2Mz2BZbP4U/h8jzzhgbWH1+RcDLYGkwdSk5/X1IZHXUJQ0VYid3ZnN/H7zw+g== X-Received: by 2002:a6b:7b06:0:b0:81f:7f2d:8391 with SMTP id ca18e2360f4ac-8353d50947fmr211623439f.3.1728587466053; Thu, 10 Oct 2024 12:11:06 -0700 (PDT) Received: from smtp.gmail.com (167-248-51-36.oa02.lnk04.ne.dynamic.allophone.net. [167.248.51.36]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-8354b8df7e7sm36167839f.4.2024.10.10.12.11.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 12:11:05 -0700 (PDT) From: Bethany Jamison To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH 1/1] hwmon: (w83627ehf) Fix underflows seen when writing limit attributes Date: Thu, 10 Oct 2024 14:11:04 -0500 Message-Id: <20241010191104.30531-2-bethany.jamison@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010191104.30531-1-bethany.jamison@canonical.com> References: <20241010191104.30531-1-bethany.jamison@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: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Guenter Roeck [ Upstream commit 5c1de37969b7bc0abcb20b86e91e70caebbd4f89 ] DIV_ROUND_CLOSEST() after kstrtol() results in an underflow if a large negative number such as -9223372036854775808 is provided by the user. Fix it by reordering clamp_val() and DIV_ROUND_CLOSEST() operations. Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin (cherry picked from commit 26825b62bd1bd3e53b4f44e0745cb516d5186343 linux-6.10.y) CVE-2024-46756 Signed-off-by: Bethany Jamison --- drivers/hwmon/w83627ehf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index fe960c0a624f7..7d7d70afde655 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -895,7 +895,7 @@ store_target_temp(struct device *dev, struct device_attribute *attr, if (err < 0) return err; - val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 0, 127); + val = DIV_ROUND_CLOSEST(clamp_val(val, 0, 127000), 1000); mutex_lock(&data->update_lock); data->target_temp[nr] = val; @@ -920,7 +920,7 @@ store_tolerance(struct device *dev, struct device_attribute *attr, return err; /* Limit the temp to 0C - 15C */ - val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 0, 15); + val = DIV_ROUND_CLOSEST(clamp_val(val, 0, 15000), 1000); mutex_lock(&data->update_lock); reg = w83627ehf_read_value(data, W83627EHF_REG_TOLERANCE[nr]);