Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1367383pxy; Thu, 6 May 2021 06:41:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHEOAYccmXd+t4DYHmYmBdPt+uxvkmveKArSwAUp4ohMsnZo3Ii7Fe0gs0r2obAxX47cY3 X-Received: by 2002:a05:6402:138f:: with SMTP id b15mr5245276edv.121.1620308468347; Thu, 06 May 2021 06:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620308468; cv=none; d=google.com; s=arc-20160816; b=ydCCCbTXy9Op6t2XSpEAxiWG0D5rx63pgQpEzx6Zss9YMXnloOwqZ7DaEgI0vNcNqo MYNWfkAURGdm6LGvG9Kn3kTHErKqE3OenCW4zdiCpZ2Jvr1TOjr2FfqNZsvQCkCBH9dH pmGNU8h/YIr4dwHKrNeGe2VljTEvr+iz2EjewtZaTS9ybgTeTdD5OBnah1rMqgbofICd kO6irkqyflY0jAmlH+YL0MGqTC9viVBKlTgR1ahCr1IRcM9Pr8agCjig5mqZEdgOEvhh eYxK2sczvQ0XeBvzXDmhrdPjydy5DK+bX930lshDIZDPys/xi9P4k5J+1iIQCxfUwXLl D0fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=cZKl1g221hvgsUM4ruH5PC7LZQBfPUMAAeP8YaPjGAU=; b=ne/J9maOPTsWBTzSWUSo+WJzLwPF2Pf+dLIQsdRZiLpXWU38d/EDdrp+z9YMg9dZA+ TfP8E5EpuGKHps0ekbhGOBuE+rnXtyzuQCrhjgIpZE9qwsfhiBOBEKcmVCH3vgh+mW/L VvjDC9gJdaYypVj6/xyqefW3ah5lfAx1qV/M/+i6tAlcX4r9xixnQrSXF6EVRAjvqueb oFWI7wrXJcyQBcEv9Hg46Uf952x750iISGCO6r8tMY/IooB6KC9YGzeFGaXAWUI+/XNa CvWEj0Qu1ytFiTfEockCdqGSbeGvSGJoSLKYktS8VtZAnH87xnVVEXdglIi/sex5bq0F A7EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=iCvBIdp7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c16si2671932edw.227.2021.05.06.06.40.42; Thu, 06 May 2021 06:41:08 -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=@infradead.org header.s=casper.20170209 header.b=iCvBIdp7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234188AbhEFNiB (ORCPT + 99 others); Thu, 6 May 2021 09:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233461AbhEFNh5 (ORCPT ); Thu, 6 May 2021 09:37:57 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30A47C061761; Thu, 6 May 2021 06:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=cZKl1g221hvgsUM4ruH5PC7LZQBfPUMAAeP8YaPjGAU=; b=iCvBIdp7CfSO/0BJGcxbWozcPf t5+tSFPC4ck12ybfCEVvVxo8U9LY1fxOS9JBCsesLSJjScpvyFriKQ5I121sTTU1wduIRAToqxDWQ GUihxZ+vvPpjjBG0m720St9/4O5srJjJswCAjDCQDB2hZTwbdav9kAZIHPV6njAwGAGhzH6xRvEqz Cwd2WqijKlvf7k5hA1Ys4CSZ4t3jNrVLPEMozQv6gelS2+1Bzb6NL82XwqXWmUaLKKA+giVqeDHYN e9oTf6PG6n/UTia4wqFcyPO9x27cCS8wnVcM6LiKUFR8vSJDzU8TZk0je2A9cZctcj2GA0skSqibN MTKubsqA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lee9l-001lUf-GN; Thu, 06 May 2021 13:35:26 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 031A93001DB; Thu, 6 May 2021 15:35:07 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D2CEC202641BA; Thu, 6 May 2021 15:35:07 +0200 (CEST) Date: Thu, 6 May 2021 15:35:07 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , x86@kernel.org, LKML Subject: Re: KVM: x86: Prevent deadlock against tk_core.seq Message-ID: References: <87h7jgm1zy.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87h7jgm1zy.ffs@nanos.tec.linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 06, 2021 at 03:21:37PM +0200, Thomas Gleixner wrote: > syzbot reported a possible deadlock in pvclock_gtod_notify(): > > CPU 0 CPU 1 > write_seqcount_begin(&tk_core.seq); > pvclock_gtod_notify() spin_lock(&pool->lock); > queue_work(..., &pvclock_gtod_work) ktime_get() > spin_lock(&pool->lock); do { > seq = read_seqcount_begin(tk_core.seq) > ... > } while (read_seqcount_retry(&tk_core.seq, seq); > > While this is unlikely to happen, it's possible. > > Delegate queue_work() to irq_work() which postpones it until the > tk_core.seq write held region is left and interrupts are reenabled. > > Fixes: 16e8d74d2da9 ("KVM: x86: notifier for clocksource changes") > Reported-by: syzbot+6beae4000559d41d80f8@syzkaller.appspotmail.com > Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel)