* [PATCH][netfilter] Avoid a possible NULL pointer deref in recent_seq_open()
@ 2007-07-29 1:08 Jesper Juhl
2007-07-30 12:28 ` Patrick McHardy
0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2007-07-29 1:08 UTC (permalink / raw)
To: Linux Kernel Mailing List
Cc: netfilter-devel, Marc Boucher, Harald Welte, Jesper Juhl,
Rusty Russell, James Morris, David S. Miller, coreteam,
Jozsef Kadlecsik, Patrick McHardy
EHLO,
There is a small problem in
net/ipv4/netfilter/ipt_recent.c::recent_seq_open().
If the call to seq_open() returns != 0 then the code calls
kfree(st) but then on the very next line proceeds to
dereference the pointer - not good.
Problem spotted by the Coverity checker.
Proposed patch to deal with it below.
Compile tested only.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
net/ipv4/netfilter/ipt_recent.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c
index 3218043..6d0c0f7 100644
--- a/net/ipv4/netfilter/ipt_recent.c
+++ b/net/ipv4/netfilter/ipt_recent.c
@@ -387,12 +387,17 @@ static int recent_seq_open(struct inode *inode, struct file *file)
st = kzalloc(sizeof(*st), GFP_KERNEL);
if (st == NULL)
return -ENOMEM;
+
ret = seq_open(file, &recent_seq_ops);
- if (ret)
+ if (ret) {
kfree(st);
+ goto out;
+ }
+
st->table = pde->data;
seq = file->private_data;
seq->private = st;
+out:
return ret;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH][netfilter] Avoid a possible NULL pointer deref in recent_seq_open()
2007-07-29 1:08 [PATCH][netfilter] Avoid a possible NULL pointer deref in recent_seq_open() Jesper Juhl
@ 2007-07-30 12:28 ` Patrick McHardy
0 siblings, 0 replies; 3+ messages in thread
From: Patrick McHardy @ 2007-07-30 12:28 UTC (permalink / raw)
To: Jesper Juhl
Cc: netfilter-devel, Marc Boucher, Harald Welte, Rusty Russell,
Linux Kernel Mailing List, James Morris, coreteam,
Jozsef Kadlecsik, David S. Miller
Jesper Juhl wrote:
> There is a small problem in
> net/ipv4/netfilter/ipt_recent.c::recent_seq_open().
>
> If the call to seq_open() returns != 0 then the code calls
> kfree(st) but then on the very next line proceeds to
> dereference the pointer - not good.
Applied, thanks Jesper.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][netfilter] Avoid a possible NULL pointer deref in recent_seq_open()
@ 2007-07-30 12:28 ` Patrick McHardy
0 siblings, 0 replies; 3+ messages in thread
From: Patrick McHardy @ 2007-07-30 12:28 UTC (permalink / raw)
To: Jesper Juhl
Cc: Linux Kernel Mailing List, netfilter-devel, coreteam,
Rusty Russell, Marc Boucher, James Morris, Harald Welte,
Jozsef Kadlecsik, David S. Miller
Jesper Juhl wrote:
> There is a small problem in
> net/ipv4/netfilter/ipt_recent.c::recent_seq_open().
>
> If the call to seq_open() returns != 0 then the code calls
> kfree(st) but then on the very next line proceeds to
> dereference the pointer - not good.
Applied, thanks Jesper.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-30 12:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-29 1:08 [PATCH][netfilter] Avoid a possible NULL pointer deref in recent_seq_open() Jesper Juhl
2007-07-30 12:28 ` Patrick McHardy
2007-07-30 12:28 ` Patrick McHardy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.