From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 A2CE082899 for ; Thu, 11 Dec 2025 04:30:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765427426; cv=none; b=Eng6mzY6TwH7GeE/EuQo5qoWXgOmdrwxo86mTl9Vb0b0zxXydAtAOm5HwXPTQfgLmEUP/8PAMpd7BLejHmB810OIlzsQZuex76FeuUzER9klmjlktr6SrTkHquTLscmNV+d1GOZKUS0hKNPUGxubtc5VQntLwiH6aMWpKhboUD8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765427426; c=relaxed/simple; bh=rDnHUQF3r1AMgpCQHMiLzc+CG8b01utAlAq7nNbX9Gs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=k9dILBwmmp92EMFu98+CDhdp7zdHgS80GxmItF3koYuPYngWFP7oSDmyOvtlImKsuCpBrvxv/PtYcFHLkByNlWSXdVXKMSzGQ6fFVj3YWUgyfxqwA2fdtYQkwaK4zUClgUY2wJj5ERoZeS6HjHuhJ3zp1NfAy8maDWpHJp1ieiw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kzalloc.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kzalloc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-297f6ccc890so767725ad.2 for ; Wed, 10 Dec 2025 20:30:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765427424; x=1766032224; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rWrfEXbTer8q/iRow+0KBLnEfp0JClsOz4Kq6E2txQg=; b=Kq6Tfd1PEXajjbll5g8pQTr/IzLjQwB1zOwVP3tjrTjLrn9nhHeZz+rZKnWJT5ko8P 5eQObvezGHo0F4jAysZTcDLzkcvvKR3hjj3IDk6dbttmpM0d64hkWIepyVa0GypGV26D fGlqte0AkITu6pEJ5sE8JZvyXkD0V6K0DqG57IojvwjxdZiUe86qvgHabDCC7Im7sykB PbwgNb1ohsa7P4wV54+QPRBg4Tsr6rK5nbKdAhV524w1lhETs38UmkGmTUW3pKShHFaw SrXiDGDoY0Q4ZiCX18W2qX5V4shX1ReSLu0slrbTO7Vfhuqyrzgp9VW0Scw5FDOQlVDM uUrw== X-Forwarded-Encrypted: i=1; AJvYcCUF/yIl1Qp0kQO7GeY0TlbUy9GlOudvE3XbhJ4e+R4rQ2nn+v6McEnP499eIrIRuiqO1nJczDqNzM2Zxjc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1/EMAYOM7zDh8241vOHXUG//1etL1WkCcLe+oqai0NcP4WVxp qq+wG2BXN+nRMnm6x251UAyn2wXJsx6SeSnJWM5CXalYeXsiUZuze6n9h4QlqLPu7O8xys7JnQ+ ffw== X-Gm-Gg: AY/fxX4gj0bchzzfAg4axGiQubn9xbbKEs6HyiRQWl5kFjitnphmAgeGQ2fku4qsFt9 iIUX1tSp1hl6AwicQodj6faoowGv+KixQW1W2LdPDyfh+AuQX+VQ0+rGK9Ak/86t3mM36nCRh+C KbLiySXg7mKSz1eFodAStIxQ//jhA4RXo3nVG0SoYk8mpf8T5R+thacDOhzVbEmGMAw9DAPXK8+ yEjYgVYK8QZngYHwNaBYUAqiSHWVRLlBoihOEI2xiMRRcx8ehGMnF8GQjkpWhtWb6+AUSN9l2qi JvDa9yAnJDvi5mKm9DTA0vh6/eVPRmfGLcJQGwCto+K4XLgFbUgo2hZzM6tBP42yhtfT+5jrpAT AyQD2FEmd7FiOZQOxH8pBZe/7cBKiWXeQXgmoy7KlGG4BJE5b+DYy5BB4lnLausx2r5XtW/p80y c0YOdww4zA/1Nl/g+dSNFd6bn0RJsmD1EOTNy2K1bifk2hbaRg7QkcBmxJfp2Tz9qytHIRac67g LBrMKT4UYYhu9d8k9YvEaZRiT3A X-Google-Smtp-Source: AGHT+IEirdSxhyq24x5EZ9HCnhoACWqzQOtyEPAGD1ap3jh6yhlTnLH7xQNRl16EpjTLAFvs4n4y5w== X-Received: by 2002:a17:902:ef46:b0:297:e604:598 with SMTP id d9443c01a7336-29eed28c5e7mr9000815ad.4.1765427423825; Wed, 10 Dec 2025 20:30:23 -0800 (PST) Received: from [10.200.7.226] (fs96f9c361.tkyc007.ap.nuro.jp. [150.249.195.97]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29eea043eefsm8685025ad.84.2025.12.10.20.30.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Dec 2025 20:30:23 -0800 (PST) Message-ID: <53f17978-40e5-4b2e-b719-552612b0e775@kzalloc.com> Date: Thu, 11 Dec 2025 13:30:19 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [Question] Detecting Sleep-in-Atomic Context in PREEMPT_RT via RV (Runtime Verification) monitor rtapp:sleep To: Nam Cao , Gabriele Monaco Cc: Sebastian Andrzej Siewior , rostedt@goodmis.org, Tomas Glozar , Shung-Hsi Yu , Byungchul Park , syzkaller@googlegroups.com, linux-rt-devel@lists.linux.dev, LKML , Dan Carpenter References: <32839fb6-dbcb-4c5c-9e3f-d46f27ae9a73@kzalloc.com> <87fraslu9c.fsf@yellow.woof> <87jyz5kuf2.fsf@yellow.woof> <20251202112644.YUux4LKd@linutronix.de> Content-Language: en-US From: Yunseong Kim In-Reply-To: <20251202112644.YUux4LKd@linutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Nam and Gabriele, Thanks for the great presentation at LPC 2025. I have a follow-up question during the Gabriele's Session RV and real-time properties, regarding spinlock behavior in atomic contexts (IRQ/preempt disabled) on the PREEMPT_RT kernel. On 12/2/25 20:26, Sebastian Andrzej Siewior wrote: > On 2025-12-02 12:14:09 [+0100], Nam Cao wrote: >>> RV is not a static checker, it is a run-time checker. >>> >>> Just in case you are not aware yet, there is also Smatch: >>> https://github.com/error27/smatch. But I can't offer much help there. >> >> I was looking up something unrelated, and I found that Smatch does >> detect this sleep-in-atomic problem: >> https://staticthinking.wordpress.com/2024/05/24/sleeping-in-atomic-warnings/ >> >> I'm not sure if its design takes PREEMPT_RT into consideration. But >> seems worth having a look. > > It does not look like it does. Judging from > https://github.com/error27/smatch/blob/master/check_preempt_info.c > > it increments the preempt-counter on preempt_disable() and spin_lock(). > So it won't yell at > preempt_disable(); > spin_lock(); > > while CONFIG_DEBUG_ATOMIC_SLEEP would. I specifically believe that RV can encompass the role of CONFIG_DEBUG_ATOMIC_SLEEP and even go beyond it. My reasoning is that even if a sleepable (PREEMPT_RT) spinlock is used within an IRQ/preemption disabled section, CONFIG_DEBUG_ATOMIC_SLEEP might not trigger a warning if scheduling does not actually occur (i.e., if there is no contention for that spinlock). This is because the actual debugging check happens in __might_resched(). Therefore, I think RV could catch these potential bugs that might otherwise be missed. Is my understanding in the right direction? >> Nam > > Sebastian I really appreciate Nam and Sebastian for sharing valuable insights on static analysis tools again. I recently discussed this with the Kernel CVE team, and Greg confirmed that such usage (sleepable spinlocks in IRQ/preempt disabled sections) is handled as a CVE. I would appreciate your insights on this matter. Best regards, Yunseong Kim