From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2308C21CC5A for ; Sat, 11 Apr 2026 05:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.71 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775884468; cv=none; b=uKGT3AGmUjRX0XTAwd3Hkwg78p6ZugHslvdxr79xRzl0MholF23P7oqpbiNpTyxVsTEiyZsOcVPK5hOTn4EgZVLee7Q+uf3JAUa77fnHvyD0HjlKOutRZVrp5nA+ByAZUK7pz5bSRUxZcf6iwej6nTi6KCICTLNsBP6MDrYbVFI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775884468; c=relaxed/simple; bh=U46PeLvPPyjFOGjOL7zF5whVBghWyyjBPqXNu/XfnZo=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=jEEZSNpD+P0WG4/miADnl/jae5cSjy/zl2uJKW50N54Qr299aOUNPFSerwVlmRODlhUaNUiTUYndo+m2MC0PQlK4su89ygIH5+1y7Ntr2Spk5VPnNQeZNwHCInfVcLdfpl5WjqaYdt/eHNmVTz9CmLpPmguTmeCqleEbU+azEew= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.210.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-7dbb6b95836so6057133a34.3 for ; Fri, 10 Apr 2026 22:14:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775884466; x=1776489266; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Le7h1+UDhxl9DUVYw94NozGKBINnZEtdqv3ldzg48YE=; b=Qs6o2jI4S92VwyTtuCSuR/qDVRD9KnhLXs8ZUrd67kJ8btKdSJkeTzytvq78BhQW1i 67LxyFX2C7MhK2OaaWljtcuhRK3/fVsur++1ALlDvi/6qqr+4eZthnBkmZnQey0+hjzl 9Rs5GEQJfO+n5LhxFhRjDowaHq7zg6ven599Jrnbnf1w4Tm53aPAf7+jCiK6YvLrZU91 m2cfLqkVZpDXaNu2X/plN9VEvSrgKnR/nNx7etthNrvz7rmAI97ta00xJxgUjqHuQQ9p Q1JHKFcA2A4yE9n/Z+UjcY2oCQhYO69YLM8CfybgQzv/kW2la0ZYxN+lDNpUHyW5jOZK cgBg== X-Gm-Message-State: AOJu0YwmRsvQCukSc4qC7AjLpeIh1Vd08gzVXUHg4j5wReUWA4FsAVB6 6S1SrCfa3T91SgONgcTSqownUWW7y/Y5fVDuHQMU/hWfGpVE3hGjlS7yymHkBk1h9ot7uh+pc4M XQwd5w7K2J4ofcetpuSU9yQE/Csms4zGqoKvT0ZVNm3408RHgykybiP18EQ0= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:627:b0:67e:2bf7:1a49 with SMTP id 006d021491bc7-68be8fce60cmr2766481eaf.60.1775884466155; Fri, 10 Apr 2026 22:14:26 -0700 (PDT) Date: Fri, 10 Apr 2026 22:14:26 -0700 In-Reply-To: <69d7f03b.050a0220.3030df.001b.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69d9d8b2.a00a0220.475f0.0003.GAE@google.com> Subject: Forwarded: [PATCH] arm64: KVM: Initialize vGIC before preempt-disabled section in kvm_reset_vcpu() From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] arm64: KVM: Initialize vGIC before preempt-disabled section in kvm_reset_vcpu() Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master kvm_reset_vcpu() calls kvm_timer_vcpu_reset() inside a preempt-disabled section to avoid races with preempt notifiers that also call vcpu put/load. However, kvm_timer_vcpu_reset() eventually calls kvm_vgic_inject_irq() which triggers vgic_lazy_init() if the vGIC has not been initialized yet. vgic_lazy_init() acquires a mutex and calls vgic_init() which invokes synchronize_srcu_expedited() -- both of which may sleep. Sleeping inside a preempt-disabled section is illegal and causes: BUG: scheduling while atomic: syz.1.49/3699/0x00000002 Fix this by calling vgic_lazy_init() before preempt_disable(). On the second call inside kvm_vgic_inject_irq(), vgic_initialized() will return true and vgic_lazy_init() will return immediately without sleeping. Reported-by: syzbot+12b178b7c756664d2518@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=12b178b7c756664d2518 Signed-off-by: Deepanshu Kartikey --- arch/arm64/kvm/reset.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index b963fd975aac..4ee16b4a37b5 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -25,6 +25,7 @@ #include #include #include +#include "vgic/vgic.h" #include #include #include @@ -198,6 +199,14 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu) vcpu->arch.reset_state.reset = false; spin_unlock(&vcpu->arch.mp_state_lock); + + /* + * Initialize vGIC before entering preempt-disabled section. + * vgic_lazy_init() may sleep via mutex_lock, which is illegal + * inside preempt_disable(). Second call inside kvm_vgic_inject_irq + * will find vGIC already initialized and return immediately. + */ + vgic_lazy_init(vcpu->kvm); preempt_disable(); loaded = (vcpu->cpu != -1); if (loaded) -- 2.43.0