From nobody Tue Dec 2 02:06:44 2025 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) (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 D682234B1AD for ; Thu, 20 Nov 2025 15:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763650996; cv=none; b=jtbrQ4yI5Nlpc+d7ZHWkvbnvJsw9TVdDwVYKt/c36DIChXomlEk+ZSRQ8SAC6C16LlRRbFbAoBgBCtk0YFBGA8UtxJRsnZNuE4EgF2iMhOKDgNT1dhAnuzuJXUF6T8dpqTHnt3d8iGtMwG6/sQc5jbyoC1OiwTuRec/dtpRiSYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763650996; c=relaxed/simple; bh=tTGjUHrfXR5isY+lSEFNNwASkyVwRARVzePML9vCCTo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dMo3ZirF1fl4W4QPnCRGu9ap3XPXhGtgEfgaemsp7e0OqJPl44lrpzqTCHD+g9qBEqP2WuH4tejpv34kQaaNFcIOAdxxh4al2EYs7K1Xk7K+y2zLqpFpOFJpyhG6ECkEcgvL1FmFc4x3Xeb4k4dkWBx8552ILw6j++ebKZdj9fs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pRDQkdoJ; arc=none smtp.client-ip=209.85.208.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pRDQkdoJ" Received: by mail-ed1-f73.google.com with SMTP id 4fb4d7f45d1cf-64161017e34so1327507a12.1 for ; Thu, 20 Nov 2025 07:03:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763650979; x=1764255779; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QTNBohfvQLfYyJiWHtGyLx9FZqAAISthRH9eXaAWBIw=; b=pRDQkdoJOB8BfljkDcQrj/uje2IXL2T/x5eZ/wk8Uc4x/XefY5p5EFYXDGT51MXa7A I9l55vHaC9zE4/cxhD6UmVf6gV7TpKWoE8cGMDsCdDbQnDkewx6hrqthpt4o94TtQL/u MjbcVlir4o3Ji4GPc4Epv0fpq/JlTGllQX22aOwxrTB0zUpmz3DAEXUZAceGwEEaBHb5 lvxujEoCa4QrSLs6V+CUcQRu2XDzktl3P9vyuulCEbS3jrwzJgkkFTVq1OoRAkt1J6aW ekIDBh2nsF6UpK2cJB/ae6naY0w2EbbMIvM2xruXokam9a5643ErVpY8TmJS9Kj3i8CB WEwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763650979; x=1764255779; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QTNBohfvQLfYyJiWHtGyLx9FZqAAISthRH9eXaAWBIw=; b=cVnl8ZKiJ0ojHdDXSySuJrnI5P4lPckuxRE0txf9iuOnZMc/4MPD7MzR7ECQKWpYCf 5dnH8Zd0p894JgJZs4GlDDYhWwWXuUsak0l405nrsh70WJTuWdHIGC0xazu6xDrX4XOg oI8RFOchTpH7O4KM2srvZMLB+AMh4/5ksoZrX0HebOkMYD6a+DTXNGqYetRBk+/u9xdK zluKzSci1lf+Os/QKTx6kj8klvCaDaFGZPWVcHTKpKTGQUh7YTyCM1rxySM0V0uefaF+ MNybT6yyJsH3fvSaWbZI9HduDnFk4sBLkO7cRZ+ihHL+6x2ujW6DXkPNxHRob1laDO+X gzjg== X-Forwarded-Encrypted: i=1; AJvYcCWucoOK4Y5ZGsLoyM5gGkKf1Er8WRjUucKqQ0ZjXeXzTSh8Fie6p5NvPyNC6CzYdsB1nnasm9eZnzo4qp0=@vger.kernel.org X-Gm-Message-State: AOJu0YzZ/Z+GmFEVVowG15MF4FfQB0EOdyfauPZZjDv4VGX9PGfrerTQ ePyEzHxMawTWnLrq+HcdOlBkFOShw7c1hvby2fqthTl0Ti/O2FQITUlhPtzJWDusVT+vaedsAJf pPQ== X-Google-Smtp-Source: AGHT+IF9OaX/QGeSo05eKeUEdCvjlZVpqfgwLf4/MHL/rv8J5uT/4osVo9PFxwafA3Q6L9NfftMIvUQ5OA== X-Received: from edb10.prod.google.com ([2002:a05:6402:238a:b0:643:5f58:caa7]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:268d:b0:640:b1cf:f800 with SMTP id 4fb4d7f45d1cf-6453d084770mr1885049a12.4.1763650978915; Thu, 20 Nov 2025 07:02:58 -0800 (PST) Date: Thu, 20 Nov 2025 15:49:07 +0100 In-Reply-To: <20251120145835.3833031-2-elver@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251120145835.3833031-2-elver@google.com> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog Message-ID: <20251120145835.3833031-7-elver@google.com> Subject: [PATCH v4 05/35] checkpatch: Warn about context_unsafe() without comment From: Marco Elver To: elver@google.com, Peter Zijlstra , Boqun Feng , Ingo Molnar , Will Deacon Cc: "David S. Miller" , Luc Van Oostenryck , Chris Li , "Paul E. McKenney" , Alexander Potapenko , Arnd Bergmann , Bart Van Assche , Christoph Hellwig , Dmitry Vyukov , Eric Dumazet , Frederic Weisbecker , Greg Kroah-Hartman , Herbert Xu , Ian Rogers , Jann Horn , Joel Fernandes , Johannes Berg , Jonathan Corbet , Josh Triplett , Justin Stitt , Kees Cook , Kentaro Takeda , Lukas Bulwahn , Mark Rutland , Mathieu Desnoyers , Miguel Ojeda , Nathan Chancellor , Neeraj Upadhyay , Nick Desaulniers , Steven Rostedt , Tetsuo Handa , Thomas Gleixner , Thomas Graf , Uladzislau Rezki , Waiman Long , kasan-dev@googlegroups.com, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-sparse@vger.kernel.org, linux-wireless@vger.kernel.org, llvm@lists.linux.dev, rcu@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Warn about applications of context_unsafe() without a comment, to encourage documenting the reasoning behind why it was deemed safe. Signed-off-by: Marco Elver --- v4: * Rename capability -> context analysis. * Avoid nested if. --- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 92669904eecc..a5db6b583b88 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6722,6 +6722,13 @@ sub process { } } =20 +# check for context_unsafe without a comment. + if ($line =3D~ /\bcontext_unsafe\b/ && + !ctx_has_comment($first_line, $linenr)) { + WARN("CONTEXT_UNSAFE", + "context_unsafe without comment\n" . $herecurr); + } + # check of hardware specific defines if ($line =3D~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x= __)\b@ && $realfile !~ m@include/asm-@) { CHK("ARCH_DEFINES", --=20 2.52.0.rc1.455.g30608eb744-goog