netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: check type when freeing metadata dst
@ 2017-08-18 12:16 David Lamparter
  2017-08-18 12:25 ` Sergei Shtylyov
  0 siblings, 1 reply; 4+ messages in thread
From: David Lamparter @ 2017-08-18 12:16 UTC (permalink / raw)
  To: netdev
  Cc: David Lamparter, Jakub Kicinski, Sridhar Samudrala, Simon Horman,
	David S . Miller

There is a new metadata dst type field added in "net: store
port/representator id in metadata_dst", but metadata_dst_free() wasn't
updated to check it before freeing the METADATA_IP_TUNNEL specific dst
cache entry.

This is not currently causing problems since it's far enough back in the
struct to be zeroed for the only other type currently in existance
(METADATA_HW_PORT_MUX), but nevertheless it's not correct.

Fixes: 3fcece12bc1b6dcdf0986f2cd9e8f63b1f9b6aa0
Signed-off-by: David Lamparter <equinox@diac24.net>
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Sridhar Samudrala <sridhar.samudrala@intel.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: David S. Miller <davem@davemloft.net>
---
 net/core/dst.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/core/dst.c b/net/core/dst.c
index 00aa972ad1a1..7954d1710d97 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -299,7 +299,8 @@ EXPORT_SYMBOL_GPL(metadata_dst_alloc);
 void metadata_dst_free(struct metadata_dst *md_dst)
 {
 #ifdef CONFIG_DST_CACHE
-	dst_cache_destroy(&md_dst->u.tun_info.dst_cache);
+	if (md_dst->type == METADATA_IP_TUNNEL)
+		dst_cache_destroy(&md_dst->u.tun_info.dst_cache);
 #endif
 	kfree(md_dst);
 }
-- 
2.13.0

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

* Re: [PATCH net-next] net: check type when freeing metadata dst
  2017-08-18 12:16 [PATCH net-next] net: check type when freeing metadata dst David Lamparter
@ 2017-08-18 12:25 ` Sergei Shtylyov
  2017-08-18 12:31   ` David Lamparter
  0 siblings, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2017-08-18 12:25 UTC (permalink / raw)
  To: David Lamparter, netdev
  Cc: Jakub Kicinski, Sridhar Samudrala, Simon Horman, David S . Miller

Hello!

On 08/18/2017 03:16 PM, David Lamparter wrote:

> There is a new metadata dst type field added in "net: store
> port/representator id in metadata_dst", but metadata_dst_free() wasn't
> updated to check it before freeing the METADATA_IP_TUNNEL specific dst
> cache entry.
> 
> This is not currently causing problems since it's far enough back in the
> struct to be zeroed for the only other type currently in existance
> (METADATA_HW_PORT_MUX), but nevertheless it's not correct.
> 
> Fixes: 3fcece12bc1b6dcdf0986f2cd9e8f63b1f9b6aa0

    Please see Documentation/process/submitting-patches.rst on how this tag 
(and the commit citing in your description as well) should look like.

> Signed-off-by: David Lamparter <equinox@diac24.net>
> Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
> Cc: Sridhar Samudrala <sridhar.samudrala@intel.com>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: David S. Miller <davem@davemloft.net>

[...]

MBR, Sergei

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

* [PATCH net-next] net: check type when freeing metadata dst
  2017-08-18 12:25 ` Sergei Shtylyov
@ 2017-08-18 12:31   ` David Lamparter
  2017-08-21 17:57     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: David Lamparter @ 2017-08-18 12:31 UTC (permalink / raw)
  To: netdev
  Cc: David Lamparter, Jakub Kicinski, Sridhar Samudrala, Simon Horman,
	David S . Miller

Commit 3fcece12bc1b ("net: store port/representator id in metadata_dst")
added a new type field to metadata_dst, but metadata_dst_free() wasn't
updated to check it before freeing the METADATA_IP_TUNNEL specific dst
cache entry.

This is not currently causing problems since it's far enough back in the
struct to be zeroed for the only other type currently in existance
(METADATA_HW_PORT_MUX), but nevertheless it's not correct.

Fixes: 3fcece12bc1b ("net: store port/representator id in metadata_dst")
Signed-off-by: David Lamparter <equinox@diac24.net>
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Sridhar Samudrala <sridhar.samudrala@intel.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: David S. Miller <davem@davemloft.net>
---
 net/core/dst.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/core/dst.c b/net/core/dst.c
index 00aa972ad1a1..7954d1710d97 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -299,7 +299,8 @@ EXPORT_SYMBOL_GPL(metadata_dst_alloc);
 void metadata_dst_free(struct metadata_dst *md_dst)
 {
 #ifdef CONFIG_DST_CACHE
-	dst_cache_destroy(&md_dst->u.tun_info.dst_cache);
+	if (md_dst->type == METADATA_IP_TUNNEL)
+		dst_cache_destroy(&md_dst->u.tun_info.dst_cache);
 #endif
 	kfree(md_dst);
 }
-- 
2.13.0

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

* Re: [PATCH net-next] net: check type when freeing metadata dst
  2017-08-18 12:31   ` David Lamparter
@ 2017-08-21 17:57     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-08-21 17:57 UTC (permalink / raw)
  To: equinox; +Cc: netdev, jakub.kicinski, sridhar.samudrala, horms

From: David Lamparter <equinox@diac24.net>
Date: Fri, 18 Aug 2017 14:31:35 +0200

> Commit 3fcece12bc1b ("net: store port/representator id in metadata_dst")
> added a new type field to metadata_dst, but metadata_dst_free() wasn't
> updated to check it before freeing the METADATA_IP_TUNNEL specific dst
> cache entry.
> 
> This is not currently causing problems since it's far enough back in the
> struct to be zeroed for the only other type currently in existance
> (METADATA_HW_PORT_MUX), but nevertheless it's not correct.
> 
> Fixes: 3fcece12bc1b ("net: store port/representator id in metadata_dst")
> Signed-off-by: David Lamparter <equinox@diac24.net>

Applied.

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

end of thread, other threads:[~2017-08-21 17:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-18 12:16 [PATCH net-next] net: check type when freeing metadata dst David Lamparter
2017-08-18 12:25 ` Sergei Shtylyov
2017-08-18 12:31   ` David Lamparter
2017-08-21 17:57     ` 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).