From: Joel Granados <j.granados@samsung.com>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
<linux-kernel@vger.kernel.org>, Iurii Zaikin <yzaikin@google.com>,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
Christian Brauner <brauner@kernel.org>,
<linux-fsdevel@vger.kernel.org>,
Kees Cook <keescook@chromium.org>
Subject: Re: [PATCH 0/2] sysctl: Remove register_sysctl_table from sources
Date: Mon, 22 May 2023 08:34:07 +0200 [thread overview]
Message-ID: <20230522063407.odxv5dgerz33xpzf@localhost> (raw)
In-Reply-To: <ZGbCOjS1n6zV9ZGV@bombadil.infradead.org>
[-- Attachment #1: Type: text/plain, Size: 4470 bytes --]
On Thu, May 18, 2023 at 05:26:34PM -0700, Luis Chamberlain wrote:
> On Thu, May 18, 2023 at 01:46:44PM -0700, Luis Chamberlain wrote:
> > On Thu, May 18, 2023 at 06:07:03PM +0200, Joel Granados wrote:
> > > This is part of the general push to deprecate register_sysctl_paths and
> > > register_sysctl_table. This patchset completely removes register_sysctl_table
> > > and replaces it with register_sysctl effectively transitioning 5 base paths
> > > ("kernel", "vm", "fs", "dev" and "debug") to the new call. Besides removing the
> > > actuall function, I also removed it from the checks done in check-sysctl-docs.
> > >
> > > Testing for this change was done in the same way as with previous sysctl
> > > replacement patches: I made sure that the result of `find /proc/sys/ | sha1sum`
> > > was the same before and after the patchset.
> > >
> > > Have pushed this through 0-day. Waiting on results..
> > >
> > > Feedback greatly appreciated.
> >
> > Thanks so much! I merged this to sysctl-testing as build tests are ongoing. But
> > I incorporated these minor changes to your first patch as register_sysctl_init()
> > is more obvious about when we cannot care about the return value.
nice! thx.
> >
> > If the build tests come through I'll push to sysctl-next.
> >
>
> I also had to apply this (yay more nuking):
Indeed. I just saw the results of 0-day and there was a warning
regarding these functions. Thx again.
best
joel
>
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index 7bc7d3c3a215..8873812d22f3 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -1466,19 +1466,6 @@ void __init __register_sysctl_init(const char *path, struct ctl_table *table,
> kmemleak_not_leak(hdr);
> }
>
> -static char *append_path(const char *path, char *pos, const char *name)
> -{
> - int namelen;
> - namelen = strlen(name);
> - if (((pos - path) + namelen + 2) >= PATH_MAX)
> - return NULL;
> - memcpy(pos, name, namelen);
> - pos[namelen] = '/';
> - pos[namelen + 1] = '\0';
> - pos += namelen + 1;
> - return pos;
> -}
> -
> static int count_subheaders(struct ctl_table *table)
> {
> int has_files = 0;
> @@ -1498,82 +1485,6 @@ static int count_subheaders(struct ctl_table *table)
> return nr_subheaders + has_files;
> }
>
> -static int register_leaf_sysctl_tables(const char *path, char *pos,
> - struct ctl_table_header ***subheader, struct ctl_table_set *set,
> - struct ctl_table *table)
> -{
> - struct ctl_table *ctl_table_arg = NULL;
> - struct ctl_table *entry, *files;
> - int nr_files = 0;
> - int nr_dirs = 0;
> - int err = -ENOMEM;
> -
> - list_for_each_table_entry(entry, table) {
> - if (entry->child)
> - nr_dirs++;
> - else
> - nr_files++;
> - }
> -
> - files = table;
> - /* If there are mixed files and directories we need a new table */
> - if (nr_dirs && nr_files) {
> - struct ctl_table *new;
> - files = kcalloc(nr_files + 1, sizeof(struct ctl_table),
> - GFP_KERNEL);
> - if (!files)
> - goto out;
> -
> - ctl_table_arg = files;
> - new = files;
> -
> - list_for_each_table_entry(entry, table) {
> - if (entry->child)
> - continue;
> - *new = *entry;
> - new++;
> - }
> - }
> -
> - /* Register everything except a directory full of subdirectories */
> - if (nr_files || !nr_dirs) {
> - struct ctl_table_header *header;
> - header = __register_sysctl_table(set, path, files);
> - if (!header) {
> - kfree(ctl_table_arg);
> - goto out;
> - }
> -
> - /* Remember if we need to free the file table */
> - header->ctl_table_arg = ctl_table_arg;
> - **subheader = header;
> - (*subheader)++;
> - }
> -
> - /* Recurse into the subdirectories. */
> - list_for_each_table_entry(entry, table) {
> - char *child_pos;
> -
> - if (!entry->child)
> - continue;
> -
> - err = -ENAMETOOLONG;
> - child_pos = append_path(path, pos, entry->procname);
> - if (!child_pos)
> - goto out;
> -
> - err = register_leaf_sysctl_tables(path, child_pos, subheader,
> - set, entry->child);
> - pos[0] = '\0';
> - if (err)
> - goto out;
> - }
> - err = 0;
> -out:
> - /* On failure our caller will unregister all registered subheaders */
> - return err;
> -}
> -
> static void put_links(struct ctl_table_header *header)
> {
> struct ctl_table_set *root_set = &sysctl_table_root.default_set;
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
prev parent reply other threads:[~2023-05-22 6:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20230518160715eucas1p174602d770f0d46e0294b7dba8d6d36dc@eucas1p1.samsung.com>
2023-05-18 16:07 ` [PATCH 0/2] sysctl: Remove register_sysctl_table from sources Joel Granados
2023-05-18 16:07 ` [PATCH 1/2] sysctl: Refactor base paths registrations Joel Granados
2023-05-24 13:29 ` Guenter Roeck
2023-05-24 17:55 ` Luis Chamberlain
2023-05-18 16:07 ` [PATCH 2/2] sysctl: Remove register_sysctl_table Joel Granados
2023-05-18 20:46 ` [PATCH 0/2] sysctl: Remove register_sysctl_table from sources Luis Chamberlain
2023-05-19 0:26 ` Luis Chamberlain
2023-05-22 6:34 ` Joel Granados [this message]
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=20230522063407.odxv5dgerz33xpzf@localhost \
--to=j.granados@samsung.com \
--cc=brauner@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=sudipm.mukherjee@gmail.com \
--cc=viro@zeniv.linux.org.uk \
--cc=yzaikin@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.