mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-27 19:25:05 +07:00
b1993a2de1
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: 4e902c5741
("[IPv4]: FIB configuration using struct fib_config")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
35 lines
865 B
C
35 lines
865 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __NET_NEXTHOP_H
|
|
#define __NET_NEXTHOP_H
|
|
|
|
#include <linux/rtnetlink.h>
|
|
#include <net/netlink.h>
|
|
|
|
static inline int rtnh_ok(const struct rtnexthop *rtnh, int remaining)
|
|
{
|
|
return remaining >= (int)sizeof(*rtnh) &&
|
|
rtnh->rtnh_len >= sizeof(*rtnh) &&
|
|
rtnh->rtnh_len <= remaining;
|
|
}
|
|
|
|
static inline struct rtnexthop *rtnh_next(const struct rtnexthop *rtnh,
|
|
int *remaining)
|
|
{
|
|
int totlen = NLA_ALIGN(rtnh->rtnh_len);
|
|
|
|
*remaining -= totlen;
|
|
return (struct rtnexthop *) ((char *) rtnh + totlen);
|
|
}
|
|
|
|
static inline struct nlattr *rtnh_attrs(const struct rtnexthop *rtnh)
|
|
{
|
|
return (struct nlattr *) ((char *) rtnh + NLA_ALIGN(sizeof(*rtnh)));
|
|
}
|
|
|
|
static inline int rtnh_attrlen(const struct rtnexthop *rtnh)
|
|
{
|
|
return rtnh->rtnh_len - NLA_ALIGN(sizeof(*rtnh));
|
|
}
|
|
|
|
#endif
|