Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1323777imm; Wed, 10 Oct 2018 12:39:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV63jkSzQtwokcAomQrtWGHD99gHqCsPqf5OQXJSpbTA5m/g5zGRNtLeQvAO+XNx0qO/4+1b5 X-Received: by 2002:a63:f347:: with SMTP id t7-v6mr30380739pgj.255.1539200389005; Wed, 10 Oct 2018 12:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539200388; cv=none; d=google.com; s=arc-20160816; b=ChBGH14TD/W7PK4vM2tpeIZX+hKBejeh0EnbyL8yg72p04pBE4BZ4P7b9VXOcTfBq+ vDu1xNmezKN477b5ERaRqco04yLHygg0JPnOtzdWP3KtZvM8d6RQ58kCqkh09jSqr88M yVFk8qsG4veaoAoZQkjPi0Pw7k8krK4AE3JPPgOEIfYNg/W+jAeZu4QKUeiJUqDPf3G9 RJ0GXZoLuoWLp0ZUeii1pMsqssc2ElWK7nMByv2Tc3hlec9vZI7G25Mh1+F0qt5PLfZ+ 1Z4G8PP4u3jRA3AEBTyTOv7dah9ESV9pG7U8UgClidS0y64XtPNhvGUPxRV3jvY8b64Q XWGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date:dkim-signature; bh=M2w2XblAESyeqU/73xyqGeI6nGSYi06KzgHwKcVbWtM=; b=ADqpO46J4zRP/10/VxB8YcCDBorQTNViwOsH7jD/J4WXjr99gmM1rhw7uRY1cmkGCO g75eibp2l0uRKjqmQxWx+qmxiKMwxCDlg3s1tilhpmIHQ82bEWQrd6ZZbw+hTCKSwekb e5s0k5o83YoGR7q+Pkm7WDfv88ynmtKlvbc1PVFe4CIDgLaoS/5j87QajGqK8gsM2YqP AvGIDmHCoXsJeKVYaAHTveeebgK8uwMpbcs5l1zMcml5oR17eSAOrZ6goXLiBlxtM+Hk RD/WRSv8CrIupn50EUjznzpNGyxgoeJmURk47Ou5pMN9hUHYqcRlTEnf8909sP+etRpj qCOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=Rcm19+Fj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2-v6si24433844pgb.247.2018.10.10.12.39.33; Wed, 10 Oct 2018 12:39:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=Rcm19+Fj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727503AbeJKDCf (ORCPT + 99 others); Wed, 10 Oct 2018 23:02:35 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38742 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbeJKDCf (ORCPT ); Wed, 10 Oct 2018 23:02:35 -0400 Received: by mail-pf1-f194.google.com with SMTP id f29-v6so3138783pff.5 for ; Wed, 10 Oct 2018 12:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=M2w2XblAESyeqU/73xyqGeI6nGSYi06KzgHwKcVbWtM=; b=Rcm19+Fj60SaHqTaNahXjW9wSZMxY1sakAoyABlN8pwsKv5ioTZuBvyoRWL9d89d4E j3E1c2nSoC9d1s6heB5OIBa9wJt/3WONheHatFI2+rx7nbgX9qW+Q9ELXig0FYDIiywQ kmjQBtvZHV/Sf/dVb8rdBKu9TE1WtNr3YofXQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=M2w2XblAESyeqU/73xyqGeI6nGSYi06KzgHwKcVbWtM=; b=JVD2hFymncYpROJ7QonUJNfYdx8YOBZADgsm27FmuHuOlzuKM/FxtePe1sR4+qWneJ LxCopd3IZvYnfS7P4x7YOeUgkw1JBmNeBsT2L5eK6raYVWvz23FSXcea1uHLWteOffgN 01hJlGOBH6ooKFlgN3EZTdxfpI1kQNd+fGyTaM16+LRaaVFzd21Z9CAGOgXGZOoOlcNj xUz0ITz0OFZvxVcnkz0XOBjkyho6MgvvlChUiB6GlaPvR5NOllLoI8tWdFCUhbPrMjfJ APdzGHYU1UJKuROu55FzFUqfy/8X4pwCqQTgHmrp3hR/KkgdlTJO1odae6cjlJBtft/z NxXQ== X-Gm-Message-State: ABuFfoiqC/GnAykZjf+eMgF4poTHuiOAaAH3Z9x9gdVHv3crvdVToEIS 4QITNOWPWNtvMazmOffGco2fT6cm90g= X-Received: by 2002:a63:f5a:: with SMTP id 26-v6mr30821974pgp.100.1539200336325; Wed, 10 Oct 2018 12:38:56 -0700 (PDT) Received: from localhost ([2620:0:1000:1601:3aef:314f:b9ea:889f]) by smtp.gmail.com with ESMTPSA id m10-v6sm24812308pgp.94.2018.10.10.12.38.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Oct 2018 12:38:55 -0700 (PDT) Date: Wed, 10 Oct 2018 12:38:54 -0700 From: Joel Fernandes To: linux-kernel@vger.kernel.org, Julia Lawall , Gilles Muller , Nicolas Palix , Michal Marek , cocci@systeme.lip6.fr, Kees Cook Subject: First coccinelle script, need some help. Message-ID: <20181010193854.GA93016@joelaf.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! I am trying to determine if a function argument is used across the whole kernel for a certain kernel function. I mustered up enough courage to write my first coccinelle script after a few late nights of reading up about it :) Here is .cocci script. I am trying to find if address is used at all in any possible definitions of pte_alloc(): $ cat ~/pte_alloc.cocci virtual report @pte_args depends on report@ identifier E1, E2; type T1, T2; position p; @@ pte_alloc@p(T1 E1, T2 E2) { ... ( ... E2 ... ) ... } @script:python depends on report@ p << pte_args.p; @@ coccilib.report.print_report(p[0], "WARNING: found definition of apte_alloc_one with address used in the body") The above warning does fire on the following test.c program: struct page *pte_alloc(struct mm_struct *mm, unsigned long address) { address++; if (condition()) { return NULL; } } But, *not* if I move 'address' into the if block: struct page *pte_alloc(struct mm_struct *mm, unsigned long address) { if (condition()) { address++; return NULL; } } I could not understand why, In my view the "address" expression should be matched across the function body even within if blocks. But if I move "address" into the if block, then the match doesn't occur any longer. My coccicheck command is as follow: make coccicheck COCCI=~/pte_alloc.cocci MODE=report M=test/test.c What am I missing? Thanks for any help. thanks, - Joel