From patchwork Wed May 18 01:41:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 1514 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:52:39 -0000 Delivered-To: patches@linaro.org Received: by 10.224.54.134 with SMTP id q6cs52493qag; Tue, 17 May 2011 18:41:19 -0700 (PDT) Received: by 10.91.145.6 with SMTP id x6mr929882agn.152.1305682878721; Tue, 17 May 2011 18:41:18 -0700 (PDT) Received: from e5.ny.us.ibm.com (e5.ny.us.ibm.com [32.97.182.145]) by mx.google.com with ESMTPS id d20si2341474ano.3.2011.05.17.18.41.17 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 May 2011 18:41:17 -0700 (PDT) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.145 as permitted sender) client-ip=32.97.182.145; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.145 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e5.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4I1EHlt028875; Tue, 17 May 2011 21:14:18 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4I1fFwO127840; Tue, 17 May 2011 21:41:15 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4I1fEvu011467; Tue, 17 May 2011 21:41:15 -0400 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4I1fEI7011464; Tue, 17 May 2011 21:41:14 -0400 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 0834B1E7512; Tue, 17 May 2011 18:41:14 -0700 (PDT) From: John Stultz To: LKML Cc: John Stultz , Joe Perches , Michal Nazarewicz , Andy Whitcroft , Jiri Slaby , KOSAKI Motohiro , David Rientjes , Dave Hansen , Andrew Morton , linux-mm@kvack.org Subject: [PATCH 4/4] checkpatch.pl: Add check for task comm references Date: Tue, 17 May 2011 18:41:05 -0700 Message-Id: <1305682865-27111-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1305682865-27111-1-git-send-email-john.stultz@linaro.org> References: <1305682865-27111-1-git-send-email-john.stultz@linaro.org> Now that accessing current->comm needs to be protected, avoid new current->comm or other task->comm usage by adding a warning to checkpatch.pl. Fair warning: I know zero perl, so this was written in the style of "monkey see, monkey do". It does appear to work in my testing though. Thanks to Jiri Slaby, Michal Nazarewicz and Joe Perches for help improving the regex! Close review and feedback would be appreciated. CC: Joe Perches CC: Michal Nazarewicz CC: Andy Whitcroft CC: Jiri Slaby CC: KOSAKI Motohiro CC: David Rientjes CC: Dave Hansen CC: Andrew Morton CC: linux-mm@kvack.org Signed-off-by: John Stultz --- scripts/checkpatch.pl | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d867081..a16ded7 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2868,6 +2868,12 @@ sub process { WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); } +# check for current->comm usage + my $comm_vars = qr/current|tsk|p|task|curr|t|me/; + if ($line =~ /\b$comm_vars\s*->\s*comm\b/) { + WARN("task comm access needs to be protected. Use get_task_comm, or printk's \%ptc formatting.\n" . $herecurr); + } + # check for %L{u,d,i} in strings my $string; while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {