Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1477123ybl; Wed, 28 Aug 2019 15:34:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvRuXvh6NgzoRGbGcZ1gFfLJr9VXY/L/nDZw5Uc2rLxuUVGRPJ0vWpR6mhdg2eKUBWynoF X-Received: by 2002:a62:60c7:: with SMTP id u190mr7589020pfb.54.1567031662348; Wed, 28 Aug 2019 15:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567031662; cv=none; d=google.com; s=arc-20160816; b=wgsncsaKjTQeaIUDO2+/BYtcZLWRr+eT/Gwpo9PaAYUwR6EZSf1qCWvY6gpsCR4w+k cz5IDdID7oaAaRRYD6u26ZHo0S9CAYcg7fcVULhsimJWBCkU/craELqrt09zFrqxKjMs cLyKuqcA7ZlRd7IH5S9MdMnLAPOxr2b+yPY5tpGmMFWWKUKqYEHIi1AzmSlXjJ3HnrSv NbaKm57fjpqcwtz9ugyciaiiKj7ijDSsO1tTU81YT28h+hvAdJ3EJBKRakLcAzarLdEI e0+lYw0sAvVARtKmdqu3dsFYwbmWdylgfriSHjFfT8ofI5cUlKQCX8NVbUwbEnanQWoj pgyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=0HaheuQHQRT9LEcUZx3XnMQChJG5XRPyuRaS389XelY=; b=WLUsqoQseL3ws1ty82Tbnia74YsOd+A8qf1JuzZ2MaPfI0FWceRd/xfFZo0vDZFrHP lXMPCjXefIWjkiHz4orKGiAzJpEMI6d1M6R76f/q/Q+Jeu7R//nYYbgk0tFJ8eJPtWm9 Dv10hqJTneXUrgjducvfYhTEDqUNHHmLyTJiQtkMSEJzwGDDulSvVSHXAFXS1G9v94qZ 99KwZBC2E+Y83UEhVbqJWLCskQ0C//VYVVgQJgvd4qMK1uuPWad1dggoJtmrrOEfy3lJ HsvY2z5AuRx3oI2m0o43TrS6CM1oJExWyQomjEqZYRmDCDFTl8ha8ApARarI9MACKGPu UWnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=V5vZiC16; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si187292plt.283.2019.08.28.15.34.06; Wed, 28 Aug 2019 15:34:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=V5vZiC16; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727115AbfH1Wcr (ORCPT + 99 others); Wed, 28 Aug 2019 18:32:47 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:35546 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726658AbfH1Wcr (ORCPT ); Wed, 28 Aug 2019 18:32:47 -0400 Received: by mail-oi1-f193.google.com with SMTP id a127so1040243oii.2 for ; Wed, 28 Aug 2019 15:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:reply-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=0HaheuQHQRT9LEcUZx3XnMQChJG5XRPyuRaS389XelY=; b=V5vZiC16J5Bo/EFt40iuUWwnm4/xViVSyGBhX75zFVM/0kdyuv4XCBtyAd9+y0EBjk d5wLd/zPiUSIRR4KUVHRY2vJMnraOR+JkElYh03WeZhN2wtSyAAi7hO66MrzSCteG/1t oRqrQX9yAYfoUsCVBPa4jjk3F5LPzqib+FED2i8aDpUO2j5P4jQ8if+CV+dinRsrqK08 YxxqiDBbjCsNsevgElegWEiAPAW5v69Gb4mOX1O8TdQPRHWUpfyCcUx5fdUquy1/+vXW GJuC3+wdydLKcUIhdLsSdxR5brS47cl73bDpTsh7TE5xBs52AdWWr+0fB9EYWGzuvFta Fb7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :reply-to:references:mime-version:content-disposition:in-reply-to :user-agent; bh=0HaheuQHQRT9LEcUZx3XnMQChJG5XRPyuRaS389XelY=; b=KJzPIChT+msXsf6s0FKuhHh73z+DM/VJ+H9H6duuHpyj9l0IC3NDIaEzzy7OBqP5wE G8UcWKw0hExfok2urEph0Ps1r5UQ5E756h7eZsp1tcEKplyhd0WiltwZltuG3BSJ5tDt xZGRI00xz5UkT0db2dqJvN14MiEnWN9fqvgMWO8ytrjlxSr8lJjbjzcdZrH4ScqoAzKS gTieqr5O26YCHijsEuTHGqNiAYLJnCY3mpyX1JEjWXjK5gws+QGYUipNVH6jOEcSLf9m O2liwkEm6PNbkckeZ+1IsJSbA5bpFgOXx9txqiBEoj7wszcH5HKVYlKWH43oiQsAM8wN 6G2A== X-Gm-Message-State: APjAAAVhG6mcbGjteRqmGazJsEtaoQxVEm/OuiQaSSEOpmMy+2DVYv9A qUP4d4N+aH0dDcw+m01Geg== X-Received: by 2002:aca:5ad4:: with SMTP id o203mr2830633oib.136.1567031566036; Wed, 28 Aug 2019 15:32:46 -0700 (PDT) Received: from serve.minyard.net ([47.184.136.59]) by smtp.gmail.com with ESMTPSA id i17sm135007oik.32.2019.08.28.15.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 15:32:45 -0700 (PDT) Received: from t560 (unknown [45.19.219.178]) by serve.minyard.net (Postfix) with ESMTPSA id A5C7E180039; Wed, 28 Aug 2019 22:32:43 +0000 (UTC) Date: Wed, 28 Aug 2019 17:32:38 -0500 From: Corey Minyard To: Jes Sorensen Cc: linux-kernel@vger.kernel.org, openipmi-developer@lists.sourceforge.net, kernel-team@fb.com Subject: Re: [PATCH 0/1] Fix race in ipmi timer cleanup Message-ID: <20190828223238.GB3294@t560> Reply-To: minyard@acm.org References: <20190828203625.32093-1-Jes.Sorensen@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190828203625.32093-1-Jes.Sorensen@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 28, 2019 at 04:36:24PM -0400, Jes Sorensen wrote: > From: Jes Sorensen > > I came across this in 4.16, but I believe the bug is still present > in current 5.x, even if it is less likely to trigger. > > Basially stop_timer_and_thread() only calls del_timer_sync() if > timer_running == true. However smi_mod_timer enables the timer before > setting timer_running = true. All the modifications/checks for timer_running should be done under the si_lock. It looks like a lock is missing in shutdown_smi(), probably starting before setting interrupt_disabled to true and after stop_timer_and_thread. I think that is the right fix for this problem. -corey > > I was able to reproduce this in 4.16 running the following on a host > > while :; do rmmod ipmi_si ; modprobe ipmi_si; done > > while rebooting the BMC on it in parallel. > > 5.2 moves the error handling around and does it more centralized, but > relying on timer_running still seems dubious to me. > > static void smi_mod_timer(struct smi_info *smi_info, unsigned long new_val) > { > if (!smi_info->timer_can_start) > return; > smi_info->last_timeout_jiffies = jiffies; > mod_timer(&smi_info->si_timer, new_val); > smi_info->timer_running = true; > } > > static inline void stop_timer_and_thread(struct smi_info *smi_info) > { > if (smi_info->thread != NULL) { > kthread_stop(smi_info->thread); > smi_info->thread = NULL; > } > > smi_info->timer_can_start = false; > if (smi_info->timer_running) > del_timer_sync(&smi_info->si_timer); > } > > Cheers, > Jes > > Jes Sorensen (1): > ipmi_si_intf: Fix race in timer shutdown handling > > drivers/char/ipmi/ipmi_si_intf.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > -- > 2.21.0 >