lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <YZ9V9yxGapfPF4+g@equinox>
Date:   Thu, 25 Nov 2021 09:23:03 +0000
From:   Phillip Potter <phil@...lpotter.co.uk>
To:     Luis Chamberlain <mcgrof@...nel.org>, axboe@...nel.dk
Cc:     akpm@...ux-foundation.org, keescook@...omium.org,
        yzaikin@...gle.com, nixiaoming@...wei.com, ebiederm@...ssion.com,
        clemens@...isch.de, arnd@...db.de, gregkh@...uxfoundation.org,
        jani.nikula@...ux.intel.com, joonas.lahtinen@...ux.intel.com,
        rodrigo.vivi@...el.com, tvrtko.ursulin@...ux.intel.com,
        airlied@...ux.ie, benh@...nel.crashing.org, mark@...heh.com,
        jlbec@...lplan.org, joseph.qi@...ux.alibaba.com, jack@...e.cz,
        amir73il@...il.com, phil@...lpotter.co.uk, viro@...iv.linux.org.uk,
        julia.lawall@...ia.fr, ocfs2-devel@....oracle.com,
        linuxppc-dev@...ts.ozlabs.org, intel-gfx@...ts.freedesktop.org,
        dri-devel@...ts.freedesktop.org, linux-fsdevel@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-block@...r.kernel.org
Subject: Re: [PATCH v2 7/8] cdrom: simplify subdirectory registration with
 register_sysctl()

On Tue, Nov 23, 2021 at 12:24:21PM -0800, Luis Chamberlain wrote:
> There is no need to user boiler plate code to specify a set of base
> directories we're going to stuff sysctls under. Simplify this by using
> register_sysctl() and specifying the directory path directly.
> 
> // pycocci sysctl-subdir-register-sysctl-simplify.cocci PATH
> 
> @c1@
> expression E1;
> identifier subdir, sysctls;
> @@
> 
> static struct ctl_table subdir[] = {
> 	{
> 		.procname = E1,
> 		.maxlen = 0,
> 		.mode = 0555,
> 		.child = sysctls,
> 	},
> 	{ }
> };
> 
> @c2@
> identifier c1.subdir;
> 
> expression E2;
> identifier base;
> @@
> 
> static struct ctl_table base[] = {
> 	{
> 		.procname = E2,
> 		.maxlen = 0,
> 		.mode = 0555,
> 		.child = subdir,
> 	},
> 	{ }
> };
> 
> @c3@
> identifier c2.base;
> identifier header;
> @@
> 
> header = register_sysctl_table(base);
> 
> @r1 depends on c1 && c2 && c3@
> expression c1.E1;
> identifier c1.subdir, c1.sysctls;
> @@
> 
> -static struct ctl_table subdir[] = {
> -	{
> -		.procname = E1,
> -		.maxlen = 0,
> -		.mode = 0555,
> -		.child = sysctls,
> -	},
> -	{ }
> -};
> 
> @r2 depends on c1 && c2 && c3@
> identifier c1.subdir;
> 
> expression c2.E2;
> identifier c2.base;
> @@
> -static struct ctl_table base[] = {
> -	{
> -		.procname = E2,
> -		.maxlen = 0,
> -		.mode = 0555,
> -		.child = subdir,
> -	},
> -	{ }
> -};
> 
> @initialize:python@
> @@
> 
> def make_my_fresh_expression(s1, s2):
>   return '"' + s1.strip('"') + "/" + s2.strip('"') + '"'
> 
> @r3 depends on c1 && c2 && c3@
> expression c1.E1;
> identifier c1.sysctls;
> expression c2.E2;
> identifier c2.base;
> identifier c3.header;
> fresh identifier E3 = script:python(E2, E1) { make_my_fresh_expression(E2, E1) };
> @@
> 
> header =
> -register_sysctl_table(base);
> +register_sysctl(E3, sysctls);
> 
> Generated-by: Coccinelle SmPL
> Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
> ---
>  drivers/cdrom/cdrom.c | 23 +----------------------
>  1 file changed, 1 insertion(+), 22 deletions(-)
> 
> diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
> index 9877e413fce3..1b57d4666e43 100644
> --- a/drivers/cdrom/cdrom.c
> +++ b/drivers/cdrom/cdrom.c
> @@ -3691,27 +3691,6 @@ static struct ctl_table cdrom_table[] = {
>  	},
>  	{ }
>  };
> -
> -static struct ctl_table cdrom_cdrom_table[] = {
> -	{
> -		.procname	= "cdrom",
> -		.maxlen		= 0,
> -		.mode		= 0555,
> -		.child		= cdrom_table,
> -	},
> -	{ }
> -};
> -
> -/* Make sure that /proc/sys/dev is there */
> -static struct ctl_table cdrom_root_table[] = {
> -	{
> -		.procname	= "dev",
> -		.maxlen		= 0,
> -		.mode		= 0555,
> -		.child		= cdrom_cdrom_table,
> -	},
> -	{ }
> -};
>  static struct ctl_table_header *cdrom_sysctl_header;
>  
>  static void cdrom_sysctl_register(void)
> @@ -3721,7 +3700,7 @@ static void cdrom_sysctl_register(void)
>  	if (!atomic_add_unless(&initialized, 1, 1))
>  		return;
>  
> -	cdrom_sysctl_header = register_sysctl_table(cdrom_root_table);
> +	cdrom_sysctl_header = register_sysctl("dev/cdrom", cdrom_table);
>  
>  	/* set the defaults */
>  	cdrom_sysctl_settings.autoclose = autoclose;
> -- 
> 2.33.0
> 

Dear Luis,

Thank you for the patch. Tested and working, looks good to me. As this
has already been pulled into Andrew Morton's tree, I have added in Jens
and the linux-block list so there is awareness that the patch will go
via -mm then linux-next tree.

For what it's worth (although guess it won't be in the commit now):
Reviewed-by: Phillip Potter <phil@...lpotter.co.uk>

Regards,
Phil

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ