Skip to content

Commit 37bd224

Browse files
salyzynklassert
authored andcommitted
af_key: pfkey_dump needs parameter validation
In pfkey_dump() dplen and splen can both be specified to access the xfrm_address_t structure out of bounds in__xfrm_state_filter_match() when it calls addr_match() with the indexes. Return EINVAL if either are out of range. Signed-off-by: Mark Salyzyn <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: Steffen Klassert <[email protected]> Cc: Herbert Xu <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Jakub Kicinski <[email protected]> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Steffen Klassert <[email protected]>
1 parent 101dde4 commit 37bd224

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

net/key/af_key.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,13 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms
18491849
if (ext_hdrs[SADB_X_EXT_FILTER - 1]) {
18501850
struct sadb_x_filter *xfilter = ext_hdrs[SADB_X_EXT_FILTER - 1];
18511851

1852+
if ((xfilter->sadb_x_filter_splen >=
1853+
(sizeof(xfrm_address_t) << 3)) ||
1854+
(xfilter->sadb_x_filter_dplen >=
1855+
(sizeof(xfrm_address_t) << 3))) {
1856+
mutex_unlock(&pfk->dump_lock);
1857+
return -EINVAL;
1858+
}
18521859
filter = kmalloc(sizeof(*filter), GFP_KERNEL);
18531860
if (filter == NULL) {
18541861
mutex_unlock(&pfk->dump_lock);

0 commit comments

Comments
 (0)