Message ID | E1mS5U9-002wsa-TC@rmk-PC.armlinux.org.uk (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] net: sched: fix initialiser warning in sch_frag.c | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 8 of 8 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 1 this patch: 1 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 8 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 1 this patch: 1 |
netdev/header_inline | success | Link |
On Sun, Sep 19, 2021 at 11:40:33PM +0100, Russell King (Oracle) wrote: > Debian gcc 10.2.1 complains thusly: Correction: this is with ARM gcc 4.9.4 with the 5.14 kernel which is no longer supported by 5.15-rc. Please ignore. > > net/sched/sch_frag.c:93:10: warning: missing braces around initializer [-Wmissing-braces] > struct rtable sch_frag_rt = { 0 }; > ^ > net/sched/sch_frag.c:93:10: warning: (near initialization for 'sch_frag_rt.dst') [-Wmissing-braces] > > Fix it by removing the unnecessary '0' initialiser, leaving the > braces. > > Fixes: 31fe34a0118e ("net/sched: sch_frag: fix stack OOB read while fragmenting IPv4 packets") > Suggested-by: Michael Ellerman <mpe@ellerman.id.au> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> > --- > net/sched/sch_frag.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/sched/sch_frag.c b/net/sched/sch_frag.c > index 8c06381391d6..ab359d63287c 100644 > --- a/net/sched/sch_frag.c > +++ b/net/sched/sch_frag.c > @@ -90,7 +90,7 @@ static int sch_fragment(struct net *net, struct sk_buff *skb, > } > > if (skb_protocol(skb, true) == htons(ETH_P_IP)) { > - struct rtable sch_frag_rt = { 0 }; > + struct rtable sch_frag_rt = { }; > unsigned long orig_dst; > > sch_frag_prepare_frag(skb, xmit); > -- > 2.30.2 > >
On Sun, Sep 19, 2021 at 11:40:33PM +0100, Russell King (Oracle) wrote: > Debian gcc 10.2.1 complains thusly: > > net/sched/sch_frag.c:93:10: warning: missing braces around initializer [-Wmissing-braces] > struct rtable sch_frag_rt = { 0 }; > ^ > net/sched/sch_frag.c:93:10: warning: (near initialization for 'sch_frag_rt.dst') [-Wmissing-braces] > > Fix it by removing the unnecessary '0' initialiser, leaving the > braces. hello Russell, thanks a lot for reporting! > diff --git a/net/sched/sch_frag.c b/net/sched/sch_frag.c > index 8c06381391d6..ab359d63287c 100644 > --- a/net/sched/sch_frag.c > +++ b/net/sched/sch_frag.c > @@ -90,7 +90,7 @@ static int sch_fragment(struct net *net, struct sk_buff *skb, > } > > if (skb_protocol(skb, true) == htons(ETH_P_IP)) { > - struct rtable sch_frag_rt = { 0 }; > + struct rtable sch_frag_rt = { }; this surely fixes the -Wmissing-braces, but then -Wpedantic would complain about usage of GNU extension (I just tried on godbolt with x86_64 gcc 11.2): warning: ISO C forbids empty initializer braces [-Wpedantic] While we are fixing this, probably the best thing is to initialize the 'dst' struct member to 0: in my understanding this should be sufficient to let the compiler fill all the struct members with 0. Oh, and I might have inserted a similar thing in openvswitch kernel module (see [1]), if you agree I will send a patch that fixes this as well. WDYT?
On Mon, Sep 20, 2021 at 11:08:53AM +0200, Davide Caratti wrote: > On Sun, Sep 19, 2021 at 11:40:33PM +0100, Russell King (Oracle) wrote: > > Debian gcc 10.2.1 complains thusly: > > > > net/sched/sch_frag.c:93:10: warning: missing braces around initializer [-Wmissing-braces] > > struct rtable sch_frag_rt = { 0 }; > > ^ > > net/sched/sch_frag.c:93:10: warning: (near initialization for 'sch_frag_rt.dst') [-Wmissing-braces] > > > > Fix it by removing the unnecessary '0' initialiser, leaving the > > braces. > > hello Russell, thanks a lot for reporting! > > > diff --git a/net/sched/sch_frag.c b/net/sched/sch_frag.c > > index 8c06381391d6..ab359d63287c 100644 > > --- a/net/sched/sch_frag.c > > +++ b/net/sched/sch_frag.c > > @@ -90,7 +90,7 @@ static int sch_fragment(struct net *net, struct sk_buff *skb, > > } > > > > if (skb_protocol(skb, true) == htons(ETH_P_IP)) { > > - struct rtable sch_frag_rt = { 0 }; > > + struct rtable sch_frag_rt = { }; > > this surely fixes the -Wmissing-braces, but then -Wpedantic > would complain about usage of GNU extension (I just tried on godbolt > with x86_64 gcc 11.2): > > warning: ISO C forbids empty initializer braces [-Wpedantic] > > While we are fixing this, probably the best thing is to initialize the > 'dst' struct member to 0: in my understanding this should be sufficient > to let the compiler fill all the struct members with 0. > > Oh, and I might have inserted a similar thing in openvswitch kernel > module (see [1]), if you agree I will send a patch that fixes this as > well. WDYT? ISO C may forbid it, but the kernel build uses -std=gnu89 - which is c89 with GNU extensions. One of the GNU extensions is to allow the empty initialiser, which means "initialise all members of this struct to zero". However, as I say, this was found using gcc 4.9.4 under 5.14, where 4.9.4 is a permissable compiler. However, under 5.15-rc it is no longer so the patch should not be applied to development kernels. It leaves the question open whether it should be fixed in stable or not, since stable kernels _do_ permit gcc 4.9.4.
diff --git a/net/sched/sch_frag.c b/net/sched/sch_frag.c index 8c06381391d6..ab359d63287c 100644 --- a/net/sched/sch_frag.c +++ b/net/sched/sch_frag.c @@ -90,7 +90,7 @@ static int sch_fragment(struct net *net, struct sk_buff *skb, } if (skb_protocol(skb, true) == htons(ETH_P_IP)) { - struct rtable sch_frag_rt = { 0 }; + struct rtable sch_frag_rt = { }; unsigned long orig_dst; sch_frag_prepare_frag(skb, xmit);
Debian gcc 10.2.1 complains thusly: net/sched/sch_frag.c:93:10: warning: missing braces around initializer [-Wmissing-braces] struct rtable sch_frag_rt = { 0 }; ^ net/sched/sch_frag.c:93:10: warning: (near initialization for 'sch_frag_rt.dst') [-Wmissing-braces] Fix it by removing the unnecessary '0' initialiser, leaving the braces. Fixes: 31fe34a0118e ("net/sched: sch_frag: fix stack OOB read while fragmenting IPv4 packets") Suggested-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> --- net/sched/sch_frag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)