Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp720613ybt; Wed, 17 Jun 2020 12:08:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8ivjf7vjIkiOIo5FL9tGFC0iEG09Jcw6OD0qiSqRXQa+x+Z1AVUXzFY1QO7K19wttXHIF X-Received: by 2002:a17:906:aad8:: with SMTP id kt24mr544143ejb.527.1592420920126; Wed, 17 Jun 2020 12:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592420920; cv=none; d=google.com; s=arc-20160816; b=sFn2hirJuntKIiI/JhM91prCmH5BsZZ1WHKvH+f1ZYGJjQsCby43abHP+0/4ADVjvT /8djv/OdOBELhuTgU09ZKFPNqEGrXOnv36pIKFlNuehGUuh8OhebMImM/rGZY5bM64Hx 6sxnKQ+8e5FTTESR8fDRBqbOyIuMTeJWwAQVCqSymZUGM4iWoAxGYNHfPQWg7Qlr5l+0 +m/1ccFeYIIiXJfQkQXOyLqjYiU2kMgr6LUWqAfsQ1HLhSV7+DaVIAB0rE75DmYBjJPs oWt9807aOvcYbu1fy/4BI4svQEd1APqxLjrho/qeJc01K5s8NOuNL3QB83lCeNsk0Wjo b4SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=RdqXevPl9uJkE3HCx2/ZTZ7Vh1kelDtYj8huy4vkv0A=; b=nun6MEQ48OLHBszXPeuH+ncAVR0DF2kP7uRmg/K3Wk0fYArPeA3q0SIpa8WZUDzCe9 UtTslvI3BZu1KS6RMbNg21CQAUM7adBE23AWNr6SWLTDwe/2DZdevDBym8OmGyZ/W7hL NX5x/xpRnnyb0QBv4mV84SYV+j0sVRm70Gaook7KeBm76RdCtFkvcc6M+fig4Q7okg3+ T0nB4m7DMXtPFIF8RBVXIU6aMob+YEm3UChInvZLpPSIKZzZMkpUDcR5WLMSAevTsjx7 pKLuKd7yLILtjL0sobdC7hk9phZtmvD9Iwch6Ongxg2URYjo3N1qoscB+BITToaHMvS8 mUIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SdUds60V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o21si423111ejx.500.2020.06.17.12.08.17; Wed, 17 Jun 2020 12:08:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SdUds60V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726980AbgFQSPJ (ORCPT + 99 others); Wed, 17 Jun 2020 14:15:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726883AbgFQSPI (ORCPT ); Wed, 17 Jun 2020 14:15:08 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EF50C06174E for ; Wed, 17 Jun 2020 11:15:08 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id g12so1300288pll.10 for ; Wed, 17 Jun 2020 11:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=RdqXevPl9uJkE3HCx2/ZTZ7Vh1kelDtYj8huy4vkv0A=; b=SdUds60VPFAsN4bvveQ4jp5InHf0ZUUz99xRZhRp+41UMQMhVcoiKwCBGDJIHZscBK lx55XnwUC1mpIChq7Ak6UivUmeED3KnMSVgfzqfMaYH+MWJtecnmKZJZJc4BiMoRn0wU Amjjdv31jrGXmKUOkF/93WsA6oExSqQUwhLVw= 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:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RdqXevPl9uJkE3HCx2/ZTZ7Vh1kelDtYj8huy4vkv0A=; b=fT+aIIbaU/Jk0uqkTKaxDF3pussEZC6eHgy7zNp+Izzj/nHkDRiu6oJx0kHsb8wqcr 4X7sA2arQUC8IKtvDZAEtCiYhs3ksUocNGKx2/NMbfMKegePI6L2HZIhdBZJD63cfknz ERCmVwGDfgR4EOnDMQXx5oSPmkrZtGsIwWXb6lAuNsttPb6zuKj8Ud1SRzVHNec9+a7m /xswlLFutWvGH7/tv9YbRdy3ngQ1s4UJmFh0cIwfL4XHr2I5r9tRav3tt6Kt7h39MM4A DEDzNfffhD8u4j9tlqFLZdgJOKoy24E/aY8J/KIdNaLanAxtkoOSGzIaeZh+WOL1Kb5b KKGQ== X-Gm-Message-State: AOAM532wJNGoHmlqZ8h9pwGrbPWqQbxNjQxV3yX7XnH1LQ0EIL/8/awv ZUuYSboM43LCxYohIoQR+fJ+BhH0AiE= X-Received: by 2002:a17:90a:7c48:: with SMTP id e8mr264393pjl.235.1592417707785; Wed, 17 Jun 2020 11:15:07 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id m22sm498891pfk.216.2020.06.17.11.15.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 11:15:06 -0700 (PDT) Date: Wed, 17 Jun 2020 11:15:05 -0700 From: Kees Cook To: Julia Lawall Cc: cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, Denis Efremov , "Gustavo A. R. Silva" Subject: Re: [PATCH] coccinelle: misc: add array_size_dup script to detect missed overlow checks Message-ID: <202006171103.327F86B1C@keescook> References: <20200615102045.4558-1-efremov@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200615102045.4558-1-efremov@linux.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 15, 2020 at 01:20:45PM +0300, Denis Efremov wrote: > +@as@ > +expression E1, E2; > +@@ > + > +array_size(E1, E2) BTW, is there a way yet in Coccinelle to match a fully qualified (?) identifier? For example, if I have two lines in C: A) array_size(variable, 5); B) array_size(instance->member.size, 5); C) array_size(instance->member.size + 1, 5); D) array_size(function_call(variable), 5); This matches A, B, C, and D: @@ expression ARG1; expression ARG2; @@ array_size(ARG1, ARG2); This matches only A: @@ identifier ARG1; expression ARG2; @@ array_size(ARG1, ARG2); How do I get something to match A and B but not C and D (i.e. I do not want to match any operations, function calls, etc, only a variable, which may be identified through dereference, array index, or struct member access.) -- Kees Cook