From patchwork Fri Apr 16 02:13:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 12206513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8CB3C433ED for ; Fri, 16 Apr 2021 02:15:33 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2045A6115B for ; Fri, 16 Apr 2021 02:15:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2045A6115B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=KvRfNWWgMe+IGjFgh+YXKX8676PhofcP2gRn9Mshw08=; b=VdgHcnfd824EamVtbo0gzPpzZZ 40Y1WQBn+xFfabMvf6GyQQiwhqRnhtUEH2jGOgezGH/VBpBKXjblvrYU8aocEcNSqnlnx33dkADiD BEFP+Uv3BDZ5Cav8LfmMtX62nCpVlwM4QOj+6RCqdBtr1ckFdzsvsNackar8rJIPRim2P8mSR4HT4 sIPpcmQBruCmMJ6VNMTCsFrU/JSgKL4gMhX8whdG/452fIf0hwEJr0lvT4CjLDauDSCxIr5Iez7HG 6TxS9TZu//pm22RiLkMDThF8EnYNMCFFcIao+CjUyefzCK0XQ0XXICjoCEoui9+RVPSKu9GkUX6Wp Kx1qa9cA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lXDzZ-000St8-WE; Fri, 16 Apr 2021 02:13:58 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lXDzU-000SsN-QR for linux-arm-kernel@desiato.infradead.org; Fri, 16 Apr 2021 02:13:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=4aOl9WYg3lZW03MpbHK6GQG1irPulDKlcMdmsoDYUyM=; b=l+7UHPMFQ445XUsYlJTYpzRcXo tsoMSltVF+J2xlenbme0H844OZPYaAMABK9gwC2QyO16lt3qKy/QxFfn2vqQyzu/ZJZu6Mw9yA3L1 6S4JAhXKwB9bGSeiabzNnM4Cxd5+ieFnSBYkk5UWbAf+bOVSJmo0N++RSqJNWuhPKKeAvzG7RT3q5 0/usv7HMtumq89R3hl3Jp6bJS1WHnGqWf2usC+A05NAHKrkAVNRnN760EC3R6OtJuCXB6eyA1rsSK FTHmkrQOuA/ksGo1enOo9Xt7X7WLbxJtIMSueUpabD5NJIW/oTR0RCAIAeL4Vftp4fawkjO2+PbMX xhor8iiw==; Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lXDzS-0091lC-7c for linux-arm-kernel@lists.infradead.org; Fri, 16 Apr 2021 02:13:51 +0000 Received: by mail-pg1-x536.google.com with SMTP id b17so18207816pgh.7 for ; Thu, 15 Apr 2021 19:13:45 -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=R2VaAYahxJAm1NlrZRT1EkzhFgjAc2Rvbf0sOayinvOqBSiH7xlnhomo0mKKLoWTuL eSw9c0dj4oOBdYKxi9kmT0vZ3bVrJlK3xbzHHPuhMNtNbOw6KNqRSBvyBiDjJ8CxBqbV jlFiwsi4hrq+Nhf0M3pMdPL9JC4pzjdWdvYh12ZIsWE3yzTp3dcpiMoS0kliWKTwJo+M 9stn12kdMGZyiPqj1+xZAm1GuXuWgWtgM3EIWJYtJC6KsdZBVpO3GnYE1fsiMpAhVOk2 fbN46ZO7i5oiedJrO1LrshtTiqAHFyX5ATA3qRTVRvLWY3BoyMFdIqJs5TJcZ+yCj/rW Oh3Q== X-Gm-Message-State: AOAM531LzLgeAh0KQLC43ZifjAtPfGyL/1Sx2bSTXfF2rqeW6refl5WE GmObs2srhalkrdC3gKz8bd4PVuopTEAul9ALAeE= X-Google-Smtp-Source: ABdhPJzT1yDrVtxLd5Qh4dvbNL5uVKACMlcjXTmzw+HDicnrP+3i8/R73Qp6cm6BaCw/Uj8qOK/3Fw== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210415_191350_294880_E4229FFC X-CRM114-Status: GOOD ( 11.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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);