Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5466987imm; Sun, 26 Aug 2018 21:06:02 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbrUuVFoELleyPJY9EUp963mwGytic679miTBXb2lQg7/5iezxjl/oLxJPkaXP7td/piNnC X-Received: by 2002:a65:5b86:: with SMTP id i6-v6mr10661099pgr.120.1535342762033; Sun, 26 Aug 2018 21:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535342762; cv=none; d=google.com; s=arc-20160816; b=I/9FPw9tF1KRYUtaG8HwjwHtx2X4rzF2PpwVc2Dth0BnNvoduTX5XHxkedgUOwTfg7 oxaVtG9NA7q5pCfabZRrAPFv7Lwf5abJy3VpaQPCco34RIP38/LKtZd9RY1+FosEYQ16 cZghJwrhNz0f/GIB4XkKNs6xzh74LXu6ppmHcusFE9JFyXdX7jGbHdbIFTb68PQHwfrF RHAgQLPP3ZF+ZmNWpRqYwbjqBZ3+8z8UL24SMCk5WWz8cOJjYLotDFw7FfXASMf0Bfxp 5lRn5iWVz3h62N4xvcp13dI58007xkJqy/13LuOg2osfxEQk+U0xXJt3prRiLl7wJb91 dDOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=c4SJJPp2aip+sxxjKpINKk0BmdpmAycJnS1o6HNR8Mg=; b=CyGiCJzRywhXnlMzxp/uWYgCDTVWeH8LJfHAbgu03HFTnvyypYn2jPYiquo/JvZcm+ InACovHcM8uhaU0m9VgaxUIgS5OwGiF8ls2LQ7BiUYfkJOaIVu47nkwROPgcsQxA8AVx Jg6WCeHX+IDZalpFOxo4rPyqERrc4JVyt8aTAUTUTmMVUmrOdcQ0L5QAXr6n2u6x5SZJ RWTjKqsp+wnw4zDXaLVtv4XRwnZfCgyWeKALi1wpCKO3KOj3c6dIVKnoHT6pm+jG86PT NKRyo8ORc3q4iCQvU9xgSMZuPaU4Mps6+kADbJyNOb9kHjOYDjsWB36S7XlPq0mMY5fi 0yzA== ARC-Authentication-Results: i=1; mx.google.com; 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 g12-v6si12878673plt.259.2018.08.26.21.05.46; Sun, 26 Aug 2018 21:06:01 -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; 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 S1727014AbeH0HtT (ORCPT + 99 others); Mon, 27 Aug 2018 03:49:19 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:44358 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbeH0HtS (ORCPT ); Mon, 27 Aug 2018 03:49:18 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fu8lL-0002mA-Pu; Mon, 27 Aug 2018 04:04:23 +0000 Date: Mon, 27 Aug 2018 05:04:23 +0100 From: Al Viro To: Julia Lawall Cc: Joe Perches , Kees Cook , LKML , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Network Development Subject: Re: [PATCH] net: sched: Fix memory exposure from short TCA_U32_SEL Message-ID: <20180827040423.GB6515@ZenIV.linux.org.uk> References: <20180826061534.GT6515@ZenIV.linux.org.uk> <20180826173236.GU6515@ZenIV.linux.org.uk> <20180826212421.GW6515@ZenIV.linux.org.uk> <20180826224322.GX6515@ZenIV.linux.org.uk> <20180827023526.GA6515@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 26, 2018 at 11:35:17PM -0400, Julia Lawall wrote: > * x = \(kmalloc\|kzalloc\|devm_kmalloc\|devm_kzalloc\)(...) I can name several you've missed right off the top of my head - vmalloc, kvmalloc, kmem_cache_alloc, kmem_cache_zalloc, variants with _trace slapped on, and that is not to mention the things like get_free_page or void *my_k3wl_alloc(u64 n) // 'cause all artificial limits suck, that's why { lots and lots of home-grown stats collection some tracepoints thrown in just for fun return kmalloc(n); } (and no, I'm not implying that net/sched folks had done anything of that sort; I have seen that and worse in drivers, though) > The * at the beginning of the line means to highlight what you are looking > for, which is done by making a diff in which the highlighted line > appears to be removed. Umm... Does that cover return, BTW? Or something like T *barf; extern void foo(T *p); foo(kmalloc(sizeof(*barf))); > The limitation is the ability to figure out the type of x. If it is a > local variable, Coccinelle should have no problem. If it is a structure > field, it may be necessary to provide command line arguments like > > --all-includes --include-headers-for-types > > --all-includes means to try to find all include files that are mentioned > in the .c file. The next stronger option is --recursive includes, which > means include what all of the mentioned files include as well, > recursively. This tends to cause a major performance hit, because a lot > of code is being parsed. --include-headers-for-types heals a bit with > that, as it only considers the header files when computing type > information, and now when applying the rules. > > With respect to ifdefs around variable declarations and structure field > declaration, in these cases Coccinelle considers that it cannot make the > ifdef have an if-like control flow, and so if considers the #ifdef, #else > and #endif to be comments. Thus it takes into account only the last type > provided for a given variable. [snip] What about several variants of structure definition? Because ifdefs around includes do occur in the wild...