mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
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>,
	Chris Wedgwood <reviews@ml.cw.f00f.org>,
	Michael Krufky <mkrufky@linuxtv.org>,
	Chuck Ebbert <cebbert@redhat.com>,
	Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
	Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
	Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Brian Haley <brian.haley@hp.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [patch 22/42] netns: Add network namespace argument to rt6_fill_node() and ipv6_dev_get_saddr()
Date: Wed, 3 Sep 2008 10:26:03 -0700	[thread overview]
Message-ID: <20080903172603.GW7731@suse.de> (raw)
In-Reply-To: <20080903172447.GA7731@suse.de>

[-- Attachment #1: 0003-netns-Add-network-namespace-argument-to-rt6_fill_no.patch --]
[-- Type: text/plain, Size: 6347 bytes --]

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

------------------

From: Brian Haley <brian.haley@hp.com>

[ Upstream commit 191cd582500f49b32a63040fedeebb0168c720af ]

ipv6_dev_get_saddr() blindly de-references dst_dev to get the network
namespace, but some callers might pass NULL.  Change callers to pass a
namespace pointer instead.

Signed-off-by: Brian Haley <brian.haley@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 include/net/addrconf.h  |    3 ++-
 include/net/ip6_route.h |    1 +
 net/ipv6/addrconf.c     |    3 +--
 net/ipv6/fib6_rules.c   |    3 ++-
 net/ipv6/ip6_fib.c      |    1 +
 net/ipv6/ip6_output.c   |    2 +-
 net/ipv6/ndisc.c        |    2 +-
 net/ipv6/route.c        |   12 +++++++-----
 net/ipv6/xfrm6_policy.c |    4 +++-
 net/sctp/ipv6.c         |    3 ++-
 10 files changed, 21 insertions(+), 13 deletions(-)

--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -80,7 +80,8 @@ extern struct inet6_ifaddr      *ipv6_ge
 						 struct net_device *dev,
 						 int strict);
 
-extern int			ipv6_dev_get_saddr(struct net_device *dev, 
+extern int			ipv6_dev_get_saddr(struct net *net,
+					       struct net_device *dev,
 					       const struct in6_addr *daddr,
 					       unsigned int srcprefs,
 					       struct in6_addr *saddr);
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -112,6 +112,7 @@ struct rt6_rtnl_dump_arg
 {
 	struct sk_buff *skb;
 	struct netlink_callback *cb;
+	struct net *net;
 };
 
 extern int rt6_dump_route(struct rt6_info *rt, void *p_arg);
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1076,13 +1076,12 @@ out:
 	return ret;
 }
 
-int ipv6_dev_get_saddr(struct net_device *dst_dev,
+int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
 		       const struct in6_addr *daddr, unsigned int prefs,
 		       struct in6_addr *saddr)
 {
 	struct ipv6_saddr_score scores[2],
 				*score = &scores[0], *hiscore = &scores[1];
-	struct net *net = dev_net(dst_dev);
 	struct ipv6_saddr_dst dst;
 	struct net_device *dev;
 	int dst_type;
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -93,7 +93,8 @@ static int fib6_rule_action(struct fib_r
 			if (flags & RT6_LOOKUP_F_SRCPREF_COA)
 				srcprefs |= IPV6_PREFER_SRC_COA;
 
-			if (ipv6_dev_get_saddr(ip6_dst_idev(&rt->u.dst)->dev,
+			if (ipv6_dev_get_saddr(net,
+					       ip6_dst_idev(&rt->u.dst)->dev,
 					       &flp->fl6_dst, srcprefs,
 					       &saddr))
 				goto again;
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -380,6 +380,7 @@ static int inet6_dump_fib(struct sk_buff
 
 	arg.skb = skb;
 	arg.cb = cb;
+	arg.net = net;
 	w->args = &arg;
 
 	for (h = s_h; h < FIB_TABLE_HASHSZ; h++, s_e = 0) {
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -925,7 +925,7 @@ static int ip6_dst_lookup_tail(struct so
 		goto out_err_release;
 
 	if (ipv6_addr_any(&fl->fl6_src)) {
-		err = ipv6_dev_get_saddr(ip6_dst_idev(*dst)->dev,
+		err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
 					 &fl->fl6_dst,
 					 sk ? inet6_sk(sk)->srcprefs : 0,
 					 &fl->fl6_src);
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -549,7 +549,7 @@ static void ndisc_send_na(struct net_dev
 			override = 0;
 		in6_ifa_put(ifp);
 	} else {
-		if (ipv6_dev_get_saddr(dev, daddr,
+		if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
 				       inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
 				       &tmpaddr))
 			return;
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2098,7 +2098,8 @@ static inline size_t rt6_nlmsg_size(void
 	       + nla_total_size(sizeof(struct rta_cacheinfo));
 }
 
-static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
+static int rt6_fill_node(struct net *net,
+			 struct sk_buff *skb, struct rt6_info *rt,
 			 struct in6_addr *dst, struct in6_addr *src,
 			 int iif, int type, u32 pid, u32 seq,
 			 int prefix, int nowait, unsigned int flags)
@@ -2181,7 +2182,7 @@ static int rt6_fill_node(struct sk_buff 
 	} else if (dst) {
 		struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
 		struct in6_addr saddr_buf;
-		if (ipv6_dev_get_saddr(idev ? idev->dev : NULL,
+		if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
 				       dst, 0, &saddr_buf) == 0)
 			NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
 	}
@@ -2226,7 +2227,8 @@ int rt6_dump_route(struct rt6_info *rt, 
 	} else
 		prefix = 0;
 
-	return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
+	return rt6_fill_node(arg->net,
+		     arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
 		     NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
 		     prefix, 0, NLM_F_MULTI);
 }
@@ -2292,7 +2294,7 @@ static int inet6_rtm_getroute(struct sk_
 	rt = (struct rt6_info*) ip6_route_output(net, NULL, &fl);
 	skb->dst = &rt->u.dst;
 
-	err = rt6_fill_node(skb, rt, &fl.fl6_dst, &fl.fl6_src, iif,
+	err = rt6_fill_node(net, skb, rt, &fl.fl6_dst, &fl.fl6_src, iif,
 			    RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
 			    nlh->nlmsg_seq, 0, 0, 0);
 	if (err < 0) {
@@ -2319,7 +2321,7 @@ void inet6_rt_notify(int event, struct r
 	if (skb == NULL)
 		goto errout;
 
-	err = rt6_fill_node(skb, rt, NULL, NULL, 0,
+	err = rt6_fill_node(net, skb, rt, NULL, NULL, 0,
 				event, info->pid, seq, 0, 0, 0);
 	if (err < 0) {
 		/* -EMSGSIZE implies BUG in rt6_nlmsg_size() */
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -52,12 +52,14 @@ static struct dst_entry *xfrm6_dst_looku
 static int xfrm6_get_saddr(xfrm_address_t *saddr, xfrm_address_t *daddr)
 {
 	struct dst_entry *dst;
+	struct net_device *dev;
 
 	dst = xfrm6_dst_lookup(0, NULL, daddr);
 	if (IS_ERR(dst))
 		return -EHOSTUNREACH;
 
-	ipv6_dev_get_saddr(ip6_dst_idev(dst)->dev,
+	dev = ip6_dst_idev(dst)->dev;
+	ipv6_dev_get_saddr(dev_net(dev), dev,
 			   (struct in6_addr *)&daddr->a6, 0,
 			   (struct in6_addr *)&saddr->a6);
 	dst_release(dst);
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -317,7 +317,8 @@ static void sctp_v6_get_saddr(struct sct
 			  __func__, asoc, dst, NIP6(daddr->v6.sin6_addr));
 
 	if (!asoc) {
-		ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL,
+		ipv6_dev_get_saddr(sock_net(sctp_opt2sk(sk)),
+				   dst ? ip6_dst_idev(dst)->dev : NULL,
 				   &daddr->v6.sin6_addr,
 				   inet6_sk(&sk->inet.sk)->srcprefs,
 				   &saddr->v6.sin6_addr);

-- 

  parent reply	other threads:[~2008-09-03 17:40 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080903171927.534216229@mini.kroah.org>
2008-09-03 17:24 ` [patch 00/42] 2.6.26-stable review Greg KH
2008-09-03 17:25   ` [patch 01/42] cramfs: fix named-pipe handling Greg KH
2008-09-03 17:25   ` [patch 02/42] PCI: fix reference leak in pci_get_dev_by_id() Greg KH
2008-09-03 17:25   ` [patch 03/42] eeepc-laptop: fix use after free Greg KH
2008-09-03 17:25   ` [patch 04/42] fbdefio: add set_page_dirty handler to deferred IO FB Greg KH
2008-09-03 17:25   ` [patch 05/42] binfmt_misc: fix false -ENOEXEC when coupled with other binary handlers Greg KH
2008-09-03 17:25   ` [patch 06/42] USB: cdc-acm: dont unlock acm->mutex on error path Greg KH
2008-09-03 17:25   ` [patch 07/42] x86: work around MTRR mask setting Greg KH
2008-09-03 17:25   ` [patch 08/42] x86: fix "kernel wont boot on a Cyrix MediaGXm (Geode)" Greg KH
2008-09-03 17:25   ` [patch 09/42] S390 dasd: fix data size for PSF/PRSSD command Greg KH
2008-09-03 17:25   ` [patch 10/42] ALSA: oxygen: prevent muting of nonexistent AC97 controls Greg KH
2008-09-03 17:25   ` [patch 11/42] bio: fix __bio_copy_iov() handling of bio->bv_len Greg KH
2008-09-03 17:25   ` [patch 12/42] bio: fix bio_copy_kern() " Greg KH
2008-09-03 17:25   ` [patch 13/42] forcedeth: fix checksum flag Greg KH
2008-09-03 17:25   ` [patch 14/42] atl1: disable TSO by default Greg KH
2008-09-03 17:25   ` [patch 15/42] cifs: fix O_APPEND on directio mounts Greg KH
2008-09-03 17:25   ` [patch 16/42] drivers/char/random.c: fix a race which can lead to a bogus BUG() Greg KH
2008-09-03 17:25   ` [patch 17/42] rtc_time_to_tm: fix signed/unsigned arithmetic Greg KH
2008-09-03 17:25   ` [patch 18/42] 8250: improve workaround for UARTs that dont re-assert THRE correctly Greg KH
2008-09-03 17:25   ` [patch 19/42] mm: make setup_zone_migrate_reserve() aware of overlapping nodes Greg KH
2008-09-03 17:25   ` [patch 20/42] AX.25: Fix sysctl registration if !CONFIG_AX25_DAMA_SLAVE Greg KH
2008-09-03 17:26   ` [patch 21/42] ipv6: Fix OOPS, ip -f inet6 route get fec0::1, linux-2.6.26, ip6_route_output, rt6_fill_node+0x175 Greg KH
2008-09-03 17:26   ` Greg KH [this message]
2008-09-03 17:26   ` [patch 23/42] pkt_sched: Fix return value corruption in HTB and TBF Greg KH
2008-09-03 17:26   ` [patch 24/42] pkt_sched: Fix actions referencing Greg KH
2008-09-03 17:26   ` [patch 25/42] udp: Drop socket lock for encapsulated packets Greg KH
2008-09-03 17:26   ` [patch 26/42] sctp: fix potential panics in the SCTP-AUTH API Greg KH
2008-09-03 17:26   ` [patch 27/42] sctp: add verification checks to SCTP_AUTH_KEY option Greg KH
2008-09-03 17:26   ` [patch 28/42] sch_prio: Fix nla_parse_nested_compat() regression Greg KH
2008-09-03 17:26   ` [patch 29/42] net: Unbreak userspace which includes linux/mroute.h Greg KH
2008-09-03 19:16     ` Stefan Lippers-Hollmann
2008-09-03 21:16       ` David Miller
2008-09-03 17:26   ` [patch 30/42] sctp: correct bounds check in sctp_setsockopt_auth_key Greg KH
2008-09-03 17:26   ` [patch 31/42] sctp: fix random memory dereference with SCTP_HMAC_IDENT option Greg KH
2008-09-03 17:26   ` [patch 32/42] ipsec: Fix deadlock in xfrm_state management Greg KH
2008-09-03 17:26   ` [patch 33/42] sparc64: Fix overshoot in nid_range() Greg KH
2008-09-03 17:26   ` [patch 34/42] sparc64: Fix cmdline_memory_size handling bugs Greg KH
2008-09-03 17:26   ` [patch 35/42] crypto: authenc - Avoid using clobbered request pointer Greg KH
2008-09-03 17:26   ` [patch 36/42] tg3: Fix firmware event timeouts Greg KH
2008-09-03 17:26   ` [patch 37/42] r8169: balance pci_map / pci_unmap pair Greg KH
2008-09-03 17:26   ` [patch 38/42] sunrpc: fix possible overrun on read of /proc/sys/sunrpc/transports Greg KH
2008-09-03 17:26   ` [patch 39/42] nfsd: fix buffer overrun decoding NFSv4 acl Greg KH
2008-09-03 17:26   ` [patch 40/42] x86: work around MTRR mask setting, v2 Greg KH
2008-09-03 17:26   ` [patch 41/42] KVM: MMU: Fix torn shadow pte Greg KH
2008-09-03 17:26   ` [patch 42/42] sata_mv: dont issue two DMA commands concurrently Greg KH
2008-09-04  2:39   ` [patch 00/42] 2.6.26-stable review Henrique de Moraes Holschuh
2008-09-04 12:21     ` Andi Kleen
2008-09-04 12:28       ` Milan Broz
2008-09-04 13:58         ` Andi Kleen
2008-09-12 14:22     ` Pavel Machek
2008-09-12 15:37       ` Andi Kleen
2008-09-12 19:46         ` Henrique de Moraes Holschuh
2008-09-13 16:56           ` Pavel Machek

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=20080903172603.GW7731@suse.de \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=brian.haley@hp.com \
    --cc=cavokz@gmail.com \
    --cc=cebbert@redhat.com \
    --cc=chuckw@quantumlinux.com \
    --cc=davej@redhat.com \
    --cc=davem@davemloft.net \
    --cc=eteo@redhat.com \
    --cc=jake@lwn.net \
    --cc=jmforbes@linuxtx.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkrufky@linuxtv.org \
    --cc=rbranco@la.checkpoint.com \
    --cc=rdunlap@xenotime.net \
    --cc=reviews@ml.cw.f00f.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=w@1wt.eu \
    --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

Powered by JetHome