netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] constify inet6_protocol structures
@ 2017-07-28 20:18 Julia Lawall
  2017-07-28 20:18 ` [PATCH 1/2] ipv6: " Julia Lawall
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Julia Lawall @ 2017-07-28 20:18 UTC (permalink / raw)
  To: David S. Miller; +Cc: kernel-janitors, bhumirks, netdev, linux-kernel

The inet6_protocol structure is only passed as the first argument to
inet6_add_protocol or inet6_del_protocol, both of which are declared as
const.  Thus the inet6_protocol structure itself can be const.

Done with the help of Coccinelle.

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@

static struct inet6_protocol i@p = { ... };

@ok1@
identifier r.i;
expression e1;
position p;
@@

 \(inet6_add_protocol\|inet6_del_protocol\)(&i@p,...)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct inet6_protocol e;
@@

e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@

static
+const
 struct inet6_protocol i = { ... };
// </smpl>

---

 net/ipv6/ip6_gre.c  |    2 +-
 net/ipv6/tcp_ipv6.c |    2 +-
 net/ipv6/udp.c      |    2 +-
 net/l2tp/l2tp_ip6.c |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] ipv6: constify inet6_protocol structures
  2017-07-28 20:18 [PATCH 0/2] constify inet6_protocol structures Julia Lawall
@ 2017-07-28 20:18 ` Julia Lawall
  2017-07-31  9:56   ` Eric Dumazet
  2017-07-28 20:18 ` [PATCH 2/2] l2tp: " Julia Lawall
  2017-07-29  1:53 ` [PATCH 0/2] " David Miller
  2 siblings, 1 reply; 9+ messages in thread
From: Julia Lawall @ 2017-07-28 20:18 UTC (permalink / raw)
  To: David S. Miller
  Cc: kernel-janitors, bhumirks, Alexey Kuznetsov, Hideaki YOSHIFUJI,
	netdev, linux-kernel

The inet6_protocol structure is only passed as the first argument to
inet6_add_protocol or inet6_del_protocol, both of which are declared as
const.  Thus the inet6_protocol structure itself can be const.

Also drop __read_mostly where present on the newly const structures.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 net/ipv6/ip6_gre.c  |    2 +-
 net/ipv6/tcp_ipv6.c |    2 +-
 net/ipv6/udp.c      |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 67ff2aa..33865d6 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1080,7 +1080,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
 }
 
 
-static struct inet6_protocol ip6gre_protocol __read_mostly = {
+static const struct inet6_protocol ip6gre_protocol = {
 	.handler     = gre_rcv,
 	.err_handler = ip6gre_err,
 	.flags       = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 90a3257..2968a33 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1945,7 +1945,7 @@ struct proto tcpv6_prot = {
 	.diag_destroy		= tcp_abort,
 };
 
-static struct inet6_protocol tcpv6_protocol = {
+static const struct inet6_protocol tcpv6_protocol = {
 	.early_demux	=	tcp_v6_early_demux,
 	.early_demux_handler =  tcp_v6_early_demux,
 	.handler	=	tcp_v6_rcv,
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 4a3e656..5f8b8d7 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1448,7 +1448,7 @@ int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
 }
 #endif
 
-static struct inet6_protocol udpv6_protocol = {
+static const struct inet6_protocol udpv6_protocol = {
 	.early_demux	=	udp_v6_early_demux,
 	.early_demux_handler =  udp_v6_early_demux,
 	.handler	=	udpv6_rcv,

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] l2tp: constify inet6_protocol structures
  2017-07-28 20:18 [PATCH 0/2] constify inet6_protocol structures Julia Lawall
  2017-07-28 20:18 ` [PATCH 1/2] ipv6: " Julia Lawall
@ 2017-07-28 20:18 ` Julia Lawall
  2017-07-29  1:53 ` [PATCH 0/2] " David Miller
  2 siblings, 0 replies; 9+ messages in thread
From: Julia Lawall @ 2017-07-28 20:18 UTC (permalink / raw)
  To: David S. Miller; +Cc: kernel-janitors, bhumirks, netdev, linux-kernel

The inet6_protocol structure is only passed as the first argument to
inet6_add_protocol or inet6_del_protocol, both of which are declared as
const.  Thus the inet6_protocol structure itself can be const.

Also drop __read_mostly on the newly const structure.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 net/l2tp/l2tp_ip6.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index 88b397c..d2efcd9 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -788,7 +788,7 @@ static int l2tp_ip6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 	.ops		= &l2tp_ip6_ops,
 };
 
-static struct inet6_protocol l2tp_ip6_protocol __read_mostly = {
+static const struct inet6_protocol l2tp_ip6_protocol = {
 	.handler	= l2tp_ip6_recv,
 };
 

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] constify inet6_protocol structures
  2017-07-28 20:18 [PATCH 0/2] constify inet6_protocol structures Julia Lawall
  2017-07-28 20:18 ` [PATCH 1/2] ipv6: " Julia Lawall
  2017-07-28 20:18 ` [PATCH 2/2] l2tp: " Julia Lawall
@ 2017-07-29  1:53 ` David Miller
  2 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2017-07-29  1:53 UTC (permalink / raw)
  To: Julia.Lawall; +Cc: kernel-janitors, bhumirks, netdev, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Fri, 28 Jul 2017 22:18:56 +0200

> The inet6_protocol structure is only passed as the first argument to
> inet6_add_protocol or inet6_del_protocol, both of which are declared as
> const.  Thus the inet6_protocol structure itself can be const.
> 
> Done with the help of Coccinelle.
 ...

Series applied, thanks Julia.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ipv6: constify inet6_protocol structures
  2017-07-28 20:18 ` [PATCH 1/2] ipv6: " Julia Lawall
@ 2017-07-31  9:56   ` Eric Dumazet
  2017-07-31 10:10     ` Julia Lawall
  2017-08-01  5:59     ` Julia Lawall
  0 siblings, 2 replies; 9+ messages in thread
From: Eric Dumazet @ 2017-07-31  9:56 UTC (permalink / raw)
  To: Julia Lawall; +Cc: David S. Miller, bhumirks, netdev

On Fri, 2017-07-28 at 22:18 +0200, Julia Lawall wrote:
> The inet6_protocol structure is only passed as the first argument to
> inet6_add_protocol or inet6_del_protocol, both of which are declared as
> const.  Thus the inet6_protocol structure itself can be const.
> 
> Also drop __read_mostly where present on the newly const structures.
> 
> Done with the help of Coccinelle.
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  net/ipv6/ip6_gre.c  |    2 +-
>  net/ipv6/tcp_ipv6.c |    2 +-
>  net/ipv6/udp.c      |    2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index 67ff2aa..33865d6 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c
> @@ -1080,7 +1080,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
>  }
>  
> 
> -static struct inet6_protocol ip6gre_protocol __read_mostly = {
> +static const struct inet6_protocol ip6gre_protocol = {
>  	.handler     = gre_rcv,
>  	.err_handler = ip6gre_err,
>  	.flags       = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index 90a3257..2968a33 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -1945,7 +1945,7 @@ struct proto tcpv6_prot = {
>  	.diag_destroy		= tcp_abort,
>  };
>  
> -static struct inet6_protocol tcpv6_protocol = {
> +static const struct inet6_protocol tcpv6_protocol = {
>  	.early_demux	=	tcp_v6_early_demux,
>  	.early_demux_handler =  tcp_v6_early_demux,
>  	.handler	=	tcp_v6_rcv,
> diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> index 4a3e656..5f8b8d7 100644
> --- a/net/ipv6/udp.c
> +++ b/net/ipv6/udp.c
> @@ -1448,7 +1448,7 @@ int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
>  }
>  #endif
>  
> -static struct inet6_protocol udpv6_protocol = {
> +static const struct inet6_protocol udpv6_protocol = {
>  	.early_demux	=	udp_v6_early_demux,
>  	.early_demux_handler =  udp_v6_early_demux,
>  	.handler	=	udpv6_rcv,
> 

This change breaks the kernel if one of these sysctls are changed:
tcp_early_demux, udp_early_demux

Check commit dddb64bcb346 ("net: Add sysctl to toggle early demux for
tcp and udp") why at least 2 structures were no longer const.

(none):~# echo 0 >/proc/sys/net/ipv4/udp_early_demux
[  101.746108] BUG: unable to handle kernel paging request at ffffffffb98cf5c0
[  101.753093] IP: proc_udp_early_demux+0x46/0x60
[  101.757565] PGD 13f540a067 
[  101.757565] P4D 13f540a067 
[  101.760372] PUD 13f540b063 
[  101.763171] PMD 80000013f50001e1 
[  101.765960] 
[  101.770790] Oops: 0003 [#1] SMP
[  101.774376] gsmi: Log Shutdown Reason 0x03
[  101.778473] Modules linked in: w1_therm wire cdc_acm ehci_pci ehci_hcd mlx4_en ib_uverbs mlx4_ib ib_core mlx4_core
[  101.788890] CPU: 3 PID: 8819 Comm: bash Not tainted 4.13.0-smp-DEV #290
[  101.795549] Hardware name: Intel RML,PCH/Iota_QC_19, BIOS 2.40.0 06/22/2016
[  101.802517] task: ffff8e733b9c4140 task.stack: ffffa43548cd0000
[  101.808445] RIP: 0010:proc_udp_early_demux+0x46/0x60
[  101.813445] RSP: 0018:ffffa43548cd3e60 EFLAGS: 00010246
[  101.818676] RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000000
[  101.825816] RDX: ffffffffb98cf5c0 RSI: 0000000000000000 RDI: ffff8e733f400100
[  101.832957] RBP: ffffa43548cd3e68 R08: 0000000000000000 R09: 0000000000000001
[  101.840096] R10: 0000000000000008 R11: f000000000000000 R12: 0000000000000001
[  101.847260] R13: ffffffffffffffea R14: 0000000000000002 R15: ffffffffb9d00380
[  101.854434] FS:  00007f7e1f34a700(0000) GS:ffff8e733f8c0000(0000) knlGS:0000000000000000
[  101.862518] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  101.868263] CR2: ffffffffb98cf5c0 CR3: 000000100f0c8000 CR4: 00000000001406e0
[  101.875439] Call Trace:
[  101.877888]  proc_sys_call_handler+0xf3/0x190
[  101.882260]  proc_sys_write+0x14/0x20
[  101.885944]  vfs_write+0xc8/0x1e0
[  101.889261]  SyS_write+0x48/0xa0
[  101.892520]  entry_SYSCALL_64_fastpath+0x13/0x94
[  101.897137] RIP: 0033:0x7f7e1ebd64a0
[  101.900707] RSP: 002b:00007ffcbb851c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[  101.908306] RAX: ffffffffffffffda RBX: 000000000232aba8 RCX: 00007f7e1ebd64a0
[  101.915437] RDX: 0000000000000002 RSI: 00000000022ea808 RDI: 0000000000000001
[  101.922567] RBP: 00007ffcbb851c50 R08: 00007f7e1ef691b0 R09: 00007f7e1f34a700
[  101.929698] R10: 000000000048926a R11: 0000000000000246 R12: 000000000232b288
[  101.936871] R13: 0000000002325e28 R14: 00000000022f0ce8 R15: 0000000000000000
[  101.944012] Code: 15 e8 07 84 00 8b 0d 9a 3c 7d 00 48 85 d2 74 09 31 f6 85 c9 75 21 48 89 32 48 8b 15 4d 30 84 00 48 85 d2 74 09 31 f6 85 c9 75 06 <48> 89 32 5b 5d c3 48 8b 72 08 eb f4 48 8b 72 08 eb d9 0f 1f 84 
[  101.962907] RIP: proc_udp_early_demux+0x46/0x60 RSP: ffffa43548cd3e60
[  101.969353] CR2: ffffffffb98cf5c0
[  101.972680] ---[ end trace 116c0975bf9e19dd ]---
[  101.977307] Kernel panic - not syncing: Fatal exception
[  101.982590] Kernel Offset: 0x37e00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ipv6: constify inet6_protocol structures
  2017-07-31  9:56   ` Eric Dumazet
@ 2017-07-31 10:10     ` Julia Lawall
  2017-08-01  5:59     ` Julia Lawall
  1 sibling, 0 replies; 9+ messages in thread
From: Julia Lawall @ 2017-07-31 10:10 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S. Miller, bhumirks, netdev



On Mon, 31 Jul 2017, Eric Dumazet wrote:

> On Fri, 2017-07-28 at 22:18 +0200, Julia Lawall wrote:
> > The inet6_protocol structure is only passed as the first argument to
> > inet6_add_protocol or inet6_del_protocol, both of which are declared as
> > const.  Thus the inet6_protocol structure itself can be const.
> >
> > Also drop __read_mostly where present on the newly const structures.
> >
> > Done with the help of Coccinelle.
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > ---
> >  net/ipv6/ip6_gre.c  |    2 +-
> >  net/ipv6/tcp_ipv6.c |    2 +-
> >  net/ipv6/udp.c      |    2 +-
> >  3 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> > index 67ff2aa..33865d6 100644
> > --- a/net/ipv6/ip6_gre.c
> > +++ b/net/ipv6/ip6_gre.c
> > @@ -1080,7 +1080,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
> >  }
> >
> >
> > -static struct inet6_protocol ip6gre_protocol __read_mostly = {
> > +static const struct inet6_protocol ip6gre_protocol = {
> >  	.handler     = gre_rcv,
> >  	.err_handler = ip6gre_err,
> >  	.flags       = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
> > diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> > index 90a3257..2968a33 100644
> > --- a/net/ipv6/tcp_ipv6.c
> > +++ b/net/ipv6/tcp_ipv6.c
> > @@ -1945,7 +1945,7 @@ struct proto tcpv6_prot = {
> >  	.diag_destroy		= tcp_abort,
> >  };
> >
> > -static struct inet6_protocol tcpv6_protocol = {
> > +static const struct inet6_protocol tcpv6_protocol = {
> >  	.early_demux	=	tcp_v6_early_demux,
> >  	.early_demux_handler =  tcp_v6_early_demux,
> >  	.handler	=	tcp_v6_rcv,
> > diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> > index 4a3e656..5f8b8d7 100644
> > --- a/net/ipv6/udp.c
> > +++ b/net/ipv6/udp.c
> > @@ -1448,7 +1448,7 @@ int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
> >  }
> >  #endif
> >
> > -static struct inet6_protocol udpv6_protocol = {
> > +static const struct inet6_protocol udpv6_protocol = {
> >  	.early_demux	=	udp_v6_early_demux,
> >  	.early_demux_handler =  udp_v6_early_demux,
> >  	.handler	=	udpv6_rcv,
> >
>
> This change breaks the kernel if one of these sysctls are changed:
> tcp_early_demux, udp_early_demux

Thanks for the feedback.  The structure is passed to:

int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char
protocol)
{
	return !cmpxchg((const struct inet6_protocol **)&inet6_protos[protocol],
			NULL, prot) ? 0 : -1;
}

I guess that things go wrong because inet6_protos does not really contain
const structures, as hinted by the cast?  And the purpose of declaring a
parameter as const when it is not is to allow things that actually are
able to be const to be passed in here?

thanks,
julia

>
> Check commit dddb64bcb346 ("net: Add sysctl to toggle early demux for
> tcp and udp") why at least 2 structures were no longer const.
>
> (none):~# echo 0 >/proc/sys/net/ipv4/udp_early_demux
> [  101.746108] BUG: unable to handle kernel paging request at ffffffffb98cf5c0
> [  101.753093] IP: proc_udp_early_demux+0x46/0x60
> [  101.757565] PGD 13f540a067
> [  101.757565] P4D 13f540a067
> [  101.760372] PUD 13f540b063
> [  101.763171] PMD 80000013f50001e1
> [  101.765960]
> [  101.770790] Oops: 0003 [#1] SMP
> [  101.774376] gsmi: Log Shutdown Reason 0x03
> [  101.778473] Modules linked in: w1_therm wire cdc_acm ehci_pci ehci_hcd mlx4_en ib_uverbs mlx4_ib ib_core mlx4_core
> [  101.788890] CPU: 3 PID: 8819 Comm: bash Not tainted 4.13.0-smp-DEV #290
> [  101.795549] Hardware name: Intel RML,PCH/Iota_QC_19, BIOS 2.40.0 06/22/2016
> [  101.802517] task: ffff8e733b9c4140 task.stack: ffffa43548cd0000
> [  101.808445] RIP: 0010:proc_udp_early_demux+0x46/0x60
> [  101.813445] RSP: 0018:ffffa43548cd3e60 EFLAGS: 00010246
> [  101.818676] RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000000
> [  101.825816] RDX: ffffffffb98cf5c0 RSI: 0000000000000000 RDI: ffff8e733f400100
> [  101.832957] RBP: ffffa43548cd3e68 R08: 0000000000000000 R09: 0000000000000001
> [  101.840096] R10: 0000000000000008 R11: f000000000000000 R12: 0000000000000001
> [  101.847260] R13: ffffffffffffffea R14: 0000000000000002 R15: ffffffffb9d00380
> [  101.854434] FS:  00007f7e1f34a700(0000) GS:ffff8e733f8c0000(0000) knlGS:0000000000000000
> [  101.862518] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [  101.868263] CR2: ffffffffb98cf5c0 CR3: 000000100f0c8000 CR4: 00000000001406e0
> [  101.875439] Call Trace:
> [  101.877888]  proc_sys_call_handler+0xf3/0x190
> [  101.882260]  proc_sys_write+0x14/0x20
> [  101.885944]  vfs_write+0xc8/0x1e0
> [  101.889261]  SyS_write+0x48/0xa0
> [  101.892520]  entry_SYSCALL_64_fastpath+0x13/0x94
> [  101.897137] RIP: 0033:0x7f7e1ebd64a0
> [  101.900707] RSP: 002b:00007ffcbb851c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
> [  101.908306] RAX: ffffffffffffffda RBX: 000000000232aba8 RCX: 00007f7e1ebd64a0
> [  101.915437] RDX: 0000000000000002 RSI: 00000000022ea808 RDI: 0000000000000001
> [  101.922567] RBP: 00007ffcbb851c50 R08: 00007f7e1ef691b0 R09: 00007f7e1f34a700
> [  101.929698] R10: 000000000048926a R11: 0000000000000246 R12: 000000000232b288
> [  101.936871] R13: 0000000002325e28 R14: 00000000022f0ce8 R15: 0000000000000000
> [  101.944012] Code: 15 e8 07 84 00 8b 0d 9a 3c 7d 00 48 85 d2 74 09 31 f6 85 c9 75 21 48 89 32 48 8b 15 4d 30 84 00 48 85 d2 74 09 31 f6 85 c9 75 06 <48> 89 32 5b 5d c3 48 8b 72 08 eb f4 48 8b 72 08 eb d9 0f 1f 84
> [  101.962907] RIP: proc_udp_early_demux+0x46/0x60 RSP: ffffa43548cd3e60
> [  101.969353] CR2: ffffffffb98cf5c0
> [  101.972680] ---[ end trace 116c0975bf9e19dd ]---
> [  101.977307] Kernel panic - not syncing: Fatal exception
> [  101.982590] Kernel Offset: 0x37e00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
>
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ipv6: constify inet6_protocol structures
  2017-07-31  9:56   ` Eric Dumazet
  2017-07-31 10:10     ` Julia Lawall
@ 2017-08-01  5:59     ` Julia Lawall
  2017-08-01 16:03       ` David Ahern
  1 sibling, 1 reply; 9+ messages in thread
From: Julia Lawall @ 2017-08-01  5:59 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S. Miller, bhumirks, netdev



On Mon, 31 Jul 2017, Eric Dumazet wrote:

> On Fri, 2017-07-28 at 22:18 +0200, Julia Lawall wrote:
> > The inet6_protocol structure is only passed as the first argument to
> > inet6_add_protocol or inet6_del_protocol, both of which are declared as
> > const.  Thus the inet6_protocol structure itself can be const.
> >
> > Also drop __read_mostly where present on the newly const structures.
> >
> > Done with the help of Coccinelle.
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > ---
> >  net/ipv6/ip6_gre.c  |    2 +-
> >  net/ipv6/tcp_ipv6.c |    2 +-
> >  net/ipv6/udp.c      |    2 +-
> >  3 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> > index 67ff2aa..33865d6 100644
> > --- a/net/ipv6/ip6_gre.c
> > +++ b/net/ipv6/ip6_gre.c
> > @@ -1080,7 +1080,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
> >  }
> >
> >
> > -static struct inet6_protocol ip6gre_protocol __read_mostly = {
> > +static const struct inet6_protocol ip6gre_protocol = {
> >  	.handler     = gre_rcv,
> >  	.err_handler = ip6gre_err,
> >  	.flags       = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
> > diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> > index 90a3257..2968a33 100644
> > --- a/net/ipv6/tcp_ipv6.c
> > +++ b/net/ipv6/tcp_ipv6.c
> > @@ -1945,7 +1945,7 @@ struct proto tcpv6_prot = {
> >  	.diag_destroy		= tcp_abort,
> >  };
> >
> > -static struct inet6_protocol tcpv6_protocol = {
> > +static const struct inet6_protocol tcpv6_protocol = {
> >  	.early_demux	=	tcp_v6_early_demux,
> >  	.early_demux_handler =  tcp_v6_early_demux,
> >  	.handler	=	tcp_v6_rcv,
> > diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> > index 4a3e656..5f8b8d7 100644
> > --- a/net/ipv6/udp.c
> > +++ b/net/ipv6/udp.c
> > @@ -1448,7 +1448,7 @@ int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
> >  }
> >  #endif
> >
> > -static struct inet6_protocol udpv6_protocol = {
> > +static const struct inet6_protocol udpv6_protocol = {
> >  	.early_demux	=	udp_v6_early_demux,
> >  	.early_demux_handler =  udp_v6_early_demux,
> >  	.handler	=	udpv6_rcv,
> >
>
> This change breaks the kernel if one of these sysctls are changed:
> tcp_early_demux, udp_early_demux

The other patch in the series has the same problem and should be dropped
too.

julia


>
> Check commit dddb64bcb346 ("net: Add sysctl to toggle early demux for
> tcp and udp") why at least 2 structures were no longer const.
>
> (none):~# echo 0 >/proc/sys/net/ipv4/udp_early_demux
> [  101.746108] BUG: unable to handle kernel paging request at ffffffffb98cf5c0
> [  101.753093] IP: proc_udp_early_demux+0x46/0x60
> [  101.757565] PGD 13f540a067
> [  101.757565] P4D 13f540a067
> [  101.760372] PUD 13f540b063
> [  101.763171] PMD 80000013f50001e1
> [  101.765960]
> [  101.770790] Oops: 0003 [#1] SMP
> [  101.774376] gsmi: Log Shutdown Reason 0x03
> [  101.778473] Modules linked in: w1_therm wire cdc_acm ehci_pci ehci_hcd mlx4_en ib_uverbs mlx4_ib ib_core mlx4_core
> [  101.788890] CPU: 3 PID: 8819 Comm: bash Not tainted 4.13.0-smp-DEV #290
> [  101.795549] Hardware name: Intel RML,PCH/Iota_QC_19, BIOS 2.40.0 06/22/2016
> [  101.802517] task: ffff8e733b9c4140 task.stack: ffffa43548cd0000
> [  101.808445] RIP: 0010:proc_udp_early_demux+0x46/0x60
> [  101.813445] RSP: 0018:ffffa43548cd3e60 EFLAGS: 00010246
> [  101.818676] RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000000
> [  101.825816] RDX: ffffffffb98cf5c0 RSI: 0000000000000000 RDI: ffff8e733f400100
> [  101.832957] RBP: ffffa43548cd3e68 R08: 0000000000000000 R09: 0000000000000001
> [  101.840096] R10: 0000000000000008 R11: f000000000000000 R12: 0000000000000001
> [  101.847260] R13: ffffffffffffffea R14: 0000000000000002 R15: ffffffffb9d00380
> [  101.854434] FS:  00007f7e1f34a700(0000) GS:ffff8e733f8c0000(0000) knlGS:0000000000000000
> [  101.862518] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [  101.868263] CR2: ffffffffb98cf5c0 CR3: 000000100f0c8000 CR4: 00000000001406e0
> [  101.875439] Call Trace:
> [  101.877888]  proc_sys_call_handler+0xf3/0x190
> [  101.882260]  proc_sys_write+0x14/0x20
> [  101.885944]  vfs_write+0xc8/0x1e0
> [  101.889261]  SyS_write+0x48/0xa0
> [  101.892520]  entry_SYSCALL_64_fastpath+0x13/0x94
> [  101.897137] RIP: 0033:0x7f7e1ebd64a0
> [  101.900707] RSP: 002b:00007ffcbb851c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
> [  101.908306] RAX: ffffffffffffffda RBX: 000000000232aba8 RCX: 00007f7e1ebd64a0
> [  101.915437] RDX: 0000000000000002 RSI: 00000000022ea808 RDI: 0000000000000001
> [  101.922567] RBP: 00007ffcbb851c50 R08: 00007f7e1ef691b0 R09: 00007f7e1f34a700
> [  101.929698] R10: 000000000048926a R11: 0000000000000246 R12: 000000000232b288
> [  101.936871] R13: 0000000002325e28 R14: 00000000022f0ce8 R15: 0000000000000000
> [  101.944012] Code: 15 e8 07 84 00 8b 0d 9a 3c 7d 00 48 85 d2 74 09 31 f6 85 c9 75 21 48 89 32 48 8b 15 4d 30 84 00 48 85 d2 74 09 31 f6 85 c9 75 06 <48> 89 32 5b 5d c3 48 8b 72 08 eb f4 48 8b 72 08 eb d9 0f 1f 84
> [  101.962907] RIP: proc_udp_early_demux+0x46/0x60 RSP: ffffa43548cd3e60
> [  101.969353] CR2: ffffffffb98cf5c0
> [  101.972680] ---[ end trace 116c0975bf9e19dd ]---
> [  101.977307] Kernel panic - not syncing: Fatal exception
> [  101.982590] Kernel Offset: 0x37e00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
>
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ipv6: constify inet6_protocol structures
  2017-08-01  5:59     ` Julia Lawall
@ 2017-08-01 16:03       ` David Ahern
  2017-08-01 16:06         ` Julia Lawall
  0 siblings, 1 reply; 9+ messages in thread
From: David Ahern @ 2017-08-01 16:03 UTC (permalink / raw)
  To: Julia Lawall, Eric Dumazet; +Cc: David S. Miller, bhumirks, netdev

On 7/31/17 11:59 PM, Julia Lawall wrote:
>> This change breaks the kernel if one of these sysctls are changed:
>> tcp_early_demux, udp_early_demux
> 
> The other patch in the series has the same problem and should be dropped
> too.
> 
> julia

Julia: are you going to send a revert patch? Right now I have to do that
manually before launching test scripts.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ipv6: constify inet6_protocol structures
  2017-08-01 16:03       ` David Ahern
@ 2017-08-01 16:06         ` Julia Lawall
  0 siblings, 0 replies; 9+ messages in thread
From: Julia Lawall @ 2017-08-01 16:06 UTC (permalink / raw)
  To: David Ahern; +Cc: Eric Dumazet, David S. Miller, bhumirks, netdev



On Tue, 1 Aug 2017, David Ahern wrote:

> On 7/31/17 11:59 PM, Julia Lawall wrote:
> >> This change breaks the kernel if one of these sysctls are changed:
> >> tcp_early_demux, udp_early_demux
> >
> > The other patch in the series has the same problem and should be dropped
> > too.
> >
> > julia
>
> Julia: are you going to send a revert patch? Right now I have to do that
> manually before launching test scripts.

Sorry, I didn't know it was applied.  I can send it.

julia

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-08-01 16:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-28 20:18 [PATCH 0/2] constify inet6_protocol structures Julia Lawall
2017-07-28 20:18 ` [PATCH 1/2] ipv6: " Julia Lawall
2017-07-31  9:56   ` Eric Dumazet
2017-07-31 10:10     ` Julia Lawall
2017-08-01  5:59     ` Julia Lawall
2017-08-01 16:03       ` David Ahern
2017-08-01 16:06         ` Julia Lawall
2017-07-28 20:18 ` [PATCH 2/2] l2tp: " Julia Lawall
2017-07-29  1:53 ` [PATCH 0/2] " David Miller

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).