Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp89932lqe; Tue, 9 Apr 2024 15:52:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWeRL5j5WHJm7p9drQoQUK0LhE1vYFKnAzYYcnGgVJ2srJFFZq5Ut9hE74vhiuVwXte8OA3AyG6/IibzzrPenM1ezT+4YO/b6n6ll07mQ== X-Google-Smtp-Source: AGHT+IHguiZn/dag816YX0O4zs9G7y71KCJHk8Roc2Ssa9ytZN2P/m/rMEm0B4b2xnyR7yfLveaf X-Received: by 2002:a05:651c:21c:b0:2d6:8ac7:455 with SMTP id y28-20020a05651c021c00b002d68ac70455mr842039ljn.40.1712703170831; Tue, 09 Apr 2024 15:52:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712703170; cv=pass; d=google.com; s=arc-20160816; b=DEpufhnSq5qp5ExTMIGqZYc78hcJ85XRIH/+cQRVo6qyA/ieXcGNqQZleRED9ba0wP YRDDYZIkDYbIY2gErLKiebue5pk07gdWywM2FV7ARG7LNnV2OMiYd/YkFOeX8v983TDQ MyqmhsJ1BrG59MzBMBiaoL576QlBgQo/qNe4XxGAoWGyoasaW/oXFbTHZhDj5Mh35NWx kw/m1dVXmlZlLs2iD4tIwfxMEW+ZLjgXQdNfOcAeevSu9YXAKk9SV1GbiP4XfUSrux8D ETjJi65hiineIX963t6WjyVbwTMI3zzwz8dwCrND4M/1EO9WZ2IRfGaEf9a6oQMruXHX 80Rw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=9IChGeyewOQVc+4wFNp4MCgvptfqjIj4DO0cy+3BUIA=; fh=svbAB5hgbbP4Hshg0yhRlJy88TNJQKAZnGmRf4bo2/w=; b=N75QNi+HKvsOd9a0FTuaKKn5zdQTLFjRhB+nSy3/3oPuYUaqiX8iJfqp2g3gmFMYQR xo/7yNembrf9N4mBwCqNtpM+8AedNLt0pwlhC00UGgj7oZLUUNoRdeWDVhcNxNmg6HCA 84eXqz5SAKs7cntc/8qijHHTNNO8+oeI1NnkUOU1c8RwPF4feD43UkCDqtZKh28MiCly K9rwWV1sg3/7M7d16Oyt2BLlNHQv8DLRY1PphXxqcYwbbT9l2fMxCDKjJ7SCKb7OM5w4 ktNxY0uSZ40Mjmec6/cz5UCieh0gMC3TtdbjDccK3ram7+Tjc0cSEbe9qTFRcDL7Hnb9 wxVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-wireless+bounces-6055-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6055-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 30-20020a508e1e000000b0056e21645042si5445893edw.278.2024.04.09.15.52.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 15:52:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-6055-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-wireless+bounces-6055-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6055-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8AA8B1F222F4 for ; Tue, 9 Apr 2024 22:52:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3029B158D83; Tue, 9 Apr 2024 22:52:46 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from mail115-95.sinamail.sina.com.cn (mail115-95.sinamail.sina.com.cn [218.30.115.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDD781DFE8 for ; Tue, 9 Apr 2024 22:52:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.95 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712703166; cv=none; b=U8Wf1e9Ah31Zstg+l2KghiBeuQ/WQ14VIAYJ2cOrwm4g4dO6mDjD5jNZgYeJnaXFHm52LqWd1X9MP9neuRFJaif60AwW67Wli26sL3oOtcKXJqeqeZLZ66z8a1MjVQwbpDcnwBrlB/ye/91zejWi8TApcL+ob5LbmriPMEpAPDc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712703166; c=relaxed/simple; bh=O+mGXfs3RDsQTErSVM8OTaHI3QnXgNIs9P8CYq9GNoM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HQnbxnVCH8s+QsWGPXghc3lBckLGJ2RY8/3js1wcdLsnitvfA9uOS0RYABC0JenL1i81g9Qs5D3Fk3qiOqW7jKrPM3LeVE8BBOe9fSXGDbWXv2n/7OBgUMbRvY0UzBrPec+q6R6GMkUfxB0TLO22crKO1b/P/u4ZxcBHL/zrfow= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([116.24.11.163]) by sina.com (172.16.235.24) with ESMTP id 6615C68000007624; Tue, 10 Apr 2024 06:51:48 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 83548545089525 X-SMAIL-UIID: AA18EA2385864CD180945C3BC5570DCF-20240410-065148-1 From: Hillf Danton To: Thomas Gleixner Cc: syzbot , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, Johannes Berg , Kalle Valo , linux-wireless@vger.kernel.org Subject: Re: [syzbot] [kernel?] WARNING in hrtimer_forward (2) Date: Wed, 10 Apr 2024 06:51:39 +0800 Message-Id: <20240409225139.1556-1-hdanton@sina.com> In-Reply-To: <87a5m27r08.ffs@tglx> References: <000000000000b77a880615a0ed2a@google.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Tue, 09 Apr 2024 12:46:31 +0200 Thomas Gleixner > On Mon, Apr 08 2024 at 19:46, syzbot wrote: > > ------------[ cut here ]------------ > > WARNING: CPU: 1 PID: 11239 at kernel/time/hrtimer.c:1053 hrtimer_forward+0x210/0x2d0 kernel/time/hrtimer.c:1053 > > RIP: 0010:hrtimer_forward+0x210/0x2d0 kernel/time/hrtimer.c:1053 > > Call Trace: > > > > hrtimer_forward_now include/linux/hrtimer.h:355 [inline] > > mac80211_hwsim_beacon+0x192/0x1f0 drivers/net/wireless/virtual/mac80211_hwsim.c:2335 > > __run_hrtimer kernel/time/hrtimer.c:1692 [inline] > > __hrtimer_run_queues+0x595/0xd00 kernel/time/hrtimer.c:1756 > > hrtimer_run_softirq+0x19a/0x2c0 kernel/time/hrtimer.c:1773 > > __do_softirq+0x2bc/0x943 kernel/softirq.c:554 > > invoke_softirq kernel/softirq.c:428 [inline] > > __irq_exit_rcu+0xf2/0x1c0 kernel/softirq.c:633 > > irq_exit_rcu+0x9/0x30 kernel/softirq.c:645 > > instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1043 [inline] > > sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1043 > > > > The code which arms the timer is not serialized against the callback so > the following can happen: > > CPU1 CPU2 > > __run_hrtimer(timer) > if (!hrtimer_queued(timer)) > hrtimer_start(timer); > > hrtimer_forward(timer) > WARN_ON(hrtimer_queued(timer) > > This really wants to use hrtimer_active() which takes the running > callback into account. > Then the race window is still open with hrtimer_active() and serialization outside hrtimer is needed. CPU1 CPU2 --- --- if (!hrtimer_is_active(timer)) if (!hrtimer_is_active(timer)) hrtimer_start(timer); __run_hrtimer(timer) hrtimer_start(timer); hrtimer_forward(timer) WARN_ON(hrtimer_queued(timer))