Re: [PATCH v1] binfmt_misc: fix crash when load/unload module

From: Luis Chamberlain
Date: Tue Jan 25 2022 - 13:14:59 EST


On Mon, Jan 24, 2022 at 03:16:11PM -0800, Andrew Morton wrote:
> On Mon, 24 Jan 2022 19:40:53 +0800 kernel test robot <lkp@xxxxxxxxx> wrote:
>
> > Hi Tong,
> >
> >
> > >> fs/binfmt_misc.c:828:21: error: incompatible pointer types assigning to 'struct ctl_table_header *' from 'struct sysctl_header *' [-Werror,-Wincompatible-pointer-types]
> > binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc");
> > ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 1 error generated.
> >
> >
> > vim +828 fs/binfmt_misc.c
> >
> > 821
> > 822 static int __init init_misc_binfmt(void)
> > 823 {
> > 824 int err = register_filesystem(&bm_fs_type);
> > 825 if (!err)
> > 826 insert_binfmt(&misc_format);
> > 827
> > > 828 binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc");
> > 829 if (!binfmt_misc_header) {
> > 830 pr_warn("Failed to create fs/binfmt_misc sysctl mount point");
> > 831 return -ENOMEM;
> > 832 }
> > 833 return 0;
> > 834 }
> > 835
>
> This is actually a blooper in Luis's "sysctl: add helper to register a
> sysctl mount point".
>
> Please test, review, ridicule, etc:
>
> From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Subject: include/linux/sysctl.h: fix register_sysctl_mount_point() return type
>
> The CONFIG_SYSCTL=n stub returns the wrong type.
>
> Fixes: ee9efac48a082 ("sysctl: add helper to register a sysctl mount point")
> Cc: Luis Chamberlain <mcgrof@xxxxxxxxxx>
> Cc: Tong Zhang <ztong0001@xxxxxxxxx>
> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>

Acked-by: Luis Chamberlain <mcgrof@xxxxxxxxxx>

Luis