Kir Kolyshkin wrote:
I am currently checking all the ~80 patches that are not in openvz
lenny kernel. Looks like most are really needed. Let me suggest some
in a few emails I will send as a reply to this one.
Here is a set of netfilter patches, quite a few. Some are very critical
(read security-related) since they fix various container/host isolation
issues, others are to prevent kernel oopses...
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=8562975430153848dd817a050133 b53adda96910
nf: fix use after free
Fix use after free error, found by internal testing. Not an ABI breaker.
Attached as 0010*
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=fa7ac0b2423dc741cd7016565545 abb8e36c4af4
nf: fix call to kmem_cache_destroy from VEs
Found by internal testing. Not an ABI breaker.
Attached as 0011*
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=17b09e1de42db77743ea9ae3dfd3 a910ac57ee71
conntrack: prevent double allocate/free of protos
Found by internal testing. Not an ABI breaker.
Attached as 0022*
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=7d3f10fc5d8e268f7572cfdd2287 c049bce3af7c
conntrack: prevent call register_pernet_subsys() from VE context
Found by internal audit. Not an ABI breaker.
Attached as 0023*
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=482dd20be37f61b2f94e6b3f3de1 c1b9b4f9e6f1
conntrack: prevent call nf_register_hooks() from VE context
Found by internal audit. Not an ABI breaker.
Attached as 0024*
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=5fff3eb60f78acaadcae8562de5d 3e6504f4d4f9
conntrack: adjust context during freeing
Found by internal audit. Not an ABI breaker.
Attached as 0029*
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=3cb8bc3781889ade74c02840b2eb 8ddafb6d39c5
netfilter: NAT: assign nf_nat_seq_adjust_hook from VE0 context only
Found by internal audit. Not an ABI breaker.
Attached as 0033*
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=490910232ebe61f65e5e5c03b728 6f11291b6092
netfilter: call nf_register_hooks from VE0 context only
Found by internal audit. Not an ABI breaker.
Attached as 0034*
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=1acba8533b788e95c52f827d06d9 629d672c80fc
netfilter: Fix NULL dereference in nf_nat_setup_info.
OpenVZ Bug #1051 (http://bugzilla.openvz.org/1051). Might be an ABI breaker.
Attached as 0047*
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=b405aed753ac48a46e66cccfd0a3 7006fd11feb8
netfilter: Add check to the nat hooks
OpenVZ Bug #1051 (http://bugzilla.openvz.org/1051). Might be an ABI breaker.
Attached as 0048*
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=b5e1f74cee5bc2c45bdca53a7218 fb8de89215dd
netlink: Fix oops in netlink conntrack module
OpenVZ bug #788 (http://bugzilla.openvz.org/788)
Attached as 0053*
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=09686c184a2cb815cbd5af500fe4 68311887d746
Free skb->nf_bridge in veth_xmit() and venet_xmit()
OpenVZ bug #1146 (http://bugzilla.openvz.org/1146)
Attached as 0066*
Call nf_ct_proto_tcp_sysctl_xxx()/nf_ct_proto_tcp_sysctl_cleanup() from
nf_conntrack_init_ve()/nf_conntrack_cleanup_ve() to prevent to be called twice
from functions:
/* Source NAT */
static unsigned int ipt_snat_target(struct sk_buff *skb,
@@ -202,7 +196,8 @@ int nf_nat_rule_find(struct sk_buff *skb,
{
int ret;
- ret = ipt_do_table(skb, hooknum, in, out, nat_table);
+ ret = ipt_do_table(skb, hooknum, in, out,
+ nf_net(hooknum, in, out)->ipv4.iptable_nat);
if (ret == NF_ACCEPT) {
if (!nf_nat_initialized(ct, HOOK2MANIP(hooknum)))
@@ -237,10 +232,10 @@ int nf_nat_rule_init(void)
int ret;
struct net *net = get_exec_env()->ve_netns;
diff --git a/net/ipv4/netfilter/nf_nat_standalone.c b/net/ipv4/netfilter/nf_nat_standalone.c
index 72f45db..17d7527 100644
--- a/net/ipv4/netfilter/nf_nat_standalone.c
+++ b/net/ipv4/netfilter/nf_nat_standalone.c
@@ -157,6 +157,19 @@ nf_nat_fn(unsigned int hooknum,
}
static unsigned int
+nf_nat_local_in(unsigned int hooknum,
+ struct sk_buff *skb,
+ const struct net_device *in,
+ const struct net_device *out,
+ int (*okfn)(struct sk_buff *))
+{
+ if (!dev_net(in)->ipv4.iptable_nat)
+ return NF_ACCEPT;
+
+ return nf_nat_fn(hooknum, skb, in, out, okfn);
+}
+
+static unsigned int
nf_nat_in(unsigned int hooknum,
struct sk_buff *skb,
const struct net_device *in,
@@ -166,6 +179,9 @@ nf_nat_in(unsigned int hooknum,
unsigned int ret;
__be32 daddr = ip_hdr(skb)->daddr;
+ if (!dev_net(in)->ipv4.iptable_nat)
+ return NF_ACCEPT;
+
ret = nf_nat_fn(hooknum, skb, in, out, okfn);
if (ret != NF_DROP && ret != NF_STOLEN &&
daddr != ip_hdr(skb)->daddr) {
@@ -188,6 +204,9 @@ nf_nat_out(unsigned int hooknum,
#endif
unsigned int ret;
+ if (!dev_net(out)->ipv4.iptable_nat)
+ return NF_ACCEPT;
+
/* root is playing with raw sockets. */
if (skb->len < sizeof(struct iphdr) ||
ip_hdrlen(skb) < sizeof(struct iphdr))
@@ -221,6 +240,9 @@ nf_nat_local_fn(unsigned int hooknum,
enum ip_conntrack_info ctinfo;
unsigned int ret;
+ if (!dev_net(out)->ipv4.iptable_nat)
+ return NF_ACCEPT;
+
/* root is playing with raw sockets. */
if (skb->len < sizeof(struct iphdr) ||
ip_hdrlen(skb) < sizeof(struct iphdr))
@@ -275,7 +297,7 @@ static struct nf_hook_ops nf_nat_ops[] __read_mostly = {
},
/* After packet filtering, change source */
{
- .hook = nf_nat_fn,
+ .hook = nf_nat_local_in,
.owner = THIS_MODULE,
.pf = PF_INET,
.hooknum = NF_INET_LOCAL_IN,
--
1.6.0.6
>From b5e1f74cee5bc2c45bdca53a7218fb8de89215dd Mon Sep 17 00:00:00 2001
From: Pavel Emelyanov <xemul@openvz.org>
Date: Fri, 28 Nov 2008 12:46:11 +0300
Subject: [PATCH] netlink: Fix oops in netlink conntrack module
If we load conntrack modules after ve start one pointer on ve_struct
is NULL and accessing it causes an oops.
This is handled in most of the places, but the netlink interface.
Fix this one as well.
+ if (!ve_nf_ct_initialized())
+ return -ENOPROTOOPT;
+
if (cda[CTA_TUPLE_ORIG])
err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_ORIG, u3);
else if (cda[CTA_TUPLE_REPLY])
@@ -836,6 +839,9 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
u_int8_t u3 = nfmsg->nfgen_family;
int err = 0;
+ if (!ve_nf_ct_initialized())
+ return -ENOPROTOOPT;
+
if (nlh->nlmsg_flags & NLM_F_DUMP) {
#ifndef CONFIG_NF_CT_ACCT
if (NFNL_MSG_TYPE(nlh->nlmsg_type) == IPCTNL_MSG_CT_GET_CTRZERO)
@@ -1203,6 +1209,9 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
u_int8_t u3 = nfmsg->nfgen_family;
int err = 0;
+ if (!ve_nf_ct_initialized())
+ return -ENOPROTOOPT;
+
if (cda[CTA_TUPLE_ORIG]) {
err = ctnetlink_parse_tuple(cda, &otuple, CTA_TUPLE_ORIG, u3);
if (err < 0)
@@ -1527,6 +1536,9 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
u_int8_t u3 = nfmsg->nfgen_family;
int err = 0;
+ if (!ve_nf_ct_initialized())
+ return -ENOPROTOOPT;
+
if (nlh->nlmsg_flags & NLM_F_DUMP) {
return netlink_dump_start(ctnl, skb, nlh,
ctnetlink_exp_dump_table,
@@ -1588,6 +1600,9 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
unsigned int i;
int err;
+ if (!ve_nf_ct_initialized())
+ return -ENOPROTOOPT;
+
if (cda[CTA_EXPECT_TUPLE]) {
/* delete a single expect by tuple */
err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3);
@@ -1726,6 +1741,9 @@ ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb,
u_int8_t u3 = nfmsg->nfgen_family;
int err = 0;
+ if (!ve_nf_ct_initialized())
+ return -ENOPROTOOPT;
+
if (!cda[CTA_EXPECT_TUPLE]
|| !cda[CTA_EXPECT_MASK]
|| !cda[CTA_EXPECT_MASTER])
--
1.6.0.6
>From 09686c184a2cb815cbd5af500fe468311887d746 Mon Sep 17 00:00:00 2001
From: Vitaliy Gusev <vgusev@openvz.org>
Date: Mon, 26 Jan 2009 15:48:02 +0300
Subject: [PATCH] Free skb->nf_bridge in veth_xmit() and venet_xmit()
We free skb->nfct in veth_xmit, but also have to free skb->nf_bridge.
Note: Why it works in 2.6.24-ovz but doesn't work in 2.6.26-ovz ?
1. It issue is only if BRIDGE_NETFILTER=y
2. nf_hook_register() has effect to all VEs in 2.6.26-ovz
(in 2.6.24-ovz doesn't).
Thus bridge hook ip_sabotage_in is not called for 2.6.24-ovz, but
is called for 2.6.26-ovz.
Thanks for the list. I have now made some work to apply this.
Below are some comments.
On Tue, Mar 10, 2009 at 02:00:39AM +0300, Kir Kolyshkin wrote:
> Kir Kolyshkin wrote:
> >I am currently checking all the ~80 patches that are not in openvz
> >lenny kernel. Looks like most are really needed. Let me suggest some
> >in a few emails I will send as a reply to this one.
>
> Here is a set of netfilter patches, quite a few. Some are very critical
> (read security-related) since they fix various container/host isolation
> issues, others are to prevent kernel oopses...
>
> http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=8562975430153848dd817a050133 b53adda96910
> nf: fix use after free
> Fix use after free error, found by internal testing. Not an ABI breaker.
> Attached as 0010*
Already in the debian openvz patch.
>
> http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=fa7ac0b2423dc741cd7016565545 abb8e36c4af4
> nf: fix call to kmem_cache_destroy from VEs
> Found by internal testing. Not an ABI breaker.
> Attached as 0011*
And this one as well.
>
> http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=17b09e1de42db77743ea9ae3dfd3 a910ac57ee71
> conntrack: prevent double allocate/free of protos
> Found by internal testing. Not an ABI breaker.
> Attached as 0022*
The double alloc should not be too much of a problem (or?), but the double free, I assume, can result
in real problems, right?
> http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=7d3f10fc5d8e268f7572cfdd2287 c049bce3af7c
> conntrack: prevent call register_pernet_subsys() from VE context
> Found by internal audit. Not an ABI breaker.
> Attached as 0023*
Security issue!
> http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=482dd20be37f61b2f94e6b3f3de1 c1b9b4f9e6f1
> conntrack: prevent call nf_register_hooks() from VE context
> Found by internal audit. Not an ABI breaker.
> Attached as 0024*
Security issue!
> http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=5fff3eb60f78acaadcae8562de5d 3e6504f4d4f9
> conntrack: adjust context during freeing
> Found by internal audit. Not an ABI breaker.
> Attached as 0029*
Security issue!
> http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=3cb8bc3781889ade74c02840b2eb 8ddafb6d39c5
> netfilter: NAT: assign nf_nat_seq_adjust_hook from VE0 context only
> Found by internal audit. Not an ABI breaker.
> Attached as 0033*
Security issue!
> http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=490910232ebe61f65e5e5c03b728 6f11291b6092
> netfilter: call nf_register_hooks from VE0 context only
> Found by internal audit. Not an ABI breaker.
> Attached as 0034*
Security issue!
> http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=1acba8533b788e95c52f827d06d9 629d672c80fc
> netfilter: Fix NULL dereference in nf_nat_setup_info.
> OpenVZ Bug #1051 (http://bugzilla.openvz.org/1051). Might be an ABI breaker.
> Attached as 0047*
Security issue!
>
> http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=b405aed753ac48a46e66cccfd0a3 7006fd11feb8
> netfilter: Add check to the nat hooks
> OpenVZ Bug #1051 (http://bugzilla.openvz.org/1051). Might be an ABI breaker.
> Attached as 0048*
Is it this part that you are worried about for the ABI breakage?
--
To UNSUBSCRIBE, email to debian-kernel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
03-16-2009, 10:13 AM
Kir Kolyshkin
lenny updates (netfilter)
Ola Lundqvist wrote:
Hi Kir
Thanks for the list. I have now made some work to apply this.
Below are some comments.
On Tue, Mar 10, 2009 at 02:00:39AM +0300, Kir Kolyshkin wrote:
Kir Kolyshkin wrote:
I am currently checking all the ~80 patches that are not in openvz
lenny kernel. Looks like most are really needed. Let me suggest some
in a few emails I will send as a reply to this one.
Here is a set of netfilter patches, quite a few. Some are very critical
(read security-related) since they fix various container/host isolation
issues, others are to prevent kernel oopses...
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=8562975430153848dd817a050133 b53adda96910
nf: fix use after free
Fix use after free error, found by internal testing. Not an ABI breaker.
Attached as 0010*
Already in the debian openvz patch.
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=fa7ac0b2423dc741cd7016565545 abb8e36c4af4
nf: fix call to kmem_cache_destroy from VEs
Found by internal testing. Not an ABI breaker.
Attached as 0011*
And this one as well.
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=17b09e1de42db77743ea9ae3dfd3 a910ac57ee71
conntrack: prevent double allocate/free of protos
Found by internal testing. Not an ABI breaker.
Attached as 0022*
The double alloc should not be too much of a problem (or?), but the double free, I assume, can result
in real problems, right?
Right. Tables are leaked.
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=7d3f10fc5d8e268f7572cfdd2287 c049bce3af7c
conntrack: prevent call register_pernet_subsys() from VE context
Found by internal audit. Not an ABI breaker.
Attached as 0023*
Security issue!
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=482dd20be37f61b2f94e6b3f3de1 c1b9b4f9e6f1
conntrack: prevent call nf_register_hooks() from VE context
Found by internal audit. Not an ABI breaker.
Attached as 0024*
Security issue!
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=5fff3eb60f78acaadcae8562de5d 3e6504f4d4f9
conntrack: adjust context during freeing
Found by internal audit. Not an ABI breaker.
Attached as 0029*
Security issue!
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=3cb8bc3781889ade74c02840b2eb 8ddafb6d39c5
netfilter: NAT: assign nf_nat_seq_adjust_hook from VE0 context only
Found by internal audit. Not an ABI breaker.
Attached as 0033*
Security issue!
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=490910232ebe61f65e5e5c03b728 6f11291b6092
netfilter: call nf_register_hooks from VE0 context only
Found by internal audit. Not an ABI breaker.
Attached as 0034*
Security issue!
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=1acba8533b788e95c52f827d06d9 629d672c80fc
netfilter: Fix NULL dereference in nf_nat_setup_info.
OpenVZ Bug #1051 (http://bugzilla.openvz.org/1051). Might be an ABI breaker.
Attached as 0047*
Security issue!
http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=b405aed753ac48a46e66cccfd0a3 7006fd11feb8
netfilter: Add check to the nat hooks
OpenVZ Bug #1051 (http://bugzilla.openvz.org/1051). Might be an ABI breaker.
Attached as 0048*
Is it this part that you are worried about for the ABI breakage?
I'm not sure why I wrote that. It doesn't look like an ABI breaker.
--
To UNSUBSCRIBE, email to debian-kernel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
03-16-2009, 07:23 PM
Ola Lundqvist
lenny updates (netfilter)
On Mon, Mar 16, 2009 at 02:13:24PM +0300, Kir Kolyshkin wrote:
[...]
> >The double alloc should not be too much of a problem (or?), but the double
> >free, I assume, can result
> >in real problems, right?
> >
>
> Right. Tables are leaked.
Ok.
[...]
> >>http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=b405aed753ac48a46e66cccfd0a3 7006fd11feb8
> >>netfilter: Add check to the nat hooks
> >>OpenVZ Bug #1051 (http://bugzilla.openvz.org/1051). Might be an ABI
> >>breaker.
> >>Attached as 0048*
> >>
> >
> >Is it this part that you are worried about for the ABI breakage?
> >
> > /* After packet filtering, change source */
> > {
> >- .hook = nf_nat_fn,
> >+ .hook = nf_nat_local_in,
> > .owner = THIS_MODULE,
> > .pf = PF_INET,
> > .hooknum = NF_INET_LOCAL_IN,
> >
>
> I'm not sure why I wrote that. It doesn't look like an ABI breaker.
>
--
To UNSUBSCRIBE, email to debian-kernel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
03-17-2009, 04:05 AM
Ola Lundqvist
lenny updates (netfilter)
Hi Kir
After adding this patch it did not build, which is quite obvious because when I read the
features/all/openvz/0047-netfilter-Fix-NULL-dereference-in-nf_nat_setup_info.patch
patch file it tells that it creates the table there.
CC [M] net/ipv4/ipvs/ip_vs_ftp.o
LD net/ipv4/netfilter/built-in.o
CC [M] net/ipv4/netfilter/nf_nat_rule.o
CC [M] net/ipv4/netfilter/nf_nat_standalone.o
net/ipv4/netfilter/nf_nat_standalone.c: In function ‘nf_nat_local_in’:
net/ipv4/netfilter/nf_nat_standalone.c:166: error: ‘struct netns_ipv4’ has no member named ‘iptable_nat’
net/ipv4/netfilter/nf_nat_standalone.c: In function ‘nf_nat_in’:
net/ipv4/netfilter/nf_nat_standalone.c:182: error: ‘struct netns_ipv4’ has no member named ‘iptable_nat’
net/ipv4/netfilter/nf_nat_standalone.c: In function ‘nf_nat_out’:
net/ipv4/netfilter/nf_nat_standalone.c:207: error: ‘struct netns_ipv4’ has no member named ‘iptable_nat’
net/ipv4/netfilter/nf_nat_standalone.c: In function ‘nf_nat_local_fn’:
net/ipv4/netfilter/nf_nat_standalone.c:243: error: ‘struct netns_ipv4’ has no member named ‘iptable_nat’
make[5]: *** [net/ipv4/netfilter/nf_nat_standalone.o] Fel 1
make[4]: *** [net/ipv4/netfilter] Fel 2
make[3]: *** [net/ipv4] Fel 2
make[2]: *** [net] Fel 2
make[2]: Leaving directory `/home/ola/build/debian/kernel/linux-2.6-2.6.26/debian/build/build_i386_openvz_686'
make[1]: *** [debian/stamps/build_i386_openvz_686_plain] Fel 2
make[1]: Leaving directory `/home/ola/build/debian/kernel/linux-2.6-2.6.26'
make: *** [binary-arch_i386_openvz_686_real] Fel 2
As I understand the 0047* patch is a potential ABI breaker which means that I can not
include 0048* for now.
Initiating a new build now.
Best regards,
// Ola
On Mon, Mar 16, 2009 at 09:23:34PM +0100, Ola Lundqvist wrote:
> On Mon, Mar 16, 2009 at 02:13:24PM +0300, Kir Kolyshkin wrote:
> [...]
> > >The double alloc should not be too much of a problem (or?), but the double
> > >free, I assume, can result
> > >in real problems, right?
> > >
> >
> > Right. Tables are leaked.
>
> Ok.
>
> [...]
> > >>http://git.openvz.org/?p=linux-2.6.26-openvz;a=commitdiff;h=b405aed753ac48a46e66cccfd0a3 7006fd11feb8
> > >>netfilter: Add check to the nat hooks
> > >>OpenVZ Bug #1051 (http://bugzilla.openvz.org/1051). Might be an ABI
> > >>breaker.
> > >>Attached as 0048*
> > >>
> > >
> > >Is it this part that you are worried about for the ABI breakage?
> > >
> > > /* After packet filtering, change source */
> > > {
> > >- .hook = nf_nat_fn,
> > >+ .hook = nf_nat_local_in,
> > > .owner = THIS_MODULE,
> > > .pf = PF_INET,
> > > .hooknum = NF_INET_LOCAL_IN,
> > >
> >
> > I'm not sure why I wrote that. It doesn't look like an ABI breaker.
> >
>
> Ok. Adding this for next patch proposal.
>
> Best regards,
>
> // Ola
>
> --
> --- Inguza Technology AB --- MSc in Information Technology ----
> / ola@inguza.com Annebergsslingan 37
> | opal@debian.org 654 65 KARLSTAD |
> | http://inguza.com/ Mobile: +46 (0)70-332 1551 |
> gpg/f.p.: 7090 A92B 18FE 7994 0C36 4FE4 18A1 B1CF 0FE5 3DD9 /
> ---------------------------------------------------------------
>