Skip to contentSkip to conversation

net: switchdev: add reminder near struct switchdev_notifier_fdb_info

PATCH Applied Vladimir Oltean 4 participants 4 messages Jun 28, 2022 – Jun 30, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: switchdev: add reminder near struct switchdev_notifier_fdb_info

br_switchdev_fdb_notify() creates an on-stack FDB info variable, and initializes it member by member. As such, newly added fields which are not initialized by br_switchdev_fdb_notify() will contain junk bytes from the stack.

Other uses of struct switchdev_notifier_fdb_info have a struct initializer which should put zeroes in the uninitialized fields.

Add a reminder above the structure for future developers. Recently discussed during review.

---
 include/net/switchdev.h | 3 +++
 1 file changed, 3 insertions(+)
include/net/switchdev.h +3 -0
index aa0171d5786d..7dcdc97c0bc3 100644
@@ -239,6 +239,9 @@ struct switchdev_notifier_info {
 	const void *ctx;
 };
 
+/* Remember to update br_switchdev_fdb_populate() when adding
+ * new members to this structure
+ */
 struct switchdev_notifier_fdb_info {
 	struct switchdev_notifier_info info; /* must be first */
 	const unsigned char *addr;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Vladimir Oltean

br_switchdev_fdb_notify() creates an on-stack FDB info variable, and initializes it member by member. As such, newly added fields which are not initialized by br_switchdev_fdb_notify() will contain junk bytes from the stack.

Other uses of struct switchdev_notifier_fdb_info have a struct initializer which should put zeroes in the uninitialized fields.

Quoted 6 lines

Add a reminder above the structure for future developers. Recently discussed during review.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Vladimir Oltean
Quoted 23 lines · Vladimir Oltean

br_switchdev_fdb_notify() creates an on-stack FDB info variable, and initializes it member by member. As such, newly added fields which are not initialized by br_switchdev_fdb_notify() will contain junk bytes from the stack.

Other uses of struct switchdev_notifier_fdb_info have a struct initializer which should put zeroes in the uninitialized fields.

Add a reminder above the structure for future developers. Recently discussed during review.

---
 include/net/switchdev.h | 3 +++
 1 file changed, 3 insertions(+)
include/net/switchdev.h +0 -0
index aa0171d5786d..7dcdc97c0bc3 100644

include/net/switchdev.h struct switchdev_notifier_info { · line 247

Quoted 9 lines
include/net/switchdev.h +3 -0
@@ -239,6 +239,9 @@ struct switchdev_notifier_info {
 	const void *ctx;
 };
 
+/* Remember to update br_switchdev_fdb_populate() when adding
+ * new members to this structure
+ */
 struct switchdev_notifier_fdb_info {
 	struct switchdev_notifier_info info; /* must be first */
 	const unsigned char *addr;
#3 lore raw
In reply to Vladimir Oltean
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Tue, 28 Jun 2022 13:08:31 +0300 you wrote:

br_switchdev_fdb_notify() creates an on-stack FDB info variable, and initializes it member by member. As such, newly added fields which are not initialized by br_switchdev_fdb_notify() will contain junk bytes from the stack.

Other uses of struct switchdev_notifier_fdb_info have a struct initializer which should put zeroes in the uninitialized fields.

[...]

Here is the summary with links:
- [net-next] net: switchdev: add reminder near struct switchdev_notifier_fdb_info

    https://git.kernel.org/netdev/net-next/c/3eb4a4c3442c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html