From: achurch@achurch.org (Andrew Church)
To: netfilter-devel@lists.samba.org
Subject: [PATCH] Fix oops on bad entry list
Date: Wed, 19 Jun 2002 09:57:31 JST [thread overview]
Message-ID: <3d0fd9cc.63276@achurch.org> (raw)
[Note: I am not subscribed to netfilter-devel; please CC me on any replies]
The patch below fixes an oops that occurs in Linux kernels
<= 2.4.19-pre10 if an entry list passed to IPT_SO_SET_REPLACE contains an
entry with a jump to an invalid position (into the middle of another entry
or outside the list).
--Andrew Church
achurch@achurch.org
http://achurch.org/
--- net/ipv4/netfilter/ip_tables.c.old Fri Jun 7 11:50:39 2002
+++ net/ipv4/netfilter/ip_tables.c Wed Jun 19 09:49:01 2002
@@ -739,6 +739,7 @@
unsigned int *i)
{
unsigned int h;
+ struct ipt_standard_target *t;
if ((unsigned long)e % __alignof__(struct ipt_entry) != 0
|| (unsigned char *)e + sizeof(struct ipt_entry) >= limit) {
@@ -751,6 +752,35 @@
duprintf("checking: element %p size %u\n",
e, e->next_offset);
return -EINVAL;
+ }
+
+ if (e->target_offset + sizeof(struct ipt_entry_target)
+ >= e->next_offset) {
+ duprintf("checking: element %p size %u target %u\n",
+ e, e->next_offset, e->target_offset);
+ return -EINVAL;
+ }
+
+ /* If the target is another chain, make sure the pointer is valid */
+ t = (void *)ipt_get_target(e);
+ if (strcmp(t->target.u.user.name, IPT_STANDARD_TARGET) == 0
+ && t->verdict >= 0) {
+ int checkpos = 0;
+ if (t->verdict >= newinfo->size) {
+ duprintf("checking: element %p: jump target %u"
+ " out of range", e, t->verdict);
+ return -EINVAL;
+ }
+ while (checkpos < t->verdict) {
+ struct ipt_entry *e2;
+ e2 = (void *)newinfo->entries + checkpos;
+ checkpos += e2->next_offset;
+ }
+ if (checkpos > t->verdict) {
+ duprintf("checking: element %p: jump target %u"
+ " invalid", e, t->verdict);
+ return -EINVAL;
+ }
}
/* Check hooks & underflows */
reply other threads:[~2002-06-19 0:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3d0fd9cc.63276@achurch.org \
--to=achurch@achurch.org \
--cc=netfilter-devel@lists.samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.