From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C39DDC0218C for ; Wed, 22 Jan 2025 12:41:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55499280006; Wed, 22 Jan 2025 07:41:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 50450280005; Wed, 22 Jan 2025 07:41:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A526280006; Wed, 22 Jan 2025 07:41:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0E39E280005 for ; Wed, 22 Jan 2025 07:41:52 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8C3961416B5 for ; Wed, 22 Jan 2025 12:41:51 +0000 (UTC) X-FDA: 83035049622.30.D015A1F Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf19.hostedemail.com (Postfix) with ESMTP id 7347B1A0006; Wed, 22 Jan 2025 12:41:49 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="VoyrM/KR"; spf=pass (imf19.hostedemail.com: domain of ardb@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=ardb@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737549709; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/nRt7/FOVju0HHPP7y/y/GmcikIqd0uun9LCjQjrq7E=; b=TCeqSK68LHfP86bUtdR7R6qL70/52AU1G73Vhl/nRNG2KXU+AJWyoxGWkJKaQJSlnQY3SR tQU4tA88v/86USsIchueAP9I5dWiQiOvrBbG7FErsMpdGx1n2QOu4ZcLlLYvsUU3goPE7P pYimvjvgKhh0eODTkTWbnx2r8sbZ9NE= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="VoyrM/KR"; spf=pass (imf19.hostedemail.com: domain of ardb@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=ardb@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737549709; a=rsa-sha256; cv=none; b=b1Dqgrj+AWJBVJaQMdX6+eOv9lZthqVTAfl1fmdrI7LWX3bFtW88Ni1Ww3joHH65vYENYF SqL7FvaT9ulQ5plYuNTiQAIRCVP1J8otE1+cJhPp9R+HVZJIm0TIOZsK+kHuNBND/U+ffu LUl+hSWPflFtCxZQyw25k5S/oXi7aoo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 220E0A4252F; Wed, 22 Jan 2025 12:40:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44836C4CEE0; Wed, 22 Jan 2025 12:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737549708; bh=/nRt7/FOVju0HHPP7y/y/GmcikIqd0uun9LCjQjrq7E=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=VoyrM/KR3y6SyzXqcrUXIeXUzSXAukF1jTugO3Tp/XeZbDQsZz0btjWFVZexImUyA GNv9Ye0JlCb6LXyPS9Jx9MVxR+Wdtkk0Ms+qZSrA1Lr8Xe+0i9vU/ISeGtF/6vb7Vs 1Uj3RovlFmNzqVfmuzQ82cCacT+Fx0ki2YqsVx1IY92F3iqqKCafCCMLWLqphwdRxg srLeLPCzyALTJw1qCRW7tcb44xO01Rx4zDtdApARN9p2pthq2z1LppbizS751cMHo9 cZn++ylUYdHjeWMHwboi8qRzV/CerfY2kd1XCsOqWLze560AIlYM8svAXpyzid0N54 v69z43CGgr7bQ== Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-30227c56b11so69529941fa.3; Wed, 22 Jan 2025 04:41:48 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW3pE+ZJbyOnLt5W+l1uqmXAzUbDO4SWGPbrtJyun1JMla4xic3VOdD6b/PAWhhL+5cc5qzR1Q4lC4=@kvack.org, AJvYcCXkchbcr3CkbRuDiPtsCtNBD2eFeLvxzMuhpvrAU1L4mCAm/nF+PJTg+Ea0JaCzAvu4UXmRo4aHJno=@kvack.org X-Gm-Message-State: AOJu0YwoqKSX/2rpgQ3wKm3+L7hZVMMSbPDp1wsk1TPLkY+iqTypW/rB sjQ81aIXG4QygGuweZH/deDzzltEa7bq99RRu7TkUtP5ezO8Fjk4f1vCsdR79sNdOMuG4yPo2JV 681XTdr+KknwgZVHwJxhDQwdmTmg= X-Google-Smtp-Source: AGHT+IFcRSReB7hah7mapcirnp1PWu31SswN3BbR4HjBYPEG79Tzl030J0TjqkE7fYQS4xaDIi2/KgOUqh2J3fswv1A= X-Received: by 2002:a05:651c:2228:b0:302:4130:e19c with SMTP id 38308e7fff4ca-3072caa15c1mr71017091fa.19.1737549706586; Wed, 22 Jan 2025 04:41:46 -0800 (PST) MIME-Version: 1.0 References: <20250110-jag-ctl_table_const-v2-1-0000e1663144@kernel.org> In-Reply-To: From: Ard Biesheuvel Date: Wed, 22 Jan 2025 13:41:35 +0100 X-Gmail-Original-Message-ID: X-Gm-Features: AbW1kvaDj3u8bGVj1m4rnYAkpiRSTpmPAB3bThAH-GyuG2Tmgw9okzkp1e58uCc Message-ID: Subject: Re: Re: [PATCH v2] treewide: const qualify ctl_tables where applicable To: Joel Granados Cc: Alexander Gordeev , =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , Kees Cook , Luis Chamberlain , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-crypto@vger.kernel.org, openipmi-developer@lists.sourceforge.net, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org, linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org, linux-raid@vger.kernel.org, linux-scsi@vger.kernel.org, linux-serial@vger.kernel.org, xen-devel@lists.xenproject.org, linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, netfs@lists.linux.dev, codalist@coda.cs.cmu.edu, linux-mm@kvack.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, fsverity@lists.linux.dev, linux-xfs@vger.kernel.org, io-uring@vger.kernel.org, bpf@vger.kernel.org, kexec@lists.infradead.org, linux-trace-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, Song Liu , "Steven Rostedt (Google)" , "Martin K. Petersen" , "Darrick J. Wong" , Jani Nikula , Corey Minyard Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7347B1A0006 X-Stat-Signature: 6sx6xw4ji7brdk6wmdddkp4bmjssyomj X-Rspam-User: X-HE-Tag: 1737549709-96490 X-HE-Meta: U2FsdGVkX18yhs6gBPiG1mTpawXUgH0QdmmMdp5SlpIC9F372JJpc/Bg/ln/tSA1Y2FOEmFlD8BGdC7i61BPJRq7yiiRvMpWqU455kgKOvVEGaHsXKZ5DJ9fJejXD0gVoErQEK4AhqZyVXHLZnkRPFjH1OBBK3qdZvR1bT5OFzywKfodqzAOGvch7GH/elbuddjdey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Rvm2eAmOLgug6D7rPiIYtJrKrWgGzI6g3l667y2fBkQto7LiiUYKfiUM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, 22 Jan 2025 at 13:25, Joel Granados wrote: > > On Tue, Jan 21, 2025 at 02:40:16PM +0100, Alexander Gordeev wrote: > > On Fri, Jan 10, 2025 at 03:16:08PM +0100, Joel Granados wrote: > > > > Hi Joel, > > > > > Add the const qualifier to all the ctl_tables in the tree except for > > > watchdog_hardlockup_sysctl, memory_allocation_profiling_sysctls, > > > loadpin_sysctl_table and the ones calling register_net_sysctl (./net, > > > drivers/inifiniband dirs). These are special cases as they use a > > > registration function with a non-const qualified ctl_table argument or > > > modify the arrays before passing them on to the registration function. > > > > > > Constifying ctl_table structs will prevent the modification of > > > proc_handler function pointers as the arrays would reside in .rodata. > > > This is made possible after commit 78eb4ea25cd5 ("sysctl: treewide: > > > constify the ctl_table argument of proc_handlers") constified all the > > > proc_handlers. > > > > I could identify at least these occurences in s390 code as well: > Hey Alexander > > Thx for bringing these to my attention. I had completely missed them as > the spatch only deals with ctl_tables outside functions. > > Short answer: > These should not be included in the current patch because they are a > different pattern from how sysctl tables are usually used. So I will not > include them. > > With that said, I think it might be interesting to look closer at them > as they seem to be complicating the proc_handler (I have to look at them > closer). > > I see that they are defining a ctl_table struct within the functions and > just using the data (from the incoming ctl_table) to forward things down > to proc_do{u,}intvec_* functions. This is very odd and I have only seen > it done in order to change the incoming ctl_table (which is not what is > being done here). > > I will take a closer look after the merge window and circle back with > more info. Might take me a while as I'm not very familiar with s390 > code; any additional information on why those are being used inside the > functions would be helpfull. > Using const data on the stack is not as useful, because the stack is always mapped writable. Global data structures marked 'const' will be moved into an ELF section that is typically mapped read-only in its entirely, and so the data cannot be modified by writing to it directly. No such protection is possible for the stack, and so the constness there is only enforced at compile time.