From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: [PATCH net 3/8] net: fix rtnh_ok() Date: Sat, 7 Apr 2018 13:42:38 -0700 Message-ID: <20180407204243.176626-4-edumazet@google.com> References: <20180407204243.176626-1-edumazet@google.com> Cc: netdev , Eric Dumazet , Eric Dumazet To: "David S . Miller" Return-path: Received: from mail-pf0-f196.google.com ([209.85.192.196]:45231 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752881AbeDGUnc (ORCPT ); Sat, 7 Apr 2018 16:43:32 -0400 Received: by mail-pf0-f196.google.com with SMTP id l27so3156049pfk.12 for ; Sat, 07 Apr 2018 13:43:32 -0700 (PDT) In-Reply-To: <20180407204243.176626-1-edumazet@google.com> Sender: netdev-owner@vger.kernel.org List-ID: syzbot reported : BUG: KMSAN: uninit-value in rtnh_ok include/net/nexthop.h:11 [inline] BUG: KMSAN: uninit-value in fib_count_nexthops net/ipv4/fib_semantics.c:469 [inline] BUG: KMSAN: uninit-value in fib_create_info+0x554/0x8d20 net/ipv4/fib_semantics.c:1091 @remaining is an integer, coming from user space. If it is negative we want rtnh_ok() to return false. Fixes: 4e902c57417c ("[IPv4]: FIB configuration using struct fib_config") Signed-off-by: Eric Dumazet Reported-by: syzbot --- include/net/nexthop.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/nexthop.h b/include/net/nexthop.h index 36bb794f5cd65cddc60139e7f84024f9f7a1a4cb..902ff382a6dcc6e3f0c1a9a244061e5a84264915 100644 --- a/include/net/nexthop.h +++ b/include/net/nexthop.h @@ -7,7 +7,7 @@ static inline int rtnh_ok(const struct rtnexthop *rtnh, int remaining) { - return remaining >= sizeof(*rtnh) && + return remaining >= (int)sizeof(*rtnh) && rtnh->rtnh_len >= sizeof(*rtnh) && rtnh->rtnh_len <= remaining; } -- 2.17.0.484.g0c8726318c-goog