From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.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 9FD551DF755 for ; Thu, 6 Feb 2025 18:18:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738865885; cv=none; b=tHVEZLmPCE87fE0zS7auA92o2/5Ei5jNwF/RLWxLLh0mJfn/a0szfVoa2Xe4i2hs4TXUwWwLmPPD9zp9jeF9IVhPZNFMUeqstJ/NJaw4eESwF1lreNxZwbKLUUvBDPs4av4V9XJ1n6LMdwm55snK83hKjmVW6OAUFLccoQhvScc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738865885; c=relaxed/simple; bh=OUyhDVr77oUg9Ew94dbfOaYtUgHMDOjvOzaZtS/8oZ4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=t1R6bfy6YnJZhNpS47vwsc3wo89rLM2w13aLD8dI/lx57OgHbHHLXIBAJS00N0U8AKNJTkjiz1wQ0MpKh29YZsSphwEZRJGwmCRff8PoJ9cGvJqVyemBrcpMxSF91VWyYrq2GtriaXZH7DcQJf60BHkFKsJ1myeLdQRTn7cBzL8= 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=0hcj8l/T; arc=none smtp.client-ip=209.85.128.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="0hcj8l/T" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-43646b453bcso6967715e9.3 for ; Thu, 06 Feb 2025 10:18:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738865881; x=1739470681; 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=VsoCl0Fwo1Ic1mnwHNM6zvZdMp3PVmxgZxLwt6H7/D4=; b=0hcj8l/TOaR1EMaKNPXgp9YdbAIYtqzDTOttid9xHzHslu2vxtB/JgxgWGs26Lxyy+ fIKang+GDGs2b3mU9AB0mudlU/KdSD9VqTHgwFP0TLfJNTr+BFmW6Bjl0ByY/NfQ6pLt KSMwdA+GPjfF0Z+h/u2Ho8wRDQdCuUKSz1wCv/1S99bTQ27mcqNwa+Pejiy3jedjPP8g lcwpRpRatjFh5Z9D0ZUdgovL6ghgak6iwJ66fkMi4xg1mzmvzsCJjMIfcb6COiOMaKvP aNKWEmrrdf+Ac264lAwWPr8JCd+jaQON1K4QVws3D5zGvwIc2eCD54Y9jlywGWHbsykF hlGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738865881; x=1739470681; 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=VsoCl0Fwo1Ic1mnwHNM6zvZdMp3PVmxgZxLwt6H7/D4=; b=fi4CpYOGMljKC6KGMgXDqf0RnxcX47RhsoOLG2o0qZXPAbJOwH3AZSMaKKxYlKCoSS zyTKVlskAKWVviAdDVwbc0y248rj1/hS7PwE3eOLKSbeaIKjB0g5OSckpM1ECUcRqfFk YNe2rOXkRuE34MKLc+mRkV9XFJo06XYyboZo3NnQuaDtjGQo0T9400YtOMp3Yhd3Jh2z pMzOm8RWaL1D5cPZm9x2rJRTR10TyAyRHghwPHDGpGF2s9PoRQrgol+EUl2sPsmiswwF tovY0dHHBXDH3BE5rl/8DSr4I9T8MzeMSLDJXcmTZEh3KvlHXkhBjfPwICutDQy6CN3o KxRg== X-Forwarded-Encrypted: i=1; AJvYcCXbxhJwfboQ4h4ZqbU7zufsfvzBWEuvl0Xz2WBw0kBNRzoIjlPJcJ5mgOotpAcCm7l0IpS+@lists.linux.dev X-Gm-Message-State: AOJu0Yx8rAhgLSQYVMQ/7F9c2dVINjOhIVW6Cbu1HBAKXT4wZ+1rojWs m7K6kIdG9msaj4gNtVzsvqBe7WFcHA+WXlvDDz8uLnk0Qvd54QR4vNuNsxhZFVGRC7+pDc3egA= = X-Google-Smtp-Source: AGHT+IHiTmn6vfthg2vhJ36+4kRebwXf2RJ94SpIllvtOjA4FgWz+fAElpnxs8wxYNVNWceG+v5BwvdraA== X-Received: from wmbeq14.prod.google.com ([2002:a05:600c:848e:b0:434:e9e2:2991]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4e15:b0:434:ff9d:a370 with SMTP id 5b1f17b1804b1-439248c34e9mr5139685e9.0.1738865881193; Thu, 06 Feb 2025 10:18:01 -0800 (PST) Date: Thu, 6 Feb 2025 19:10:00 +0100 In-Reply-To: <20250206181711.1902989-1-elver@google.com> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250206181711.1902989-1-elver@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Message-ID: <20250206181711.1902989-7-elver@google.com> Subject: [PATCH RFC 06/24] checkpatch: Warn about capability_unsafe() without comment From: Marco Elver To: elver@google.com Cc: "Paul E. McKenney" , Alexander Potapenko , Bart Van Assche , Bill Wendling , Boqun Feng , Dmitry Vyukov , Frederic Weisbecker , Greg Kroah-Hartman , Ingo Molnar , Jann Horn , Joel Fernandes , Jonathan Corbet , Josh Triplett , Justin Stitt , Kees Cook , Mark Rutland , Mathieu Desnoyers , Miguel Ojeda , Nathan Chancellor , Neeraj Upadhyay , Nick Desaulniers , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Uladzislau Rezki , Waiman Long , Will Deacon , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, rcu@vger.kernel.org, linux-crypto@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Warn about applications of capability_unsafe() without a comment, to encourage documenting the reasoning behind why it was deemed safe. Signed-off-by: Marco Elver --- scripts/checkpatch.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7b28ad331742..c28efdb1d404 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6693,6 +6693,14 @@ sub process { } } +# check for capability_unsafe without a comment. + if ($line =~ /\bcapability_unsafe\b/) { + if (!ctx_has_comment($first_line, $linenr)) { + WARN("CAPABILITY_UNSAFE", + "capability_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.48.1.502.g6dc24dfdaf-goog