Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) (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 041FE2E1EFD for ; Thu, 20 Nov 2025 15:03:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763650987; cv=none; b=eMv8qd43/zQMLQ3TZRs63OhD2IY6qR52oy6AGOKNPCUu6srFaKd8KjO7gG2/Sg+ronMNsbQJ217YQCsLyALU3+T0UoRB/9fkqFW8IgwqoXehaVGChRUfoSdypBp1ffGyDZqCVPaeISgI64AzSOJ6dp7xNIlDCNKmlrfUBd4s2wI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763650987; c=relaxed/simple; bh=tTGjUHrfXR5isY+lSEFNNwASkyVwRARVzePML9vCCTo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OfrxLHF/1FFAiPSlLVAiAPii1nuUbLTUEXudgq3g2q3njsiT2zWB6y1L/gZQVFRsi+GWSGcnv56N9JKUFg4esukagerzyxpD71r+cC+NJ9aN8EhtTnvUn6iBVUoDV22QDetRFNTFuceKSEnOCrIx4ooa89lV1Prruuqukr/mSng= 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=vhbCjJvF; arc=none smtp.client-ip=209.85.208.74 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="vhbCjJvF" Received: by mail-ed1-f74.google.com with SMTP id 4fb4d7f45d1cf-64165abd7ffso1295537a12.0 for ; Thu, 20 Nov 2025 07:03:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763650979; x=1764255779; darn=lists.linux.dev; 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=vhbCjJvFvcDIeAsPwwfm9jEUQ9JO3R+HNL0dBJ0RFOPW8opS9Hwi+apXo4yttuzXEt U3ZUxAOVKfUoatPKnvS5YNiYbhpwLfZr4Z15eP4WEwvPtHJQyojx28FgqzVVB/8Z9uDw KKvKEDIngObLViUiZXLTeqmZnoZmXUlvWq1ATEaMUygziJjuht0UOLNthfhmOa+bRG9p k5+PImj6MgmebjkmuiGuxiRR/C/nOOQieRWsshsWf0rfcbvEmzdVpmK8uwq1PSJbPpUo c3tUQgIjZ+8nJ38qsMy5JgktVPLG5Z1+tTCVy82ofS2DVWrFI8jHtNA/F9pas/h1AlL9 f/HQ== 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=GocFFz72BzIUEVDTogIzVqB4eFAPquutUhpiafCnY1kUs/3qwgSJkeyndbI4h7RdnP MTyBZ25UJCg/1IZFvTxQhBDZCqWx43T/8iTjxpoxPKUxaEYvwu40006nlAHIbxjy+GMr 8YcNEa0kSGqmNGpkHzMuUUKyYr7YC/Sa5VWkCAXT6032pPpdbqKpj9xLaBauEuVSl5Ro Vsy+S04O0YUi/VCEK9StJr8Mp93db4LA/pj8VdTm17eHlLfYELX0GN5e22Ky6off41Gj Zug324jhQ8UR2gus+aiqTkcE7YFica5KMIP6Olm6+mwQoJ9BpNATYlwcjPI5KtxmhvEq c/+A== X-Forwarded-Encrypted: i=1; AJvYcCUWzte15tUYPRTEK3gJD1UWBpBs4dF4BwdHsMgjXjxJ5iNJ/dHQs0dc4WBR3/lVvsvEiGln@lists.linux.dev X-Gm-Message-State: AOJu0YyROx/MpUFn/vF9MZPhuLHd92ldtC5ErbFdNYxxkS3uli6msHzV ZXgiJ5DQ+7Wn3QE+U8nmQmeuvb6kRIqJ4tfrFB3iIM8j60rMy2zN6Vm5TTtp2VWpnZOWND7QtwA Iyw== 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: llvm@lists.linux.dev 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-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 { } } +# check for context_unsafe without a comment. + if ($line =~ /\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 =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) { CHK("ARCH_DEFINES", -- 2.52.0.rc1.455.g30608eb744-goog