Skip to content

Commit e7af210

Browse files
Florian Westphaldavem330
authored andcommitted
netfilter: nft_payload: reject out-of-range attributes via policy
Now that nla_policy allows range checks for bigendian data make use of this to reject such attributes. At this time, reject happens later from the init or select_ops callbacks, but its prone to errors. In the future, new attributes can be handled via NLA_POLICY_MAX_BE and exiting ones can be converted one by one. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 08724ef commit e7af210

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/netfilter/nft_payload.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ static const struct nla_policy nft_payload_policy[NFTA_PAYLOAD_MAX + 1] = {
173173
[NFTA_PAYLOAD_SREG] = { .type = NLA_U32 },
174174
[NFTA_PAYLOAD_DREG] = { .type = NLA_U32 },
175175
[NFTA_PAYLOAD_BASE] = { .type = NLA_U32 },
176-
[NFTA_PAYLOAD_OFFSET] = { .type = NLA_U32 },
177-
[NFTA_PAYLOAD_LEN] = { .type = NLA_U32 },
176+
[NFTA_PAYLOAD_OFFSET] = NLA_POLICY_MAX_BE(NLA_U32, 255),
177+
[NFTA_PAYLOAD_LEN] = NLA_POLICY_MAX_BE(NLA_U32, 255),
178178
[NFTA_PAYLOAD_CSUM_TYPE] = { .type = NLA_U32 },
179-
[NFTA_PAYLOAD_CSUM_OFFSET] = { .type = NLA_U32 },
179+
[NFTA_PAYLOAD_CSUM_OFFSET] = NLA_POLICY_MAX_BE(NLA_U32, 255),
180180
[NFTA_PAYLOAD_CSUM_FLAGS] = { .type = NLA_U32 },
181181
};
182182

0 commit comments

Comments
 (0)