All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Granados <j.granados@samsung.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: <mcgrof@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
	Leon Romanovsky <leon@kernel.org>,
	David Ahern <dsahern@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Joerg Reuter <jreuter@yaina.de>,
	Ralf Baechle <ralf@linux-mips.org>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Jozsef Kadlecsik <kadlec@netfilter.org>,
	Florian Westphal <fw@strlen.de>, Roopa Prabhu <roopa@nvidia.com>,
	Nikolay Aleksandrov <razor@blackwall.org>,
	Alexander Aring <alex.aring@gmail.com>,
	Stefan Schmidt <stefan@datenfreihafen.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Matthieu Baerts <matthieu.baerts@tessares.net>,
	Mat Martineau <martineau@kernel.org>,
	Simon Horman <horms@verge.net.au>, Julian Anastasov <ja@ssi.bg>,
	Remi Denis-Courmont <courmisch@gmail.com>,
	Santosh Shilimkar <santosh.shilimkar@oracle.com>,
	David Howells <dhowells@redhat.com>,
	Marc Dionne <marc.dionne@auristor.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Xin Long <lucien.xin@gmail.com>,
	Karsten Graul <kgraul@linux.ibm.com>,
	Wenjia Zhang <wenjia@linux.ibm.com>,
	Jan Karcher <jaka@linux.ibm.com>, Jon Maloy <jmaloy@redhat.com>,
	Ying Xue <ying.xue@windriver.com>,
	Martin Schiller <ms@dev.tdt.de>, <linux-rdma@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	<linux-hams@vger.kernel.org>, <netfilter-devel@vger.kernel.org>,
	<coreteam@netfilter.org>, <bridge@lists.linux-foundation.org>,
	<dccp@vger.kernel.org>, <linux-wpan@vger.kernel.org>,
	<mptcp@lists.linux.dev>, <lvs-devel@vger.kernel.org>,
	<rds-devel@oss.oracle.com>, <linux-afs@lists.infradead.org>,
	<linux-sctp@vger.kernel.org>, <linux-s390@vger.kernel.org>,
	<tipc-discussion@lists.sourceforge.net>,
	<linux-x25@vger.kernel.org>
Subject: Re: [PATCH 06/11] sysctl: Add size to register_net_sysctl function
Date: Wed, 21 Jun 2023 13:36:25 +0200	[thread overview]
Message-ID: <20230621113625.o54p6qfvr5duskfb@localhost> (raw)
In-Reply-To: <dab06c20-f8b0-4e34-b885-f3537e442d54@kadam.mountain>

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

On Wed, Jun 21, 2023 at 12:47:30PM +0300, Dan Carpenter wrote:
> The patchset doesn't include the actual interesting changes, just a
> bunch of mechanical prep work.
Yep, The thread got mangled on the way out. But hopefully the rest of
the patch made its way to the lists and maintainers.

> 
> On Wed, Jun 21, 2023 at 11:09:55AM +0200, Joel Granados wrote:
> > diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
> > index a91283d1e5bf..7b717434368c 100644
> > --- a/net/ieee802154/6lowpan/reassembly.c
> > +++ b/net/ieee802154/6lowpan/reassembly.c
> > @@ -379,7 +379,8 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
> >  	table[1].extra2	= &ieee802154_lowpan->fqdir->high_thresh;
> >  	table[2].data	= &ieee802154_lowpan->fqdir->timeout;
> >  
> > -	hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
> > +	hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table,
> > +				  ARRAY_SIZE(lowpan_frags_ns_ctl_table));
> 
> For example, in lowpan_frags_ns_sysctl_register() the sentinel is
> sometimes element zero if the user doesn't have enough permissions.  I
> would want to ensure that was handled correctly, but that's going to be
> done later in a completely different patchset.  I'm definitely not going
> to remember to check.
Very good catch! I have fixed this as well as ensure_safe_net_sysctl
that was missing a table_size arg.

> 
> > diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
> > index dc5165d3eec4..6f96aae76537 100644
> > --- a/net/mpls/af_mpls.c
> > +++ b/net/mpls/af_mpls.c
> > @@ -1395,6 +1395,40 @@ static const struct ctl_table mpls_dev_table[] = {
> >  	{ }
> >  };
> >  
> > +static int mpls_platform_labels(struct ctl_table *table, int write,
> > +				void *buffer, size_t *lenp, loff_t *ppos);
> > +#define MPLS_NS_SYSCTL_OFFSET(field)		\
> > +	(&((struct net *)0)->field)
> > +
> > +static const struct ctl_table mpls_table[] = {
> > +	{
> > +		.procname	= "platform_labels",
> > +		.data		= NULL,
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= mpls_platform_labels,
> > +	},
> > +	{
> > +		.procname	= "ip_ttl_propagate",
> > +		.data		= MPLS_NS_SYSCTL_OFFSET(mpls.ip_ttl_propagate),
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= proc_dointvec_minmax,
> > +		.extra1		= SYSCTL_ZERO,
> > +		.extra2		= SYSCTL_ONE,
> > +	},
> > +	{
> > +		.procname	= "default_ttl",
> > +		.data		= MPLS_NS_SYSCTL_OFFSET(mpls.default_ttl),
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= proc_dointvec_minmax,
> > +		.extra1		= SYSCTL_ONE,
> > +		.extra2		= &ttl_max,
> > +	},
> > +	{ }
> > +};
> > +
> >  static int mpls_dev_sysctl_register(struct net_device *dev,
> >  				    struct mpls_dev *mdev)
> >  {
> > @@ -1410,7 +1444,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  	/* Table data contains only offsets relative to the base of
> >  	 * the mdev at this point, so make them absolute.
> >  	 */
> > -	for (i = 0; i < ARRAY_SIZE(mpls_dev_table); i++) {
> > +	for (i = 0; i < ARRAY_SIZE(mpls_dev_table) - 1; i++) {
> 
> Adding the " - 1" is just a gratuitous change.  It's not required.
> It makes that patch more confusing to review.  And you're just going
> to have to change it back to how it was if you remove the sentinel.
Removed this for convenience. Thx.


> 
> >  		table[i].data = (char *)mdev + (uintptr_t)table[i].data;
> >  		table[i].extra1 = mdev;
> >  		table[i].extra2 = net;
> > @@ -1418,7 +1452,8 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  
> >  	snprintf(path, sizeof(path), "net/mpls/conf/%s", dev->name);
> >  
> > -	mdev->sysctl = register_net_sysctl(net, path, table);
> > +	mdev->sysctl = register_net_sysctl(net, path, table,
> > +					   ARRAY_SIZE(mpls_dev_table));
> >  	if (!mdev->sysctl)
> >  		goto free;
> >  
> > @@ -1432,6 +1467,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  	return -ENOBUFS;
> >  }
> >  
> > +
Oops. thx. fixed

> 
> Double blank line.
> 
> >  static void mpls_dev_sysctl_unregister(struct net_device *dev,
> >  				       struct mpls_dev *mdev)
> >  {
> 
> regards,
> dan carpenter

-- 

Joel Granados

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

WARNING: multiple messages have this Message-ID (diff)
From: Joel Granados <j.granados@samsung.com>
To: dccp@vger.kernel.org
Subject: Re: [PATCH 06/11] sysctl: Add size to register_net_sysctl function
Date: Wed, 21 Jun 2023 11:36:25 +0000	[thread overview]
Message-ID: <20230621113625.o54p6qfvr5duskfb@localhost> (raw)
In-Reply-To: <20230621091000.424843-7-j.granados@samsung.com>

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

On Wed, Jun 21, 2023 at 12:47:30PM +0300, Dan Carpenter wrote:
> The patchset doesn't include the actual interesting changes, just a
> bunch of mechanical prep work.
Yep, The thread got mangled on the way out. But hopefully the rest of
the patch made its way to the lists and maintainers.

> 
> On Wed, Jun 21, 2023 at 11:09:55AM +0200, Joel Granados wrote:
> > diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
> > index a91283d1e5bf..7b717434368c 100644
> > --- a/net/ieee802154/6lowpan/reassembly.c
> > +++ b/net/ieee802154/6lowpan/reassembly.c
> > @@ -379,7 +379,8 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
> >  	table[1].extra2	= &ieee802154_lowpan->fqdir->high_thresh;
> >  	table[2].data	= &ieee802154_lowpan->fqdir->timeout;
> >  
> > -	hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
> > +	hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table,
> > +				  ARRAY_SIZE(lowpan_frags_ns_ctl_table));
> 
> For example, in lowpan_frags_ns_sysctl_register() the sentinel is
> sometimes element zero if the user doesn't have enough permissions.  I
> would want to ensure that was handled correctly, but that's going to be
> done later in a completely different patchset.  I'm definitely not going
> to remember to check.
Very good catch! I have fixed this as well as ensure_safe_net_sysctl
that was missing a table_size arg.

> 
> > diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
> > index dc5165d3eec4..6f96aae76537 100644
> > --- a/net/mpls/af_mpls.c
> > +++ b/net/mpls/af_mpls.c
> > @@ -1395,6 +1395,40 @@ static const struct ctl_table mpls_dev_table[] = {
> >  	{ }
> >  };
> >  
> > +static int mpls_platform_labels(struct ctl_table *table, int write,
> > +				void *buffer, size_t *lenp, loff_t *ppos);
> > +#define MPLS_NS_SYSCTL_OFFSET(field)		\
> > +	(&((struct net *)0)->field)
> > +
> > +static const struct ctl_table mpls_table[] = {
> > +	{
> > +		.procname	= "platform_labels",
> > +		.data		= NULL,
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= mpls_platform_labels,
> > +	},
> > +	{
> > +		.procname	= "ip_ttl_propagate",
> > +		.data		= MPLS_NS_SYSCTL_OFFSET(mpls.ip_ttl_propagate),
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= proc_dointvec_minmax,
> > +		.extra1		= SYSCTL_ZERO,
> > +		.extra2		= SYSCTL_ONE,
> > +	},
> > +	{
> > +		.procname	= "default_ttl",
> > +		.data		= MPLS_NS_SYSCTL_OFFSET(mpls.default_ttl),
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= proc_dointvec_minmax,
> > +		.extra1		= SYSCTL_ONE,
> > +		.extra2		= &ttl_max,
> > +	},
> > +	{ }
> > +};
> > +
> >  static int mpls_dev_sysctl_register(struct net_device *dev,
> >  				    struct mpls_dev *mdev)
> >  {
> > @@ -1410,7 +1444,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  	/* Table data contains only offsets relative to the base of
> >  	 * the mdev at this point, so make them absolute.
> >  	 */
> > -	for (i = 0; i < ARRAY_SIZE(mpls_dev_table); i++) {
> > +	for (i = 0; i < ARRAY_SIZE(mpls_dev_table) - 1; i++) {
> 
> Adding the " - 1" is just a gratuitous change.  It's not required.
> It makes that patch more confusing to review.  And you're just going
> to have to change it back to how it was if you remove the sentinel.
Removed this for convenience. Thx.


> 
> >  		table[i].data = (char *)mdev + (uintptr_t)table[i].data;
> >  		table[i].extra1 = mdev;
> >  		table[i].extra2 = net;
> > @@ -1418,7 +1452,8 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  
> >  	snprintf(path, sizeof(path), "net/mpls/conf/%s", dev->name);
> >  
> > -	mdev->sysctl = register_net_sysctl(net, path, table);
> > +	mdev->sysctl = register_net_sysctl(net, path, table,
> > +					   ARRAY_SIZE(mpls_dev_table));
> >  	if (!mdev->sysctl)
> >  		goto free;
> >  
> > @@ -1432,6 +1467,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  	return -ENOBUFS;
> >  }
> >  
> > +
Oops. thx. fixed

> 
> Double blank line.
> 
> >  static void mpls_dev_sysctl_unregister(struct net_device *dev,
> >  				       struct mpls_dev *mdev)
> >  {
> 
> regards,
> dan carpenter

-- 

Joel Granados

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

WARNING: multiple messages have this Message-ID (diff)
From: Joel Granados <j.granados@samsung.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: mcgrof@kernel.org, Jason Gunthorpe <jgg@ziepe.ca>,
	Leon Romanovsky <leon@kernel.org>,
	David Ahern <dsahern@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Joerg Reuter <jreuter@yaina.de>,
	Ralf Baechle <ralf@linux-mips.org>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Jozsef Kadlecsik <kadlec@netfilter.org>,
	Florian Westphal <fw@strlen.de>, Roopa Prabhu <roopa@nvidia.com>,
	Nikolay Aleksandrov <razor@blackwall.org>,
	Alexander Aring <alex.aring@gmail.com>,
	Stefan Schmidt <stefan@datenfreihafen.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Herbert Xu <herbert@gondor.apana.org.au>
Subject: Re: [PATCH 06/11] sysctl: Add size to register_net_sysctl function
Date: Wed, 21 Jun 2023 13:36:25 +0200	[thread overview]
Message-ID: <20230621113625.o54p6qfvr5duskfb@localhost> (raw)
In-Reply-To: <dab06c20-f8b0-4e34-b885-f3537e442d54@kadam.mountain>

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

On Wed, Jun 21, 2023 at 12:47:30PM +0300, Dan Carpenter wrote:
> The patchset doesn't include the actual interesting changes, just a
> bunch of mechanical prep work.
Yep, The thread got mangled on the way out. But hopefully the rest of
the patch made its way to the lists and maintainers.

> 
> On Wed, Jun 21, 2023 at 11:09:55AM +0200, Joel Granados wrote:
> > diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
> > index a91283d1e5bf..7b717434368c 100644
> > --- a/net/ieee802154/6lowpan/reassembly.c
> > +++ b/net/ieee802154/6lowpan/reassembly.c
> > @@ -379,7 +379,8 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
> >  	table[1].extra2	= &ieee802154_lowpan->fqdir->high_thresh;
> >  	table[2].data	= &ieee802154_lowpan->fqdir->timeout;
> >  
> > -	hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
> > +	hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table,
> > +				  ARRAY_SIZE(lowpan_frags_ns_ctl_table));
> 
> For example, in lowpan_frags_ns_sysctl_register() the sentinel is
> sometimes element zero if the user doesn't have enough permissions.  I
> would want to ensure that was handled correctly, but that's going to be
> done later in a completely different patchset.  I'm definitely not going
> to remember to check.
Very good catch! I have fixed this as well as ensure_safe_net_sysctl
that was missing a table_size arg.

> 
> > diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
> > index dc5165d3eec4..6f96aae76537 100644
> > --- a/net/mpls/af_mpls.c
> > +++ b/net/mpls/af_mpls.c
> > @@ -1395,6 +1395,40 @@ static const struct ctl_table mpls_dev_table[] = {
> >  	{ }
> >  };
> >  
> > +static int mpls_platform_labels(struct ctl_table *table, int write,
> > +				void *buffer, size_t *lenp, loff_t *ppos);
> > +#define MPLS_NS_SYSCTL_OFFSET(field)		\
> > +	(&((struct net *)0)->field)
> > +
> > +static const struct ctl_table mpls_table[] = {
> > +	{
> > +		.procname	= "platform_labels",
> > +		.data		= NULL,
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= mpls_platform_labels,
> > +	},
> > +	{
> > +		.procname	= "ip_ttl_propagate",
> > +		.data		= MPLS_NS_SYSCTL_OFFSET(mpls.ip_ttl_propagate),
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= proc_dointvec_minmax,
> > +		.extra1		= SYSCTL_ZERO,
> > +		.extra2		= SYSCTL_ONE,
> > +	},
> > +	{
> > +		.procname	= "default_ttl",
> > +		.data		= MPLS_NS_SYSCTL_OFFSET(mpls.default_ttl),
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= proc_dointvec_minmax,
> > +		.extra1		= SYSCTL_ONE,
> > +		.extra2		= &ttl_max,
> > +	},
> > +	{ }
> > +};
> > +
> >  static int mpls_dev_sysctl_register(struct net_device *dev,
> >  				    struct mpls_dev *mdev)
> >  {
> > @@ -1410,7 +1444,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  	/* Table data contains only offsets relative to the base of
> >  	 * the mdev at this point, so make them absolute.
> >  	 */
> > -	for (i = 0; i < ARRAY_SIZE(mpls_dev_table); i++) {
> > +	for (i = 0; i < ARRAY_SIZE(mpls_dev_table) - 1; i++) {
> 
> Adding the " - 1" is just a gratuitous change.  It's not required.
> It makes that patch more confusing to review.  And you're just going
> to have to change it back to how it was if you remove the sentinel.
Removed this for convenience. Thx.


> 
> >  		table[i].data = (char *)mdev + (uintptr_t)table[i].data;
> >  		table[i].extra1 = mdev;
> >  		table[i].extra2 = net;
> > @@ -1418,7 +1452,8 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  
> >  	snprintf(path, sizeof(path), "net/mpls/conf/%s", dev->name);
> >  
> > -	mdev->sysctl = register_net_sysctl(net, path, table);
> > +	mdev->sysctl = register_net_sysctl(net, path, table,
> > +					   ARRAY_SIZE(mpls_dev_table));
> >  	if (!mdev->sysctl)
> >  		goto free;
> >  
> > @@ -1432,6 +1467,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  	return -ENOBUFS;
> >  }
> >  
> > +
Oops. thx. fixed

> 
> Double blank line.
> 
> >  static void mpls_dev_sysctl_unregister(struct net_device *dev,
> >  				       struct mpls_dev *mdev)
> >  {
> 
> regards,
> dan carpenter

-- 

Joel Granados

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

WARNING: multiple messages have this Message-ID (diff)
From: Joel Granados <j.granados@samsung.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Alexander Aring <alex.aring@gmail.com>,
	Nikolay Aleksandrov <razor@blackwall.org>,
	Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	David Howells <dhowells@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Marc Dionne <marc.dionne@auristor.com>,
	Jan Karcher <jaka@linux.ibm.com>,
	Mat Martineau <martineau@kernel.org>,
	linux-afs@lists.infradead.org,
	Stefan Schmidt <stefan@datenfreihafen.org>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	linux-s390@vger.kernel.org, rds-devel@oss.oracle.com,
	Xin Long <lucien.xin@gmail.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Leon Romanovsky <leon@kernel.org>,
	dccp@vger.kernel.org, linux-rdma@vger.kernel.org,
	bridge@lists.linux-foundation.org,
	Jozsef Kadlecsik <kadlec@netfilter.org>,
	lvs-devel@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca>,
	Julian Anastasov <ja@ssi.bg>,
	coreteam@netfilter.org, Roopa Prabhu <roopa@nvidia.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Martin Schiller <ms@dev.tdt.de>,
	Santosh Shilimkar <santosh.shilimkar@oracle.com>,
	linux-sctp@vger.kernel.org, Wenjia Zhang <wenjia@linux.ibm.com>,
	Simon Horman <horms@verge.net.au>,
	Remi Denis-Courmont <courmisch@gmail.com>,
	linux-hams@vger.kernel.org, mptcp@lists.linux.dev,
	tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org,
	Neil Horman <nhorman@tuxdriver.com>,
	netdev@vger.kernel.org, David Ahern <dsahern@kernel.org>,
	Florian Westphal <fw@strlen.de>,
	linux-kernel@vger.kernel.org, Ralf Baechle <ralf@linux-mips.org>,
	Karsten Graul <kgraul@linux.ibm.com>,
	Jon Maloy <jmaloy@redhat.com>,
	mcgrof@kernel.org, netfilter-devel@vger.kernel.org,
	Joerg Reuter <jreuter@yaina.de>,
	Ying Xue <ying.xue@windriver.com>,
	Matthieu Baerts <matthieu.baerts@tessares.net>,
	linux-wpan@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [Bridge] [PATCH 06/11] sysctl: Add size to register_net_sysctl function
Date: Wed, 21 Jun 2023 13:36:25 +0200	[thread overview]
Message-ID: <20230621113625.o54p6qfvr5duskfb@localhost> (raw)
In-Reply-To: <dab06c20-f8b0-4e34-b885-f3537e442d54@kadam.mountain>

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

On Wed, Jun 21, 2023 at 12:47:30PM +0300, Dan Carpenter wrote:
> The patchset doesn't include the actual interesting changes, just a
> bunch of mechanical prep work.
Yep, The thread got mangled on the way out. But hopefully the rest of
the patch made its way to the lists and maintainers.

> 
> On Wed, Jun 21, 2023 at 11:09:55AM +0200, Joel Granados wrote:
> > diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
> > index a91283d1e5bf..7b717434368c 100644
> > --- a/net/ieee802154/6lowpan/reassembly.c
> > +++ b/net/ieee802154/6lowpan/reassembly.c
> > @@ -379,7 +379,8 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
> >  	table[1].extra2	= &ieee802154_lowpan->fqdir->high_thresh;
> >  	table[2].data	= &ieee802154_lowpan->fqdir->timeout;
> >  
> > -	hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
> > +	hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table,
> > +				  ARRAY_SIZE(lowpan_frags_ns_ctl_table));
> 
> For example, in lowpan_frags_ns_sysctl_register() the sentinel is
> sometimes element zero if the user doesn't have enough permissions.  I
> would want to ensure that was handled correctly, but that's going to be
> done later in a completely different patchset.  I'm definitely not going
> to remember to check.
Very good catch! I have fixed this as well as ensure_safe_net_sysctl
that was missing a table_size arg.

> 
> > diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
> > index dc5165d3eec4..6f96aae76537 100644
> > --- a/net/mpls/af_mpls.c
> > +++ b/net/mpls/af_mpls.c
> > @@ -1395,6 +1395,40 @@ static const struct ctl_table mpls_dev_table[] = {
> >  	{ }
> >  };
> >  
> > +static int mpls_platform_labels(struct ctl_table *table, int write,
> > +				void *buffer, size_t *lenp, loff_t *ppos);
> > +#define MPLS_NS_SYSCTL_OFFSET(field)		\
> > +	(&((struct net *)0)->field)
> > +
> > +static const struct ctl_table mpls_table[] = {
> > +	{
> > +		.procname	= "platform_labels",
> > +		.data		= NULL,
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= mpls_platform_labels,
> > +	},
> > +	{
> > +		.procname	= "ip_ttl_propagate",
> > +		.data		= MPLS_NS_SYSCTL_OFFSET(mpls.ip_ttl_propagate),
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= proc_dointvec_minmax,
> > +		.extra1		= SYSCTL_ZERO,
> > +		.extra2		= SYSCTL_ONE,
> > +	},
> > +	{
> > +		.procname	= "default_ttl",
> > +		.data		= MPLS_NS_SYSCTL_OFFSET(mpls.default_ttl),
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= proc_dointvec_minmax,
> > +		.extra1		= SYSCTL_ONE,
> > +		.extra2		= &ttl_max,
> > +	},
> > +	{ }
> > +};
> > +
> >  static int mpls_dev_sysctl_register(struct net_device *dev,
> >  				    struct mpls_dev *mdev)
> >  {
> > @@ -1410,7 +1444,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  	/* Table data contains only offsets relative to the base of
> >  	 * the mdev at this point, so make them absolute.
> >  	 */
> > -	for (i = 0; i < ARRAY_SIZE(mpls_dev_table); i++) {
> > +	for (i = 0; i < ARRAY_SIZE(mpls_dev_table) - 1; i++) {
> 
> Adding the " - 1" is just a gratuitous change.  It's not required.
> It makes that patch more confusing to review.  And you're just going
> to have to change it back to how it was if you remove the sentinel.
Removed this for convenience. Thx.


> 
> >  		table[i].data = (char *)mdev + (uintptr_t)table[i].data;
> >  		table[i].extra1 = mdev;
> >  		table[i].extra2 = net;
> > @@ -1418,7 +1452,8 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  
> >  	snprintf(path, sizeof(path), "net/mpls/conf/%s", dev->name);
> >  
> > -	mdev->sysctl = register_net_sysctl(net, path, table);
> > +	mdev->sysctl = register_net_sysctl(net, path, table,
> > +					   ARRAY_SIZE(mpls_dev_table));
> >  	if (!mdev->sysctl)
> >  		goto free;
> >  
> > @@ -1432,6 +1467,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
> >  	return -ENOBUFS;
> >  }
> >  
> > +
Oops. thx. fixed

> 
> Double blank line.
> 
> >  static void mpls_dev_sysctl_unregister(struct net_device *dev,
> >  				       struct mpls_dev *mdev)
> >  {
> 
> regards,
> dan carpenter

-- 

Joel Granados

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

  parent reply	other threads:[~2023-06-21 11:36 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230621091002eucas1p28cbe3260b7d4c2a086f0b5ac79a7f038@eucas1p2.samsung.com>
2023-06-21  9:09 ` [PATCH 00/11] Remove the end element in sysctl table arrays Joel Granados
     [not found]   ` <CGME20230621091004eucas1p2e53ad3001cdaef7b3c44555653bbec37@eucas1p2.samsung.com>
2023-06-21  9:09     ` [PATCH 01/11] sysctl: Prefer ctl_table_header in proc_sysctl Joel Granados
     [not found]   ` <CGME20230621091007eucas1p2271595a5889075994e8dceb0c06ae7cc@eucas1p2.samsung.com>
2023-06-21  9:09     ` [PATCH 02/11] sysctl: Use the ctl header in list ctl_table macro Joel Granados
     [not found]   ` <CGME20230621091009eucas1p1e4fa56beb44e49e4d1160bfac6eb59ec@eucas1p1.samsung.com>
2023-06-21  9:09     ` [PATCH 03/11] sysctl: Add ctl_table_size to ctl_table_header Joel Granados
     [not found]   ` <CGME20230621091011eucas1p2116c1fb8f406bec7ca9a831f66955724@eucas1p2.samsung.com>
2023-06-21  9:09     ` [PATCH 04/11] sysctl: Add size argument to init_header Joel Granados
     [not found]   ` <CGME20230621091014eucas1p1a30430568d0f7fec5ccbed31cab73aa0@eucas1p1.samsung.com>
2023-06-21  9:09     ` [PATCH 05/11] sysctl: Add a size arg to __register_sysctl_table Joel Granados
2023-06-21 20:53       ` Jakub Kicinski
2023-06-22 14:09         ` Joel Granados
     [not found]   ` <CGME20230621091022eucas1p1c097da50842b23e902e1a674e117e1aa@eucas1p1.samsung.com>
2023-06-21  9:09     ` [PATCH 06/11] sysctl: Add size to register_net_sysctl function Joel Granados
2023-06-21  9:09       ` [Bridge] " Joel Granados
2023-06-21  9:09       ` Joel Granados
2023-06-21  9:09       ` Joel Granados
2023-06-21  9:47       ` Dan Carpenter
2023-06-21  9:47         ` [Bridge] " Dan Carpenter
2023-06-21  9:47         ` Dan Carpenter
2023-06-21  9:47         ` Dan Carpenter
2023-06-21 10:23         ` Dan Carpenter
2023-06-21 10:23           ` [Bridge] " Dan Carpenter
2023-06-21 10:23           ` Dan Carpenter
2023-06-21 10:23           ` Dan Carpenter
2023-06-21 12:03           ` Joel Granados
2023-06-21 12:03             ` [Bridge] " Joel Granados
2023-06-21 12:03             ` Joel Granados
2023-06-21 12:03             ` Joel Granados
2023-06-23 14:21           ` Joel Granados
2023-06-23 14:21             ` [Bridge] " Joel Granados
2023-06-23 14:21             ` Joel Granados
2023-06-23 14:21             ` Joel Granados
2023-06-21 10:49         ` Dan Carpenter
2023-06-21 10:49           ` [Bridge] " Dan Carpenter
2023-06-21 10:49           ` Dan Carpenter
2023-06-21 10:49           ` Dan Carpenter
2023-06-21 11:49           ` Joel Granados
2023-06-21 11:49             ` [Bridge] " Joel Granados
2023-06-21 11:49             ` Joel Granados
2023-06-21 11:49             ` Joel Granados
2023-06-21 11:36         ` Joel Granados [this message]
2023-06-21 11:36           ` [Bridge] " Joel Granados
2023-06-21 11:36           ` Joel Granados
2023-06-21 11:36           ` Joel Granados
     [not found]   ` <CGME20230621091029eucas1p2f9fd694dae3dfbdfffd25dccf4fcb568@eucas1p2.samsung.com>
2023-06-21  9:09     ` [PATCH 07/11] sysctl: Add size to register_sysctl Joel Granados
2023-06-21  9:09       ` [Intel-gfx] " Joel Granados
2023-06-21  9:09       ` Joel Granados
2023-06-21  9:09       ` Joel Granados
2023-06-21  9:09       ` [Ocfs2-devel] " Joel Granados via Ocfs2-devel
     [not found]   ` <CGME20230621091037eucas1p188e11d8064526a5a0549217d5a419647@eucas1p1.samsung.com>
2023-06-21  9:09     ` [PATCH 08/11] sysctl: Add size to register_sysctl_init Joel Granados
2023-06-21  9:09       ` Joel Granados
2023-06-21  9:56       ` Jiri Slaby
2023-06-21  9:56         ` Jiri Slaby
2023-06-21 13:11         ` Joel Granados
2023-06-21 13:11           ` Joel Granados
2023-06-22  4:25           ` Jiri Slaby
2023-06-22  4:25             ` Jiri Slaby
2023-06-22 13:59             ` Joel Granados
2023-06-22 13:59               ` Joel Granados
2023-06-21 10:47       ` Greg Kroah-Hartman
2023-06-21 10:47         ` Greg Kroah-Hartman
2023-06-21 13:15         ` Joel Granados
2023-06-21 13:15           ` Joel Granados
2023-06-22  4:21           ` Jiri Slaby
2023-06-22  4:21             ` Jiri Slaby
2023-06-22 14:00             ` Joel Granados
2023-06-22 14:00               ` Joel Granados
2023-06-23 15:20               ` Petr Mladek
2023-06-23 15:20                 ` Petr Mladek
2023-06-21 11:36       ` Petr Mladek
2023-06-21 11:36         ` Petr Mladek
2023-06-21 15:30         ` Joel Granados
2023-06-21 15:30           ` Joel Granados
     [not found]   ` <CGME20230621094824eucas1p154c97eead5f2de6bceca6359304b775c@eucas1p1.samsung.com>
2023-06-21  9:48     ` [PATCH 09/11] sysctl: Remove the end element in sysctl table arrays Joel Granados
2023-06-21  9:48       ` [Bridge] " Joel Granados
2023-06-21  9:48       ` Joel Granados
2023-06-21  9:48       ` Joel Granados
2023-06-21  9:48       ` [Intel-gfx] " Joel Granados
2023-06-21  9:48       ` Joel Granados
2023-06-21  9:48       ` Joel Granados
2023-06-21  9:48       ` [Ocfs2-devel] " Joel Granados via Ocfs2-devel
2023-06-21  9:48       ` Joel Granados
     [not found]       ` <CGME20230621094825eucas1p2d37372e5bd2377bfe953e6e4f7ff0363@eucas1p2.samsung.com>
2023-06-21  9:48         ` [PATCH 10/11] sysctl: Remove nr_entries from new_links Joel Granados
     [not found]       ` <CGME20230621094828eucas1p22b0b45adc25f881fe00a20d96d495d95@eucas1p2.samsung.com>
2023-06-21  9:48         ` [PATCH 11/11] sysctl: rm "child" from __register_sysctl_table doc Joel Granados
2023-06-21 11:16       ` [PATCH 09/11] sysctl: Remove the end element in sysctl table arrays Jani Nikula
2023-06-21 11:16         ` [Bridge] " Jani Nikula
2023-06-21 11:16         ` Jani Nikula
2023-06-21 11:16         ` Jani Nikula
2023-06-21 11:16         ` [Intel-gfx] " Jani Nikula
2023-06-21 11:16         ` Jani Nikula
2023-06-21 11:16         ` Jani Nikula
2023-06-21 11:16         ` [Ocfs2-devel] " Jani Nikula via Ocfs2-devel
2023-06-21 13:06         ` Joel Granados
2023-06-21 13:06           ` [Bridge] " Joel Granados
2023-06-21 13:06           ` Joel Granados
2023-06-21 13:06           ` [Intel-gfx] " Joel Granados
2023-06-21 13:06           ` Joel Granados
2023-06-21 13:06           ` Joel Granados
2023-06-21 13:06           ` [Ocfs2-devel] " Joel Granados via Ocfs2-devel
2023-06-21 13:15           ` Jani Nikula
2023-06-21 13:15             ` [Bridge] " Jani Nikula
2023-06-21 13:15             ` Jani Nikula
2023-06-21 13:15             ` [Intel-gfx] " Jani Nikula
2023-06-21 13:15             ` Jani Nikula
2023-06-21 13:15             ` Jani Nikula
2023-06-21 13:15             ` [Ocfs2-devel] " Jani Nikula via Ocfs2-devel
2023-06-21 13:43             ` Joel Granados
2023-06-21 13:43               ` [Bridge] " Joel Granados
2023-06-21 13:43               ` Joel Granados
2023-06-21 13:43               ` [Intel-gfx] " Joel Granados
2023-06-21 13:43               ` Joel Granados
2023-06-21 13:43               ` Joel Granados
2023-06-21 13:43               ` [Ocfs2-devel] " Joel Granados via Ocfs2-devel
2023-06-21 10:46   ` [PATCH 00/11] " Greg KH
2023-06-21 12:38     ` Joel Granados
2023-06-21 13:10       ` Greg KH
2023-06-21 14:13         ` 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=20230621113625.o54p6qfvr5duskfb@localhost \
    --to=j.granados@samsung.com \
    --cc=alex.aring@gmail.com \
    --cc=bridge@lists.linux-foundation.org \
    --cc=coreteam@netfilter.org \
    --cc=courmisch@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=davem@davemloft.net \
    --cc=dccp@vger.kernel.org \
    --cc=dhowells@redhat.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=horms@verge.net.au \
    --cc=ja@ssi.bg \
    --cc=jaka@linux.ibm.com \
    --cc=jgg@ziepe.ca \
    --cc=jmaloy@redhat.com \
    --cc=jreuter@yaina.de \
    --cc=kadlec@netfilter.org \
    --cc=kgraul@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-hams@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=linux-x25@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=lvs-devel@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=marcelo.leitner@gmail.com \
    --cc=martineau@kernel.org \
    --cc=matthieu.baerts@tessares.net \
    --cc=mcgrof@kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=mptcp@lists.linux.dev \
    --cc=ms@dev.tdt.de \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=ralf@linux-mips.org \
    --cc=razor@blackwall.org \
    --cc=rds-devel@oss.oracle.com \
    --cc=roopa@nvidia.com \
    --cc=santosh.shilimkar@oracle.com \
    --cc=stefan@datenfreihafen.org \
    --cc=steffen.klassert@secunet.com \
    --cc=tipc-discussion@lists.sourceforge.net \
    --cc=wenjia@linux.ibm.com \
    --cc=ying.xue@windriver.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.