Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp230049rdb; Tue, 19 Dec 2023 15:05:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEy6uCCxIaZ/ttvyID8YQnYK0Q6ZzFJvI6cH1OSIiCY1/EVwZunzdjhhOvQBgPe3ByNWA+f X-Received: by 2002:a05:620a:28c2:b0:77d:7213:8fb2 with SMTP id l2-20020a05620a28c200b0077d72138fb2mr24656535qkp.40.1703027106464; Tue, 19 Dec 2023 15:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703027106; cv=none; d=google.com; s=arc-20160816; b=zPPRVVeyAlZ2jHOFgDP66p3/6ZRWhoBAjFudpJLW3kMjGSczcQwZbRo3ubdsBQBFTz g/jmpJfMZ/DUtDwYIKI12lzOD4YfHpEjKEr4sQad9dQvW1UR14KkFKDWUevSrhFiWlDI hrt1nyU59nS33WW6fDnH3P1JonebcgJRtL3LnWkplP50KVSC3PZCZvBA+ebDa7NBcxsg 8Puvwy506UaAQTsJMmKRywNMai6tkg/Ec87qdRoPVwMzSRTCiygpC/tnM+sdI5AxYFhD 7KMauMKIsjm+jVpWui76ElQFbZpqtQD4XL3bXwVQ6p6R7iuMx4WbMqPOblIAI5FumA+7 ZHZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:message-id:in-reply-to:subject:cc:to:from :date:dkim-signature; bh=deXv4lVWUMilBoHHp3w75/hwr/YXbvS5EAOYrGm50ic=; fh=CWk8ZVsA59SIorltGHRseujImeLRfPyKoeOWLp7IR0A=; b=X+7dooEpJU1wNzMCpAoska2tw3wfHqofRpoaSH0nbXvem48ZIjPOoA5FcI8kEu4aQZ 3zJWV9XroozRpv3rY9cOYl2r8NFfM4csMwmqilT2tWU9YWNxM9lrrB6BdxOIbh2QTV8t xsh/HEQH3c2yqCiRahlCbTtmb/6XcDpGpPV41dd75DdvIqznL8SENBZMTOLfQJFhXUaC yhzJ1bHPOw18BOmR8SxJS5yVU8E/kASfWx1xABKiJ5fTYXeJf2TuGaWO2l3u+MrZJwFg f+jkVhUUfR/wtxsfADmyh4/fUYOoGgayCLdgeyWqysNGoyYqppJgdoqQ+QzwIQHVkNPc glvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=GFjBVzq3; spf=pass (google.com: domain of linux-kernel+bounces-6077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6077-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bp13-20020a05620a458d00b0077f97bdfb1esi15557159qkb.319.2023.12.19.15.05.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 15:05:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=GFjBVzq3; spf=pass (google.com: domain of linux-kernel+bounces-6077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6077-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3A4571C20FFE for ; Tue, 19 Dec 2023 23:05:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5D2F3D0CD; Tue, 19 Dec 2023 23:04:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="GFjBVzq3" X-Original-To: linux-kernel@vger.kernel.org Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0D323FB21; Tue, 19 Dec 2023 23:04:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=deXv4lVWUMilBoHHp3w75/hwr/YXbvS5EAOYrGm50ic=; b=GFjBVzq3UEyJCplsoXruB0h1ovFTW98nX14OvI9oetApWxfKE7sGGgFO 1NjM2xaL3m+1otjrLN1wusNIqhIF21wg08GVaucCR/4Hwz+ByuKjtpl3K q/exQW1D1Yw8KTlpQfMblBOQTlQHrgLuDVoTzL1huBprh/HC5+9RS//sr 0=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.04,289,1695679200"; d="scan'208";a="74900283" Received: from 231.85.89.92.rev.sfr.net (HELO hadrien) ([92.89.85.231]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 00:04:48 +0100 Date: Wed, 20 Dec 2023 00:04:47 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Luis Chamberlain cc: =?ISO-8859-15?Q?Thomas_Wei=DFschuh?= , Joel Granados , Dan Carpenter , Kees Cook , "Gustavo A. R. Silva" , Iurii Zaikin , Greg Kroah-Hartman , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2 00/18] sysctl: constify sysctl ctl_tables In-Reply-To: Message-ID: References: <20231207104357.kndqvzkhxqkwkkjo@localhost> <20231208095926.aavsjrtqbb5rygmb@localhost> <8509a36b-ac23-4fcd-b797-f8915662d5e1@t-8ch.de> <20231212090930.y4omk62wenxgo5by@localhost> <20231217120201.z4gr3ksjd4ai2nlk@localhost> <908dc370-7cf6-4b2b-b7c9-066779bc48eb@t-8ch.de> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII I came up with the following: @@ type t; const t *x; identifier y,z; expression a; assignment operator aop; @@ ( (<+...(<+...x->y...+>)[...]...+>) aop a | (<+...(<+...x->y...+>)->z...+>) aop a | * (<+...x->y...+>) aop a ) @fn disable optional_qualifier@ identifier f,x; type t; parameter list[n] ps; @@ f(ps,t *x,...) { ... } @@ identifier fn.f; expression list[fn.n] es; type t; const t *e; @@ *f(es,e,...) --------------- The first rule takes care of assignments, while the remaining rules check function calls. This is not extensively tested and has false positives. One case is when you have a->b[x->y] = 12; and it is x not a that is const. Maybe I can improve it to avoid this problem. I would suggest to replace the occurrences of t by your specific type of interest (and then drop the occurrences type t;), to reduce the amount of work to be done and the chance of false positives. This is also limited in that it only works on a single file. Thus in particular the last rule on function calls will only be triggered when the called function is defined in the same file. Despite the current limitations, maybe it will find something useful. julia