All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: switchdev: add reminder near struct switchdev_notifier_fdb_info
@ 2022-06-28 10:08 Vladimir Oltean
  2022-06-29  6:46 ` Ido Schimmel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Vladimir Oltean @ 2022-06-28 10:08 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jiri Pirko, Ivan Vecera, Roopa Prabhu, Nikolay Aleksandrov,
	Ido Schimmel

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.

Link: https://patchwork.kernel.org/project/netdevbpf/patch/20220524152144.40527-2-schultz.hans+netdev@gmail.com/#24877698
Link: https://patchwork.kernel.org/project/netdevbpf/patch/20220524152144.40527-3-schultz.hans+netdev@gmail.com/#24912269
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 include/net/switchdev.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index aa0171d5786d..7dcdc97c0bc3 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -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;
-- 
2.25.1


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

* Re: [PATCH net-next] net: switchdev: add reminder near struct switchdev_notifier_fdb_info
  2022-06-28 10:08 [PATCH net-next] net: switchdev: add reminder near struct switchdev_notifier_fdb_info Vladimir Oltean
@ 2022-06-29  6:46 ` Ido Schimmel
  2022-06-29  8:07 ` Nikolay Aleksandrov
  2022-06-30  4:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2022-06-29  6:46 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Jiri Pirko, Ivan Vecera, Roopa Prabhu,
	Nikolay Aleksandrov

On Tue, Jun 28, 2022 at 01:08:31PM +0300, Vladimir Oltean 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.
> 
> Add a reminder above the structure for future developers. Recently
> discussed during review.
> 
> Link: https://patchwork.kernel.org/project/netdevbpf/patch/20220524152144.40527-2-schultz.hans+netdev@gmail.com/#24877698
> Link: https://patchwork.kernel.org/project/netdevbpf/patch/20220524152144.40527-3-schultz.hans+netdev@gmail.com/#24912269
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Ido Schimmel <idosch@nvidia.com>

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

* Re: [PATCH net-next] net: switchdev: add reminder near struct switchdev_notifier_fdb_info
  2022-06-28 10:08 [PATCH net-next] net: switchdev: add reminder near struct switchdev_notifier_fdb_info Vladimir Oltean
  2022-06-29  6:46 ` Ido Schimmel
@ 2022-06-29  8:07 ` Nikolay Aleksandrov
  2022-06-30  4:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2022-06-29  8:07 UTC (permalink / raw)
  To: Vladimir Oltean, netdev
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jiri Pirko, Ivan Vecera, Roopa Prabhu, Ido Schimmel

On 28/06/2022 13:08, Vladimir Oltean 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.
> 
> Add a reminder above the structure for future developers. Recently
> discussed during review.
> 
> Link: https://patchwork.kernel.org/project/netdevbpf/patch/20220524152144.40527-2-schultz.hans+netdev@gmail.com/#24877698
> Link: https://patchwork.kernel.org/project/netdevbpf/patch/20220524152144.40527-3-schultz.hans+netdev@gmail.com/#24912269
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  include/net/switchdev.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/net/switchdev.h b/include/net/switchdev.h
> index aa0171d5786d..7dcdc97c0bc3 100644
> --- a/include/net/switchdev.h
> +++ b/include/net/switchdev.h
> @@ -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;

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


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

* Re: [PATCH net-next] net: switchdev: add reminder near struct switchdev_notifier_fdb_info
  2022-06-28 10:08 [PATCH net-next] net: switchdev: add reminder near struct switchdev_notifier_fdb_info Vladimir Oltean
  2022-06-29  6:46 ` Ido Schimmel
  2022-06-29  8:07 ` Nikolay Aleksandrov
@ 2022-06-30  4:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-06-30  4:00 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: netdev, davem, edumazet, kuba, pabeni, jiri, ivecera, roopa,
	razor, idosch

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-06-30  4:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28 10:08 [PATCH net-next] net: switchdev: add reminder near struct switchdev_notifier_fdb_info Vladimir Oltean
2022-06-29  6:46 ` Ido Schimmel
2022-06-29  8:07 ` Nikolay Aleksandrov
2022-06-30  4:00 ` patchwork-bot+netdevbpf

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.