linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Joel Granados <j.granados@samsung.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "Dave Chinner" <david@fromorbit.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	"Eric Dumazet" <edumazet@google.com>,
	linux-hardening@vger.kernel.org, linux-riscv@lists.infradead.org,
	linux-s390@vger.kernel.org, rds-devel@oss.oracle.com,
	linux-rdma@vger.kernel.org,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	linux-sctp@vger.kernel.org, lvs-devel@vger.kernel.org,
	coreteam@netfilter.org, linux-trace-kernel@vger.kernel.org,
	"Kees Cook" <keescook@chromium.org>,
	bridge@lists.linux.dev, apparmor@lists.ubuntu.com,
	linux-xfs@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-nfs@vger.kernel.org, netdev@vger.kernel.org,
	kexec@lists.infradead.org,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	linux-perf-users@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	netfilter-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	bpf@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v3 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers
Date: Thu, 25 Apr 2024 13:04:12 +0200	[thread overview]
Message-ID: <20240425110412.2n5d27smecfncsfa@joelS2.panther.com> (raw)
In-Reply-To: <20240424201234.3cc2b509@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 2429 bytes --]

On Wed, Apr 24, 2024 at 08:12:34PM -0700, Jakub Kicinski wrote:
> On Tue, 23 Apr 2024 09:54:35 +0200 Thomas Weißschuh wrote:
> > The series was split from my larger series sysctl-const series [0].
> > It only focusses on the proc_handlers but is an important step to be
> > able to move all static definitions of ctl_table into .rodata.
> 
> Split this per subsystem, please.
It is tricky to do that because it changes the first argument (ctl*) to
const in the proc_handler function type defined in sysclt.h:
"
-typedef int proc_handler(struct ctl_table *ctl, int write, void *buffer,
+typedef int proc_handler(const struct ctl_table *ctl, int write, void *buffer,
                size_t *lenp, loff_t *ppos);
"
This means that all the proc_handlers need to change at the same time.

However, there is an alternative way to do this that allows chunking. We
first define the proc_handler as a void pointer (casting it where it is
being used) [1]. Then we could do the constification by subsystem (like
Jakub proposes). Finally we can "revert the void pointer change so we
don't have one size fit all pointer as our proc_handler [2].

Here are some comments about the alternative:
1. We would need to make the first argument const in all the derived
   proc_handlers [3] 
2. There would be no undefined behavior for two reasons:
   2.1. There is no case where we change the first argument. We know
        this because there are no compile errors after we make it const.
   2.2. We would always go from non-const to const. This is the case
        because all the stuff that is unchanged in non-const.
3. If the idea sticks, it should go into mainline as one patchset. I
   would not like to have a void* proc_handler in a kernel release.
4. I think this is a "win/win" solution were the constification goes
   through and it is divided in such a way that it is reviewable.

I would really like to hear what ppl think about this "heretic"
alternative. @Thomas, @Luis, @Kees @Jakub?

Best

[1] https://git.kernel.org/pub/scm/linux/kernel/git/joel.granados/linux.git/commit/?h=jag/constfy_treewide_alternative&id=4a383503b1ea650d4e12c1f5838974e879f5aa6f
[2] https://git.kernel.org/pub/scm/linux/kernel/git/joel.granados/linux.git/commit/?h=jag/constfy_treewide_alternative&id=a3be65973d27ec2933b9e81e1bec60be3a9b460d
[3] proc_dostring, proc_dobool, proc_dointvec....

--

Joel Granados

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

  parent reply	other threads:[~2024-04-25 11:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240423075608eucas1p265e7c90f3efd6995cb240b3d2688b803@eucas1p2.samsung.com>
2024-04-23  7:54 ` [PATCH v3 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers Thomas Weißschuh
2024-04-23  7:54   ` [PATCH v3 01/11] stackleak: don't modify ctl_table argument Thomas Weißschuh
2024-04-23  7:54   ` [PATCH v3 02/11] cgroup: bpf: constify ctl_table arguments and fields Thomas Weißschuh
2024-04-23  7:54   ` [PATCH v3 03/11] hugetlb: constify ctl_table arguments of utility functions Thomas Weißschuh
2024-04-23  7:54   ` [PATCH v3 04/11] utsname: constify ctl_table arguments of utility function Thomas Weißschuh
2024-04-23  7:54   ` [PATCH v3 05/11] neighbour: " Thomas Weißschuh
2024-04-23  7:54   ` [PATCH v3 06/11] ipv4/sysctl: constify ctl_table arguments of utility functions Thomas Weißschuh
2024-04-23  7:54   ` [PATCH v3 07/11] ipv6/addrconf: " Thomas Weißschuh
2024-04-23  7:54   ` [PATCH v3 08/11] ipv6/ndisc: constify ctl_table arguments of utility function Thomas Weißschuh
2024-04-23  7:54   ` [PATCH v3 09/11] ipvs: constify ctl_table arguments of utility functions Thomas Weißschuh
2024-04-23  7:54   ` [PATCH v3 10/11] sysctl: constify ctl_table arguments of utility function Thomas Weißschuh
2024-04-23  7:54   ` [PATCH v3 11/11] sysctl: treewide: constify the ctl_table argument of handlers Thomas Weißschuh
2024-04-29  9:47     ` Heiko Carstens
2024-04-23 18:31   ` [PATCH v3 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers Luis Chamberlain
2024-04-25  3:12   ` Jakub Kicinski
2024-04-25  7:10     ` Thomas Weißschuh
2024-04-27  7:40       ` Thomas Weißschuh
2024-04-25 11:04     ` Joel Granados [this message]
2024-04-25 20:34       ` Thomas Weißschuh
2024-05-08 11:37         ` Joel Granados
2024-05-08 17:11     ` Kees Cook
2024-05-03  9:03   ` Joel Granados
2024-05-03 14:09     ` Thomas Weißschuh
2024-05-08 11:40       ` Joel Granados

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240425110412.2n5d27smecfncsfa@joelS2.panther.com \
    --to=j.granados@samsung.com \
    --cc=apparmor@lists.ubuntu.com \
    --cc=bpf@vger.kernel.org \
    --cc=bridge@lists.linux.dev \
    --cc=coreteam@netfilter.org \
    --cc=david@fromorbit.com \
    --cc=edumazet@google.com \
    --cc=keescook@chromium.org \
    --cc=kexec@lists.infradead.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lvs-devel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=rds-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).