From patchwork Tue May 17 20:47:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 1509 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:37 -0000 Delivered-To: patches@linaro.org Received: by 10.224.61.3 with SMTP id r3cs32833qah; Tue, 17 May 2011 13:47:56 -0700 (PDT) Received: by 10.91.63.8 with SMTP id q8mr821959agk.80.1305665275829; Tue, 17 May 2011 13:47:55 -0700 (PDT) Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx.google.com with ESMTPS id x38si1922541anx.134.2011.05.17.13.47.54 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 May 2011 13:47:54 -0700 (PDT) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.159 as permitted sender) client-ip=32.97.110.159; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.159 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e38.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4HKdlkO003154; Tue, 17 May 2011 14:39:47 -0600 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id p4HKlnnY148858; Tue, 17 May 2011 14:47:49 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4HKlmro003452; Tue, 17 May 2011 14:47:49 -0600 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4HKlmw5003428; Tue, 17 May 2011 14:47:48 -0600 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 026001E7511; Tue, 17 May 2011 13:47:47 -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 3/3] checkpatch.pl: Add check for task comm references Date: Tue, 17 May 2011 13:47:43 -0700 Message-Id: <1305665263-20933-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1305665263-20933-1-git-send-email-john.stultz@linaro.org> References: <1305665263-20933-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 | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d867081..a67ea69 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2868,6 +2868,13 @@ 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 + our $common_comm_vars = qr{(?x: + current|tsk|p|task|curr|chip|t|object|me + )}; + if ($line =~ /\b($common_comm_vars)\s*->\s*comm\b/) { + WARN("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) {