Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
a69069d0
Commit
a69069d0
authored
Aug 02, 2003
by
Daniel Ritz
Committed by
David S. Miller
Aug 02, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IPV6]: Fix memory leak in esp6_input.
parent
86b125f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
13 deletions
+25
-13
net/ipv6/esp6.c
net/ipv6/esp6.c
+25
-13
No files found.
net/ipv6/esp6.c
View file @
a69069d0
...
...
@@ -203,18 +203,24 @@ int esp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_b
int
hdr_len
=
skb
->
h
.
raw
-
skb
->
nh
.
raw
;
int
nfrags
;
u8
ret_nexthdr
=
0
;
unsigned
char
*
tmp_hdr
=
NULL
;
int
ret
=
0
;
if
(
!
pskb_may_pull
(
skb
,
sizeof
(
struct
ipv6_esp_hdr
)))
goto
out
;
if
(
!
pskb_may_pull
(
skb
,
sizeof
(
struct
ipv6_esp_hdr
)))
{
ret
=
-
EINVAL
;
goto
out_nofree
;
}
if
(
elen
<=
0
||
(
elen
&
(
blksize
-
1
)))
goto
out
;
if
(
elen
<=
0
||
(
elen
&
(
blksize
-
1
)))
{
ret
=
-
EINVAL
;
goto
out_nofree
;
}
tmp_hdr
=
kmalloc
(
hdr_len
,
GFP_ATOMIC
);
if
(
!
tmp_hdr
)
goto
out
;
if
(
!
tmp_hdr
)
{
ret
=
-
ENOMEM
;
goto
out_nofree
;
}
memcpy
(
tmp_hdr
,
skb
->
nh
.
raw
,
hdr_len
);
/* If integrity check is required, do this. */
...
...
@@ -229,12 +235,15 @@ int esp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_b
if
(
unlikely
(
memcmp
(
sum
,
sum1
,
alen
)))
{
x
->
stats
.
integrity_failed
++
;
ret
=
-
EINVAL
;
goto
out
;
}
}
if
((
nfrags
=
skb_cow_data
(
skb
,
0
,
&
trailer
))
<
0
)
if
((
nfrags
=
skb_cow_data
(
skb
,
0
,
&
trailer
))
<
0
)
{
ret
=
-
EINVAL
;
goto
out
;
}
skb
->
ip_summed
=
CHECKSUM_NONE
;
...
...
@@ -254,8 +263,10 @@ int esp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_b
if
(
unlikely
(
nfrags
>
MAX_SG_ONSTACK
))
{
sg
=
kmalloc
(
sizeof
(
struct
scatterlist
)
*
nfrags
,
GFP_ATOMIC
);
if
(
!
sg
)
if
(
!
sg
)
{
ret
=
-
ENOMEM
;
goto
out
;
}
}
skb_to_sgvec
(
skb
,
sg
,
sizeof
(
struct
ipv6_esp_hdr
)
+
esp
->
conf
.
ivlen
,
elen
);
crypto_cipher_decrypt
(
esp
->
conf
.
tfm
,
sg
,
sg
,
elen
);
...
...
@@ -270,6 +281,7 @@ int esp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_b
if
(
net_ratelimit
())
{
printk
(
KERN_WARNING
"ipsec esp packet is garbage padlen=%d, elen=%d
\n
"
,
padlen
+
2
,
elen
);
}
ret
=
-
EINVAL
;
goto
out
;
}
/* ... check padding bits here. Silly. :-) */
...
...
@@ -280,13 +292,13 @@ int esp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_b
memcpy
(
skb
->
nh
.
raw
,
tmp_hdr
,
hdr_len
);
skb
->
nh
.
ipv6h
->
payload_len
=
htons
(
skb
->
len
-
sizeof
(
struct
ipv6hdr
));
ip6_find_1stfragopt
(
skb
,
&
prevhdr
);
ret
_nexthdr
=
*
prevhdr
=
nexthdr
[
1
];
ret
=
*
prevhdr
=
nexthdr
[
1
];
}
kfree
(
tmp_hdr
);
return
ret_nexthdr
;
out:
return
-
EINVAL
;
kfree
(
tmp_hdr
);
out_nofree:
return
ret
;
}
static
u32
esp6_get_max_size
(
struct
xfrm_state
*
x
,
int
mtu
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment