Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netlink: allow NLA_MSECS to have range validation

Since NLA_MSECS is really equivalent to NLA_U64, allow
it to have range validation as well.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Johannes Berg and committed by
David S. Miller
da4063bd d06a09b9

+6 -2
+4 -2
include/net/netlink.h
··· 371 371 #define __NLA_ENSURE(condition) BUILD_BUG_ON_ZERO(!(condition)) 372 372 #define NLA_ENSURE_UINT_TYPE(tp) \ 373 373 (__NLA_ENSURE(tp == NLA_U8 || tp == NLA_U16 || \ 374 - tp == NLA_U32 || tp == NLA_U64) + tp) 374 + tp == NLA_U32 || tp == NLA_U64 || \ 375 + tp == NLA_MSECS) + tp) 375 376 #define NLA_ENSURE_SINT_TYPE(tp) \ 376 377 (__NLA_ENSURE(tp == NLA_S8 || tp == NLA_S16 || \ 377 378 tp == NLA_S32 || tp == NLA_S64) + tp) ··· 380 379 (__NLA_ENSURE(tp == NLA_S8 || tp == NLA_U8 || \ 381 380 tp == NLA_S16 || tp == NLA_U16 || \ 382 381 tp == NLA_S32 || tp == NLA_U32 || \ 383 - tp == NLA_S64 || tp == NLA_U64) + tp) 382 + tp == NLA_S64 || tp == NLA_U64 || \ 383 + tp == NLA_MSECS) + tp) 384 384 #define NLA_ENSURE_NO_VALIDATION_PTR(tp) \ 385 385 (__NLA_ENSURE(tp != NLA_BITFIELD32 && \ 386 386 tp != NLA_REJECT && \
+2
lib/nlattr.c
··· 151 151 value = nla_get_u32(nla); 152 152 break; 153 153 case NLA_U64: 154 + case NLA_MSECS: 154 155 value = nla_get_u64(nla); 155 156 break; 156 157 default: ··· 228 227 case NLA_U16: 229 228 case NLA_U32: 230 229 case NLA_U64: 230 + case NLA_MSECS: 231 231 return nla_validate_int_range_unsigned(pt, nla, extack); 232 232 case NLA_S8: 233 233 case NLA_S16: