Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp825207pxb; Tue, 3 Nov 2020 13:36:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxy51n9W4x2CKdeL2ddVSAfm6lUAofjo3FSyZt0qFrQmVw/QGADQ4mXyU9TRaUwiE48rudO X-Received: by 2002:a17:906:82d7:: with SMTP id a23mr15472809ejy.505.1604439406668; Tue, 03 Nov 2020 13:36:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439406; cv=none; d=google.com; s=arc-20160816; b=muAwnylnyTozI2LiDJAjk96mkqv0IEg2JxdvyyatC+K2YhgNsbFoic5TYKTtAWcIma hmtT2PXiYerpOvRk37PDzyXFpAhCZzGNDnkNYm06MTQTSIo5VjeDT4F0e6KMs37KA5WB 6sV9YZYQ092Ys3I/fRcrMCF9aoGzmcu5VcsiaXh83pJ7P+citf5hB/WRcm7Td8YNrYw3 Mh4mkE9u8y8WYVhYY1dWsfbRNhi0NcS0JeT08WigGRt9FxkX19VKLhrPdXxfo0H7CoyX eHBUsYm2CuMTadzGzXYHNaggsIh7a4CE0iqnsemcRnIdMSixCDkkLAeD+4yLd6BUYjdH sQ1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=X+QtuUVL9LetVxCgD6pZvCgR6rT6l+pfClv+kje/L9I=; b=v8v53BEDU0xYNW+bdQA0t8Z6Ih/PevLSEaaa+xAVSqCy0KO1KYc02fhBSZXIPAtekX +6bI60sjKqnKdT3E2x7Kk/3kRc8hqWkgPGuB95S9ykZiY2yD/sO2/PQyADGxCRjd2R4X 2UFeHfVnSkRBMoGDj0ZRuKMz4yaCXfcDQI8kdex9B0w0+VQJcAlvzYz+o2mrqfR+Oo0k j6vwY/IjOPTziWarHgV3KwizwhrWLFd04dhsDdaB4N2es/NitvEz2UyzRYc7QurvVMXc zMiF7TE2xa1W0pyItxsuR9mMR2dV5hFsvYJDRNDBi8K7zWSgR+Q97f24552EUL6eqA1n 5bwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bvRCFBNn; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j13si13632226edj.549.2020.11.03.13.36.24; Tue, 03 Nov 2020 13:36:46 -0800 (PST) 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=@kernel.org header.s=default header.b=bvRCFBNn; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733116AbgKCVcU (ORCPT + 99 others); Tue, 3 Nov 2020 16:32:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:59450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732000AbgKCU5P (ORCPT ); Tue, 3 Nov 2020 15:57:15 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 46C71223AC; Tue, 3 Nov 2020 20:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437034; bh=gdF1GPyW58qqTIt5QLgJ7KkJhKmPpzFDFHtEqlJKOtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bvRCFBNn2hPT9GYk2CgATRY+cFznA/0CvSy6qv/CdawPP7WMZ7jgycQ6RTmLeDMTS a8lJsWHR2YbYAHj9DiG/uT+if/gG8Zp2LmQBdRE9Rh13GyNTFIU7ztqjx9QfW6DuE1 brPvWxC3VGbWtFg5OZQ8wUELvsrrJZuK2mSBFFi0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Madhuparna Bhowmik , Guenter Roeck , Florian Fainelli , Wim Van Sebroeck , Sasha Levin Subject: [PATCH 5.4 080/214] drivers: watchdog: rdc321x_wdt: Fix race condition bugs Date: Tue, 3 Nov 2020 21:35:28 +0100 Message-Id: <20201103203257.853302854@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Madhuparna Bhowmik [ Upstream commit 4b2e7f99cdd314263c9d172bc17193b8b6bba463 ] In rdc321x_wdt_probe(), rdc321x_wdt_device.queue is initialized after misc_register(), hence if ioctl is called before its initialization which can call rdc321x_wdt_start() function, it will see an uninitialized value of rdc321x_wdt_device.queue, hence initialize it before misc_register(). Also, rdc321x_wdt_device.default_ticks is accessed in reset() function called from write callback, thus initialize it before misc_register(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Madhuparna Bhowmik Reviewed-by: Guenter Roeck Reviewed-by: Florian Fainelli Link: https://lore.kernel.org/r/20200807112902.28764-1-madhuparnabhowmik10@gmail.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Sasha Levin --- drivers/watchdog/rdc321x_wdt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c index 2e608ae6cbc78..e0efbc5831986 100644 --- a/drivers/watchdog/rdc321x_wdt.c +++ b/drivers/watchdog/rdc321x_wdt.c @@ -230,6 +230,8 @@ static int rdc321x_wdt_probe(struct platform_device *pdev) rdc321x_wdt_device.sb_pdev = pdata->sb_pdev; rdc321x_wdt_device.base_reg = r->start; + rdc321x_wdt_device.queue = 0; + rdc321x_wdt_device.default_ticks = ticks; err = misc_register(&rdc321x_wdt_misc); if (err < 0) { @@ -244,14 +246,11 @@ static int rdc321x_wdt_probe(struct platform_device *pdev) rdc321x_wdt_device.base_reg, RDC_WDT_RST); init_completion(&rdc321x_wdt_device.stop); - rdc321x_wdt_device.queue = 0; clear_bit(0, &rdc321x_wdt_device.inuse); timer_setup(&rdc321x_wdt_device.timer, rdc321x_wdt_trigger, 0); - rdc321x_wdt_device.default_ticks = ticks; - dev_info(&pdev->dev, "watchdog init success\n"); return 0; -- 2.27.0