public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Dave Jones <davej@redhat.com>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	torvalds@osdl.org, akpm@osdl.org, alan@lxorguk.ukuu.org.uk,
	Harald Welte <laforge@netfilter.org>,
	Rusty Rusty <rusty@rustcorp.com.au>
Subject: [patch 08/23] [PATCH] [NETFILTER] NAT: Fix module refcount dropping too far
Date: Tue, 22 Nov 2005 13:06:40 -0800	[thread overview]
Message-ID: <20051122210640.GI28140@shell0.pdx.osdl.net> (raw)
In-Reply-To: 20051122205223.099537000@localhost.localdomain

[-- Attachment #1: nat-fix-module-refcount-droppoing-too-far.patch --]
[-- Type: text/plain, Size: 1694 bytes --]

-stable review patch.  If anyone has any objections, please let us know.
------------------

The unknown protocol is used as a fallback when a protocol isn't known.
Hence we cannot handle it failing, so don't set ".me".  It's OK, since we
only grab a reference from within the same module (iptable_nat.ko), so we
never take the module refcount from 0 to 1.

Also, remove the "protocol is NULL" test: it's never NULL.

Signed-off-by: Rusty Rusty <rusty@rustcorp.com.au>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Chris Wright <chrisw@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 net/ipv4/netfilter/ip_nat_core.c          |    6 ++----
 net/ipv4/netfilter/ip_nat_proto_unknown.c |    2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

--- linux-2.6.14.2.orig/net/ipv4/netfilter/ip_nat_core.c
+++ linux-2.6.14.2/net/ipv4/netfilter/ip_nat_core.c
@@ -66,10 +66,8 @@ ip_nat_proto_find_get(u_int8_t protonum)
 	 * removed until we've grabbed the reference */
 	preempt_disable();
 	p = __ip_nat_proto_find(protonum);
-	if (p) {
-		if (!try_module_get(p->me))
-			p = &ip_nat_unknown_protocol;
-	}
+	if (!try_module_get(p->me))
+		p = &ip_nat_unknown_protocol;
 	preempt_enable();
 
 	return p;
--- linux-2.6.14.2.orig/net/ipv4/netfilter/ip_nat_proto_unknown.c
+++ linux-2.6.14.2/net/ipv4/netfilter/ip_nat_proto_unknown.c
@@ -62,7 +62,7 @@ unknown_print_range(char *buffer, const 
 
 struct ip_nat_protocol ip_nat_unknown_protocol = {
 	.name			= "unknown",
-	.me			= THIS_MODULE,
+	/* .me isn't set: getting a ref to this cannot fail. */
 	.manip_pkt		= unknown_manip_pkt,
 	.in_range		= unknown_in_range,
 	.unique_tuple		= unknown_unique_tuple,

--

  parent reply	other threads:[~2005-11-22 21:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20051122205223.099537000@localhost.localdomain>
2005-11-22 21:06 ` [patch 05/23] [PATCH] VFS: Fix memory leak with file leases Chris Wright
2005-11-22 21:06 ` [patch 06/23] [PATCH] Generic HDLC WAN drivers - disable netif_carrier_off() Chris Wright
2005-11-22 21:06 ` [patch 07/23] [PATCH] [NETFILTER] PPTP helper: Fix endianness bug in GRE key / CallID NAT Chris Wright
2005-11-22 21:06 ` Chris Wright [this message]
2005-11-22 21:06 ` [patch 09/23] [PATCH] [NETFILTER] nf_queue: Fix Ooops when no queue handler registered Chris Wright
2005-11-22 21:06 ` [patch 10/23] [PATCH] [NETFILTER] refcount leak of proto when ctnetlink dumping tuple Chris Wright
2005-11-22 21:07 ` [patch 11/23] [PATCH] [NETFILTER] ctnetlink: check if protoinfo is present Chris Wright
2005-11-22 21:07 ` [patch 12/23] [PATCH] [NETFILTER] PPTP helper: fix PNS-PAC expectation call id Chris Wright
2005-11-22 21:08 ` [patch 13/23] [PATCH] [NETFILTER] ctnetlink: Fix oops when no ICMP ID info in message Chris Wright
2005-11-22 23:31   ` Krzysztof Oledzki
2005-11-23  0:10     ` Chris Wright
2005-11-23  6:59     ` Harald Welte
2005-11-23 19:17       ` Chris Wright
2005-11-22 21:08 ` [patch 14/23] [PATCH] [NETFILTER] ip_conntrack TCP: Accept SYN+PUSH like SYN Chris Wright
2005-11-22 21:08 ` [patch 15/23] [PATCH] [NETFILTER] ip_conntrack: fix ftp/irc/tftp helpers on ports >= 32768 Chris Wright
2005-11-22 21:08 ` [patch 16/23] [PATCH] [IPV6]: Fix memory management error during setting up new advapi sockopts Chris Wright
2005-11-22 21:08 ` [patch 17/23] [PATCH] [IPV6]: Fix calculation of AH length during filling ancillary data Chris Wright
2005-11-22 21:08 ` [patch 18/23] [PATCH] [IPV6]: Fix sending extension headers before and including routing header Chris Wright
2005-11-22 21:08 ` [patch 19/23] [PATCH] x86_64/i386: Compute correct MTRR mask on early Noconas Chris Wright
2005-11-22 21:08 ` [patch 20/23] drivers/isdn/hardware/eicon/os_4bri.c: correct the xdiLoadFile() signature Chris Wright
2005-11-22 21:08 ` [patch 21/23] [PATCH] hwmon: Fix missing boundary check when setting W83627THF in0 limits Chris Wright
2005-11-22 21:08 ` [patch 22/23] hwmon: Fix lm78 VID conversion Chris Wright
2005-11-22 21:09 ` [patch 23/23] hwmon: Fix missing it87 fan div init Chris Wright

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=20051122210640.GI28140@shell0.pdx.osdl.net \
    --to=chrisw@osdl.org \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=chuckw@quantumlinux.com \
    --cc=davej@redhat.com \
    --cc=jmforbes@linuxtx.org \
    --cc=laforge@netfilter.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@xenotime.net \
    --cc=rusty@rustcorp.com.au \
    --cc=stable@kernel.org \
    --cc=torvalds@osdl.org \
    --cc=tytso@mit.edu \
    --cc=zwane@arm.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox