From patchwork Fri Dec 15 00:14:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 178979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8940393dys; Thu, 14 Dec 2023 16:15:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIst8ejq1iNXEqQgurJjdoCFHdPY4eDSzfCvW+VNud9u7mhHInPTNZgh3zVPY1BvA4PpJa X-Received: by 2002:a05:6a20:3d1e:b0:18f:d144:2636 with SMTP id y30-20020a056a203d1e00b0018fd1442636mr5755784pzi.59.1702599313777; Thu, 14 Dec 2023 16:15:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702599313; cv=none; d=google.com; s=arc-20160816; b=Jvlr5iKcJnGok0xaoEgKE6zXJGIqZITVAep/tlFGbk4Ml9OEFQoiANRgTz1RTfEE6Z Vang1IkrKuMyglGEv7LMjME2cl/AcuSYb7rySolgvfJfecavExT7MEUc4uxXO9iSk2Hu D9cFIT1iTM5bge//iz8MSMl9vkEzg1YFJtvUJ3C+nGnXm6bP7+EX+WlhlBFgsO9SQMIu bypTwD3QwtDSk5KSu2DPhiCxDCI3AY9xi3kYqoaUGzuk8u+tm+IYf1Fhjo/yROUYz+Ji 8+hwSiHEW/mNAlLzIVgWpK5kCZlpi3EQYcYtih2WZlSaGXKrx2/02e7LMS8wX2bXMDpC SILA== ARC-Message-Signature: i=1; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=ev3Eb+ZV85HTlWtAyzOBUHGpbBJx18XoGsZ8JgWiqC8=; fh=IwsDDw4cI++qKV55VWdUeZ4ZhCgc3XoeixFhWqkK50c=; b=0WHX5yTIecCd0ioOKNMWXOJ1vMBtnOIwLfEd6COkNBnt65xLvLmfmFFBCilGp/KKW4 h8UhtCMYvHbNwsbjlilqhh5D2npzojWWfpupF7N9rGm0/rr+SoOmemeVnqnotYe2TJyY RYbetd9TPXtk3cmXPaIMiLdvK6QH/7Ec5omjgT1+Njqyi1WyZYmzcS0mCfWTVe0Rmxud gWK6oVJkksT6qed1v0kqctvQ8Sp52LBxnmlVzQBHA0bXsf7wEJu5IzhZXeLBizcaqxUC MumGcO6AET579DRzGvEm25A06yJXETk/snu4srlHlMlfLJPpYxQ8EIwo6ol/dNQUSgxN 95lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QpluNX1F; spf=pass (google.com: domain of linux-kernel+bounces-278-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-278-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x31-20020a17090a6c2200b002868d3e1ab4si3695447pjj.170.2023.12.14.16.15.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 16:15:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-278-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QpluNX1F; spf=pass (google.com: domain of linux-kernel+bounces-278-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-278-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8A959283B5F for ; Fri, 15 Dec 2023 00:15:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 976DA63CC; Fri, 15 Dec 2023 00:15:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="QpluNX1F" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 E0D1F538A for ; Fri, 15 Dec 2023 00:14:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1d2f1cecf89so174265ad.1 for ; Thu, 14 Dec 2023 16:14:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702599295; x=1703204095; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ev3Eb+ZV85HTlWtAyzOBUHGpbBJx18XoGsZ8JgWiqC8=; b=QpluNX1FlvOioywUAbxINcLZzpOwHBPA96hPaBjGxXe9xA/LyK27sWz745302R5mpK HwZgMNnSdhS0UBn2lGwqAaEvpmIxObANQc8f0sIh/Bw2aqIOuyxHiMrovr+dstkMc2Ot eBNxeyquluuSPRnq01gbUFEj7NK5Wv1J3bVX0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702599295; x=1703204095; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ev3Eb+ZV85HTlWtAyzOBUHGpbBJx18XoGsZ8JgWiqC8=; b=LjsnsBsCM+s1qLkvAo7YTf13Zme/pXH0sspgXLf8TtfdCnVeOkuYlqvXN/T/zaePaD Ite2T5VXzPotBgPlol1BBDuIiaLLprpIHQqPWIA/qGzcZRNKiUJnM7PriHyHGhLMTcq4 TWbXGwfUDJTQCZc5wuP5DBoqlXANq2E9Yj/ckqfcNXHXm8hUcnWVDsKIgS0HjTq4A3CA eng98dxcuXH0zxEqgUO4+EF0l0cNXPdhKi7C6RumA2Y9vIKmBTifNb1Bjf2tuu5FOZZA 6N5PysnDVc2MhB4IW7VpLGZndh+yY1dHkR/xBByw1Zn1Op/DUZ+wJcCuw1vAD5e4FR/n rHcQ== X-Gm-Message-State: AOJu0YxhDmn7rMqQZiUwpOzhQje3qaEnshxs6hOVJn6/1Xm01KSd1dOB fpyUUe9opiccUOJVniYR99831w== X-Received: by 2002:a17:903:2303:b0:1d0:ab57:2483 with SMTP id d3-20020a170903230300b001d0ab572483mr6164845plh.98.1702599295303; Thu, 14 Dec 2023 16:14:55 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id d17-20020a170902c19100b001d352a496c1sm3668670pld.295.2023.12.14.16.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 16:14:54 -0800 (PST) From: Kees Cook To: Jonathan Corbet Cc: Kees Cook , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] scripts: kernel-doc: Report excess struct member descriptions Date: Thu, 14 Dec 2023 16:14:51 -0800 Message-Id: <20231215001451.work.746-kees@kernel.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1274; i=keescook@chromium.org; h=from:subject:message-id; bh=DsKC5d7CSbsFqjMtjY54c7l6d4gHSd5eMJH8lGLCILM=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBle5p7kFwcR+6Zr4eXM4A9sR0wpYZoCKJVSj19A HKrKcGjPuOJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZXuaewAKCRCJcvTf3G3A JglID/926jj/4/4MRA201XHEL8z/RFF8dzGN29wtLTO7VSlu16zXONJ1cFL3O78lCO6+aoL+p6D LiEdBfm+eWgzO/3A4CGt7W6GEg0P6Bi9kav1WUNN5TjH/qtIIWFEqTKqM+vCI6/8UPNLnvm4uwU AWPWhX3O0mVD7Exw08YroCwrLHprq9+7UKYHBiayW3JTjflXYgM8RB3jeNuI7vtL7sOS21xrT8Q IxrS9H8lfe0K8HItfd8op6dKQFFN9Oi0pPsIavOUbQNeqM2kwNnwi0zBFzDd1MYU2YkuHUuzkYO qlQ9oMJSu0nQcalKsQtjSa8GGIv6LN3vXJilmj8t7p2pjiCsLsavB+YeOATwJFL2+hsRfo07dCa aGpvqffvjjwrUwp8DMc/TAeEeQIuwa21YspBGUbYcOpKvGDqDzFa3bN/wQCSlxwem5qpwc3RpCl fdD1olKKBacbx5Hov+E64bJtnggvkd+eWFik12U5tjc5bdFilwyif4gooVbSgCPvLZWpxbm6Rs3 CsQcnbhZFyKp95brTHhhva22cMZ4Px02g9YnhADZ8LuiCzJcHM1LSH9bly/znIAsF1wosVwJ5tw 6f2W/EPWowJKm6Kd2jZmtz9T2E9zSHAVdxKe6wr58QzQv17SzgCjs1R1LOkXzL7klYskCj5QS4r c0PI/rD 11T39bbQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785304777677589609 X-GMAIL-MSGID: 1785304777677589609 While missing descriptions were already be reported, missing struct members were not. For example, previously this output was empty, but now produces: $ ./scripts/kernel-doc -none ./drivers/leds/leds-mlxreg.c ./drivers/leds/leds-mlxreg.c:42: warning: Excess struct member 'led_data' description in 'mlxreg_led_data' Cc: Jonathan Corbet Cc: linux-doc@vger.kernel.org Signed-off-by: Kees Cook --- scripts/kernel-doc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 08a3e603db19..39e730ee1fef 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -1265,6 +1265,18 @@ sub dump_struct($$) { $declaration .= "\t" . $clause . "\n"; $level++ if ($clause =~ m/(\{)/ && !($clause =~m/\}/)); } + + my %_members; + $_members{$_}++ for (@parameterlist); + + while (my ($k, $v) = each %parameterdescs) { + if (!exists($_members{$k})) { + if (show_warnings("struct", $declaration_name)) { + emit_warning("${file}:$.", "Excess struct member '$k' description in '$declaration_name'\n"); + } + } + } + output_declaration($declaration_name, 'struct', {'struct' => $declaration_name,