From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f176.google.com (mail-dy1-f176.google.com [74.125.82.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30BE0221540 for ; Mon, 8 Jun 2026 00:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780878290; cv=none; b=truIYikjt690urKjil+WAtl7VLqpTOe4xhVr+pWxZTJk1SlwyyvDzqWP2HdKQ0UIwxOsGDxZip4+J+fnPamaL30a/Q9q+NC3CRJSCDEFW//N7gll8Ll+/qd8rk+nEQc+joQCN6mGmIwoD7VObqUliwttw28mIWo0O5jvYAQ497k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780878290; c=relaxed/simple; bh=FciX88FPNr97H7Lac066zfnpTitncLfqzeyFdC2bPqI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rGzYrnOBLiaO/D+1jTbmSyFck95sjjqc7IBhW+mE/6AtwSS1nMpEWenqBJjTbm+J5Gjj1VUmThcG0jFU1jEhHJyZV4kz1Qsnx6LBZOLG2Srj/KXjA0LKMQ+bAhBhFFhRh4bSdh0ip50K+biRTIuFCMaxbjIm637TSlNV+sLkJR0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VvrELY86; arc=none smtp.client-ip=74.125.82.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VvrELY86" Received: by mail-dy1-f176.google.com with SMTP id 5a478bee46e88-30759632453so4946319eec.1 for ; Sun, 07 Jun 2026 17:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780878288; x=1781483088; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=Q9Il7KIXLbr6Qqp2KZE0DFyL3uNS8bQYdKstIr+QUQw=; b=VvrELY86UKXgUqj+S6Em5yBdqfC4C84b0XR1vfMyaV4R8xh1KyHJ4vhfqvXhxZiKcq OGVCcGVzseVwkxacyPt+zCHBMeehkRk/sWLvyoYBG/YIx8FbdYulmYBvuSII5KdeQRgk nVqhZodecuHieixbUzdflbL6MhdD3IjxjavoKzAqwjkKRBaN6tM9h87brvGUNmRKrMJO Rj/JgxjZFyI2NxQJmEP7Ipw6YVHzTn+ykIfQmqF0K5xVfaQpxyYnQWGBtth7dH/oG8qA pFBMk+u31TFsmvaYQ+M6cbVldnO877AJ1NDE7mea+6gWBKnYAH1tfCX3uDvpC31zzhjo 8w4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780878288; x=1781483088; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Q9Il7KIXLbr6Qqp2KZE0DFyL3uNS8bQYdKstIr+QUQw=; b=oDxi3oTzaAcuWyPqs1kynD3pLcAxXlBvvQG2Lvdy0REZlNSJsMAGLo/2sFgnGieRf9 Ffjz5Wb4uF7Q0MRpi/GQiAnOebB5G3fvm6v+pqR743uwBs56jP6CbefZt6r8eV4a9hme 2tOUHyLQHa+zM/nv6QaEEWUBBNUke5QZyTdAWIX/RRivU0E4gsRmE533wLgJPXV6INtg iX26ktciBzilYtS7Z9lHVuiX8/n2GGQPFFffsHtk6lNwRQ/Tv+EPyqDMzQB8dxnDt7Ze yBLFonMq8iesluyrgCKSmtxkEk7KRi+ieE0s3stZedpjpnhfp1j/wcDetiXMUUpXXDcU 9f2Q== X-Forwarded-Encrypted: i=1; AFNElJ8QaK3zrtNpB44CPFhGRg+hqRYyfGGfyURbs+KDbXwxAzTBKjV/Ee6e4pprPDZl6yMmneybLU4ozeWAb00=@vger.kernel.org X-Gm-Message-State: AOJu0YyEwdSuQebx5SUfOa6TOxbERuJEQS45FdRA7fcOb+t9pXU9ydS0 oLkkKB6USDYx0c8YhHS1Zl3oTBJLRnQgvFYZi1zF/aryehGrubomm3TDFEsGXj2e X-Gm-Gg: Acq92OEATM4lOfJqujGIOZni9PnFUWm64KFYylUZduvN8gsqQpwAkeNhDyfxph3Yhsr Qr5HGbY6kPUtvHM+UJUTHyGCW/Ok80KMhoSTntmjKjfvwGGk2uY2sVsSUXgPJVz/c6ajkcRRY4y UoKBT4H4OiEzG+4qsr3FRB+s7pMtNWAgm4GGHBPtRzXbbcnUHIXVuu5AXvagMPE8Pldz/F/uP1T 9yK4mabMgngVlsnPMJPjccZYzPH3DH/tvRAndrZV2MhuNXHFNL8NzQQ+twZZeELbmFYQDG8XQS3 3+e1vrhw40RIqYxj8x6pICEYTxWTAeloLGkDhp+4+cRoizdoD2PwKUUWzKA3kp+HX+zzFVdL9KO iCFpWBuSk/lxWfNPyRUYp2rBQHuPZoVRtU3ZWyF3qykb67rR+jLpAHLyR8JRmnwMUpeeLSZ1QRS 2MTSe1tHKyqvq6NSX6X4q4MXiPvfopsw4+tYZjdCMwqpFQVpY= X-Received: by 2002:a05:7301:1293:b0:304:188d:d0be with SMTP id 5a478bee46e88-3077b17f8d9mr7390764eec.16.1780878288259; Sun, 07 Jun 2026 17:24:48 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:da43:aeff:fecc:bfd5]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3074df8076csm16215925eec.29.2026.06.07.17.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2026 17:24:47 -0700 (PDT) Sender: Guenter Roeck Date: Sun, 7 Jun 2026 17:24:47 -0700 From: Guenter Roeck To: Nikita Zhandarovich Cc: Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: Re: [PATCH v2] hwmon: it87: Clamp negative values to zero in set_fan() Message-ID: <28e8c685-6fae-4db6-8db6-55352750e254@roeck-us.net> References: <20260529141839.1639287-1-n.zhandarovich@fintech.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260529141839.1639287-1-n.zhandarovich@fintech.ru> On Fri, May 29, 2026 at 05:18:36PM +0300, Nikita Zhandarovich wrote: > set_fan() parses user input with kstrtol() and passes the resulting > value to FAN16_TO_REG() on chips with 16-bit fan support. > > Negative fan speeds are not meaningful and should be rejected before > conversion. Worst scenario, one may be able to abuse undefined > behaviour of signed overflow to possibly induce rpm * 2 == 0 in > FAN16_TO_REG(), thus causing a division by zero. > > Instead, clamp val < 0 to zero and keep the conversion in its valid > input domain, avoiding unsafe arithmetic in the register conversion > path. > > Found by Linux Verification Center (linuxtesting.org) with static > analysis tool SVACE. > > Fixes: 17d648bf5786 ("it87: Add support for the IT8716F") > Signed-off-by: Nikita Zhandarovich Applied. Thanks, Guenter