diff mbox series

[v10,nf-next,1/3] net: pppoe: avoid zero-length arrays in struct pppoe_hdr

Message ID 20250315195910.17659-2-ericwouds@gmail.com (mailing list archive)
State New
Headers show
Series Add nf_flow_encap_push() for xmit direct | expand

Commit Message

Eric Woudstra March 15, 2025, 7:59 p.m. UTC
Jakub Kicinski suggested following patch:

W=1 C=1 GCC build gives us:

net/bridge/netfilter/nf_conntrack_bridge.c: note: in included file (through
../include/linux/if_pppox.h, ../include/uapi/linux/netfilter_bridge.h,
../include/linux/netfilter_bridge.h): include/uapi/linux/if_pppox.h:
153:29: warning: array of flexible structures

It doesn't like that hdr has a zero-length array which overlaps proto.
The kernel code doesn't currently need those arrays.

PPPoE connection is functional after applying this patch.

Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>

---

Split from patch-set: bridge-fastpath and related improvements v9

Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
---
 drivers/net/ppp/pppoe.c       | 2 +-
 include/uapi/linux/if_pppox.h | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Simon Horman March 23, 2025, 4:48 p.m. UTC | #1
On Sat, Mar 15, 2025 at 08:59:08PM +0100, Eric Woudstra wrote:
> Jakub Kicinski suggested following patch:
> 
> W=1 C=1 GCC build gives us:
> 
> net/bridge/netfilter/nf_conntrack_bridge.c: note: in included file (through
> ../include/linux/if_pppox.h, ../include/uapi/linux/netfilter_bridge.h,
> ../include/linux/netfilter_bridge.h): include/uapi/linux/if_pppox.h:
> 153:29: warning: array of flexible structures
> 
> It doesn't like that hdr has a zero-length array which overlaps proto.
> The kernel code doesn't currently need those arrays.
> 
> PPPoE connection is functional after applying this patch.
> 
> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
> 
> ---
> 
> Split from patch-set: bridge-fastpath and related improvements v9
> 
> Signed-off-by: Eric Woudstra <ericwouds@gmail.com>

Hi Eric,

Perhaps this is due to tooling, but your Signed-off-by line should
appear immediately after the Reviewed-by line. No blank line in between.

And, in particular, the Signed-off-by line should appear above the (first)
scissors ("---"), as if git am is used to apply your patch then the
commit message will be truncated at that point. Which results
in a commit with no signed-off-by line.

FWIIW, putting the note about splitting the patch-set below the scissors
looks good to me.

...
Eric Woudstra March 25, 2025, 6:46 a.m. UTC | #2
On 3/23/25 5:48 PM, Simon Horman wrote:
> On Sat, Mar 15, 2025 at 08:59:08PM +0100, Eric Woudstra wrote:
>> Jakub Kicinski suggested following patch:
>>
>> W=1 C=1 GCC build gives us:
>>
>> net/bridge/netfilter/nf_conntrack_bridge.c: note: in included file (through
>> ../include/linux/if_pppox.h, ../include/uapi/linux/netfilter_bridge.h,
>> ../include/linux/netfilter_bridge.h): include/uapi/linux/if_pppox.h:
>> 153:29: warning: array of flexible structures
>>
>> It doesn't like that hdr has a zero-length array which overlaps proto.
>> The kernel code doesn't currently need those arrays.
>>
>> PPPoE connection is functional after applying this patch.
>>
>> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
>>
>> ---
>>
>> Split from patch-set: bridge-fastpath and related improvements v9
>>
>> Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
> 
> Hi Eric,
> 
> Perhaps this is due to tooling, but your Signed-off-by line should
> appear immediately after the Reviewed-by line. No blank line in between.
> 
> And, in particular, the Signed-off-by line should appear above the (first)
> scissors ("---"), as if git am is used to apply your patch then the
> commit message will be truncated at that point. Which results
> in a commit with no signed-off-by line.
> 
> FWIIW, putting the note about splitting the patch-set below the scissors
> looks good to me.
> 
> ...

Thanks, when I noticed it, it was send already. I've changed my script,
so it should not happen anymore.
diff mbox series

Patch

diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index 68e631718ab0..17946af6a8cf 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -882,7 +882,7 @@  static int pppoe_sendmsg(struct socket *sock, struct msghdr *m,
 	skb->protocol = cpu_to_be16(ETH_P_PPP_SES);
 
 	ph = skb_put(skb, total_len + sizeof(struct pppoe_hdr));
-	start = (char *)&ph->tag[0];
+	start = (char *)ph + sizeof(*ph);
 
 	error = memcpy_from_msg(start, m, total_len);
 	if (error < 0) {
diff --git a/include/uapi/linux/if_pppox.h b/include/uapi/linux/if_pppox.h
index 9abd80dcc46f..29b804aa7474 100644
--- a/include/uapi/linux/if_pppox.h
+++ b/include/uapi/linux/if_pppox.h
@@ -122,7 +122,9 @@  struct sockaddr_pppol2tpv3in6 {
 struct pppoe_tag {
 	__be16 tag_type;
 	__be16 tag_len;
+#ifndef __KERNEL__
 	char tag_data[];
+#endif
 } __attribute__ ((packed));
 
 /* Tag identifiers */
@@ -150,7 +152,9 @@  struct pppoe_hdr {
 	__u8 code;
 	__be16 sid;
 	__be16 length;
+#ifndef __KERNEL__
 	struct pppoe_tag tag[];
+#endif
 } __packed;
 
 /* Length of entire PPPoE + PPP header */