[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211118203241.1287533-1-keescook@chromium.org>
Date: Thu, 18 Nov 2021 12:32:41 -0800
From: Kees Cook <keescook@...omium.org>
To: "David S. Miller" <davem@...emloft.net>
Cc: Kees Cook <keescook@...omium.org>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
David Ahern <dsahern@...nel.org>,
Jakub Kicinski <kuba@...nel.org>, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: [PATCH] ipv6: Use memset_after() to zero rt6_info
In preparation for FORTIFY_SOURCE performing compile-time and run-time
field bounds checking for memset(), avoid intentionally writing across
neighboring fields.
Use memset_after() to clear everything after the dst_entry member of
struct rt6_info.
Signed-off-by: Kees Cook <keescook@...omium.org>
---
net/ipv6/route.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 3ae25b8ffbd6..0cf616b2d013 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -328,9 +328,7 @@ static const struct rt6_info ip6_blk_hole_entry_template = {
static void rt6_info_init(struct rt6_info *rt)
{
- struct dst_entry *dst = &rt->dst;
-
- memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));
+ memset_after(rt, 0, dst);
INIT_LIST_HEAD(&rt->rt6i_uncached);
}
--
2.30.2
Powered by blists - more mailing lists