Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1276909pxb; Thu, 15 Apr 2021 19:52:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB3lWueUF+moAT5DKTpye6OhQwqF33R3oKhz+yZJmN9fniyTNMQZB57ef3RmBj4ObTXNGT X-Received: by 2002:a17:90a:a613:: with SMTP id c19mr7321449pjq.117.1618541557437; Thu, 15 Apr 2021 19:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618541557; cv=none; d=google.com; s=arc-20160816; b=iVLEAJzjrdPsvhEUX9m9GrBNr8u2SXcBNCX8IIwdqhi8aRZ/zrxp9Zrhdgis9uY72I Mv7p0O9mHMoY89tWFoaQtBEu0rNgLIGtXzOoq2VYDtQ14vxiw44VdjCG3tp8YOfVhscP 82+FS0NHDSeXverrKzQJHRvw03vj5UaAJTsx8sV2Wt1+Jjlhh+WFQri39Hdy3SVzN/SO xZkxWme1AZHCF3ElnJJWrEADlTF4TyKWUAKe2UgGSNHzcyin44cp24u9Lo5KWBeLb6HM b2+tcv3OmlemALbXdn3d29D6Efw6sQ4ylVwECTY8citXOWThbeBekOBwqmaeHDNh+u5l 93uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=4aOl9WYg3lZW03MpbHK6GQG1irPulDKlcMdmsoDYUyM=; b=ajFLuIOCki+6Cf4RgkUh74ySP26wxrflrcmQENeDuNqsn2Qp17g/0r8QjKzMKyZx0s D9VuscEtj+FKxE+yi2FOPKuGLWlM1olKhsOxiDnZQeKFDHY6qnvh2tyOK+OD2NyYyX41 s7bCPxLn2nrQcTizQj4XppMYn5jzTM/SzOgaOWi20RRaU93OXIIsjz5ALSXEqef4df4m DmVklhF+UL2gwFu5uGBCgPc9bmNWMOE+iJkXlTsLFy+MY2AR5QQmp4USH4o0xq8Mhrxv 0AzvjJ1ctZW/52pMux8A7CumpugkXTEhVP0m8WVKVJ8cqTBS+32XnPdcbQFwKMic4hHf uZLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bnL7FccJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j128si5472136pfd.128.2021.04.15.19.52.24; Thu, 15 Apr 2021 19:52:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bnL7FccJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238106AbhDPCOK (ORCPT + 99 others); Thu, 15 Apr 2021 22:14:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235057AbhDPCOJ (ORCPT ); Thu, 15 Apr 2021 22:14:09 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2104DC061574; Thu, 15 Apr 2021 19:13:46 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id g35so18171932pgg.9; Thu, 15 Apr 2021 19:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=4aOl9WYg3lZW03MpbHK6GQG1irPulDKlcMdmsoDYUyM=; b=bnL7FccJsG4zTTkJBYehFLpBUVXBexu/pyNJ80IOWqbViQDw7z3C/kvtTNDfM2bzZr oDNQDWg5jLTENvwM1CT4YhJio8vD5aMBLl1R17FzJpALCLadHm3CPdbJNNsPdA4cY/4I XbiHdLJX5Z3/2oXc5ZJGRTW7KMarBWQ6jnnzR5pnWpR5ob80IGmBVNoooi8HZ3+s/t/P EdkhKKY8c44MGFBz+txDcSrUHJFH8PVVc7FtqOqkjlDzwvNJ2XcBZy9xd/y2O7O2pVrq Uw+v1zNmT4WN3vB5rdK6ZbtLM8DND5b+tGYU7RzCkT6Heg12fTBO/96323NN1bBsAsdI qqUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4aOl9WYg3lZW03MpbHK6GQG1irPulDKlcMdmsoDYUyM=; b=WH+/Ww9ZuG90vJo7kORCh4F6pJj9FnbX/aq5ZDDYgxPZmt3nBWlgBPY6dqPlfeFg/c MyqLFOk5ownyx/k6bgkf/Y9gCx+MUKnKdvKAxpnIKH75gRIKwmTYt5Vf6oLjs5I0bIRM UkSeawi7q9rz5lGnNSsPjqcgUvidEh6WstWzlQZiYGn7hymF2vqjmS7sTLwPvMuX6eMg uIJWvrlBYLjqRbkpj1dz6f69Pg2LGzqA+LiYh+HfJSz5OAjj0fa1VIIeecJzH1pFbn6/ hWqcjo+5/dXoQnfsKHJtg5znj5L18dY/PYLZOg/ySRrn36MCZ6gVPpA0RGfNozG5rXjp FX4Q== X-Gm-Message-State: AOAM5306tIaWx7sxxanV0YHXp6liSo7fWisDn2IgLZ6gADy19S2XRNNk 2gTUYS91ejDyeoB+wLxpoCs= X-Received: by 2002:a05:6a00:2247:b029:25a:978:40b8 with SMTP id i7-20020a056a002247b029025a097840b8mr606588pfu.54.1618539225453; Thu, 15 Apr 2021 19:13:45 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com (c-73-252-146-110.hsd1.ca.comcast.net. [73.252.146.110]) by smtp.gmail.com with ESMTPSA id u25sm3407079pgk.34.2021.04.15.19.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 19:13:45 -0700 (PDT) From: rentao.bupt@gmail.com To: Wim Van Sebroeck , Guenter Roeck , Joel Stanley , Andrew Jeffery , linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Tao Ren , Amithash Prasad Cc: Tao Ren Subject: [PATCH v2] watchdog: aspeed: fix integer overflow in set_timeout handler Date: Thu, 15 Apr 2021 19:13:37 -0700 Message-Id: <20210416021337.18715-1-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tao Ren Fix the time comparison (timeout vs. max_hw_heartbeat_ms) in set_timeout handler to avoid potential integer overflow when the supplied timeout is greater than aspeed's maximum allowed timeout (4294 seconds). Fixes: efa859f7d786 ("watchdog: Add Aspeed watchdog driver") Reported-by: Amithash Prasad Signed-off-by: Tao Ren --- Changes in v2: - do not touch "wdd->timeout": only "max_hw_heartbeat_ms * 1000" is updated to "max_hw_heartbeat_ms / 1000". drivers/watchdog/aspeed_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c index 7e00960651fa..507fd815d767 100644 --- a/drivers/watchdog/aspeed_wdt.c +++ b/drivers/watchdog/aspeed_wdt.c @@ -147,7 +147,7 @@ static int aspeed_wdt_set_timeout(struct watchdog_device *wdd, wdd->timeout = timeout; - actual = min(timeout, wdd->max_hw_heartbeat_ms * 1000); + actual = min(timeout, wdd->max_hw_heartbeat_ms / 1000); writel(actual * WDT_RATE_1MHZ, wdt->base + WDT_RELOAD_VALUE); writel(WDT_RESTART_MAGIC, wdt->base + WDT_RESTART); -- 2.17.1