Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1109698rdb; Sun, 1 Oct 2023 21:50:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3uWZeAiUDCim+oyLeGpsnPdhA3h7tYjlqS4+oFI2Y653OnkvZpzL6qICo7CN+sh8Pow2C X-Received: by 2002:a05:6870:a256:b0:1d5:b863:3a1f with SMTP id g22-20020a056870a25600b001d5b8633a1fmr9955021oai.7.1696222252825; Sun, 01 Oct 2023 21:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696222252; cv=none; d=google.com; s=arc-20160816; b=0nRhcr8UH4VODlxajs0wKhaTG/IGuE1KJlqVXWZPzrIlGir76cfrgE9e/m70TBFtfw 6p1uasJKf+zQWStMgD9jRQICFtgGBdnBlU1xFmkJ8454UAiTdZN3M7A7Qz6LiwvyRv94 4+poaZQSfQv9hctrqzwrRlJRh/z5Kfrj0uWXNdX4v8x/ZGgW6stRee1s2yRnSDbglxtJ st8gIWpCkLmWMnZND5PuebriDnR1XTGsR6kpHVwJWXNoMr/KBYn3vFoqAcmMAemrmbur oMLayCWG69maaUdl996H4zMQc9INaA9DpiIgQNrcsBK2wb3Q+pqmvOigtpBI+APGGnU5 IvPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0pqyiI3+7drkqtZIOt/nPWQvKqd+z/yppiMX4edx8e0=; fh=vzI13+Le9X4g6qIpJSxvbVRKWcrur6qfGmlImdnjChE=; b=nLDkF1XTqJxZ8axEoS84jEQm1HlxcPgX7wTk6mYbSDBlW8OAdpjPWBdBI4zlmK2Xgm 5Q6P9C+UyidbN2L5ofypGe0geaI7GZCoQtgxOcrE6n3nwxiW8VEuKPXCzshcwR6by7i/ pvtQ4h4CxEfdmKfbWainrEt7uMz09YodwAXBu7swJc7Xt7nbs3ONO1OuJCeivEa6iX2K GiaI2CJ3gydgyV1nHDbQImq2PxZ8JetY9502mZppjB2lS7IvqVQ1wdlojnWUPJh61CWZ KED7simZV+vhnGG8W8dbstUF/YsDzNHK7LTZvRTVWW2zTQwTbgi6s3N4nMSudR1xnyiW YNaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NDfAyqKt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o15-20020a656a4f000000b00584ac83e108si18231703pgu.729.2023.10.01.21.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 21:50:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NDfAyqKt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 06F5E8037719; Sun, 1 Oct 2023 15:22:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234289AbjJAWVf (ORCPT + 99 others); Sun, 1 Oct 2023 18:21:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjJAWVe (ORCPT ); Sun, 1 Oct 2023 18:21:34 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 338C0CE for ; Sun, 1 Oct 2023 15:21:31 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-69101022969so14348355b3a.3 for ; Sun, 01 Oct 2023 15:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696198890; x=1696803690; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=0pqyiI3+7drkqtZIOt/nPWQvKqd+z/yppiMX4edx8e0=; b=NDfAyqKtPqK4dieOW/2h7XgW879BvlK+Zs+BmgGEF2I3fiZNYTmR1iQI2w3z6Hv90s qW2AfUWgYRNNZyu4aMHnl43dZDH8EEFYHWe/mIEYp8P4Nu0aXUDFgFbLz6B7zqpzrsTH rbSicNfLts5ilJRxU+mBMaa9C/2syFmn3aBYI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696198890; x=1696803690; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0pqyiI3+7drkqtZIOt/nPWQvKqd+z/yppiMX4edx8e0=; b=lERP4Lb3b/wCawMxA8mORPn2pf5IVZ4GfOvTrgSwOYmBUNPGMjOencLjiXeHK46iVq At7JXfSsLpnqd5riWnHGjGMnGv3ku/JOF2ER/J65bPaKc4tz7K8/pqyQmSYH9XPFbeVN jkRpmK5wq/EKSXDFKEnR8TGXJBCjtxxsHKYAFBhn3Ei4tKMOPLZ7iYwo7vBIqWOuLjKR p1P+bhfTaydj12YFR8OdeYxYtqcyHDvZ1KPB69TDpWD+tsytSDtRQ3hXrHUAQymuv/Ng SMamZaj7ju/XKaJ0cQhm9lJve9KIHz7tlZhs4OhMW87uv+YkC9r14Q4N9muBapNaJvlX OAdQ== X-Gm-Message-State: AOJu0Yz6vIHl5xOHuxft5v3T2hAe/s1OwftokFgIfT7ybAGA0/3wpyxU QWKc1lvIkP05OuRds6ppc7bhWw== X-Received: by 2002:a05:6a00:852:b0:691:da6:47a with SMTP id q18-20020a056a00085200b006910da6047amr12630310pfk.31.1696198890639; Sun, 01 Oct 2023 15:21:30 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id q26-20020a62ae1a000000b0068ffd4eb66dsm18313851pff.35.2023.10.01.15.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 15:21:29 -0700 (PDT) Date: Sun, 1 Oct 2023 15:21:27 -0700 From: Kees Cook To: Julia Lawall Cc: Kees Cook , Christophe JAILLET , Ian Abbott , H Hartley Sweeten , "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by Message-ID: <202310011515.D4C9184@keescook> References: <5c3b7459b820e22e2ac6ce892d4aadcc119cc919.1696065263.git.christophe.jaillet@wanadoo.fr> <202309301342.5B5BED40A1@keescook> <90E2BBA5-8A2D-42DE-B36A-CD37BABBB433@kernel.org> <202310011405.7599BA9@keescook> <202310011421.C4F19D45@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202310011421.C4F19D45@keescook> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 01 Oct 2023 15:22:00 -0700 (PDT) On Sun, Oct 01, 2023 at 02:22:17PM -0700, Kees Cook wrote: > On Sun, Oct 01, 2023 at 02:05:46PM -0700, Kees Cook wrote: > > On Sun, Oct 01, 2023 at 09:14:02PM +0200, Julia Lawall wrote: > > > Kees, > > > > > > You can try the following. > > > > Cool! Yeah, this finds the example: > > > > drivers/comedi/drivers/rti800.c:74: struct comedi_lrange: field at offset 0 is the counter for the flex array > > drivers/comedi/drivers/rti800.c:83: struct comedi_lrange: field at offset 0 is the counter for the flex array > > drivers/comedi/drivers/rti800.c:92: struct comedi_lrange: field at offset 0 is the counter for the flex array > > > > I'll run it on the whole codebase... > > It found only the struct comedi_lrange instances, but that's good to > know. :) On a related note, why doesn't this work? @allocated@ identifier STRUCT, ARRAY; expression COUNT; struct STRUCT *PTR; identifier ALLOC; type ELEMENT_TYPE; @@ PTR = ALLOC(..., sizeof(\(*PTR\|struct STRUCT\)) + COUNT * sizeof(\(*PTR->ARRAY\|PTR->ARRAY[0]\|ELEMENT_TYPE\)), ...); minus: parse error: File "alloc.cocci", line 15, column 34, charpos = 485 around = 'struct', whole content = PTR = ALLOC(..., sizeof(\(*PTR\|struct STRUCT\)) + if I drop "struct", then it complains about ELEMENT_TYPE... -Kees -- Kees Cook