: Fix axrpc/afs related bugs
Subsystems (3)
cover : Fix axrpc/afs related bugs
These patches fix two bugs introduced by the RXRPC patches. While looking at the other code that came in with these patches, I noticed it includes an entire rtnetlink client in the kernel, which doesn't seem to make much sense since all the information is available in much easier ways, so I've replaced it by two small helper functions that should do exactly the same.
Unless I'm missing something fundamental, please apply :)
fs/afs/Makefile | 2 fs/afs/cmservice.c | 1 fs/afs/internal.h | 1 fs/afs/netdevices.c | 54 +++++ fs/afs/use-rtnetlink.c | 473 ---------------------------------------------- include/linux/netdevice.h | 1 net/core/dev.c | 21 +- net/netlink/af_netlink.c | 6 8 files changed, 75 insertions(+), 484 deletions(-)
Patrick McHardy (4):
[NETLINK]: Fix use after free in netlink_recvmsg [AFS]: Fix memory leak in SRXAFSCB_GetCapabilities [NET]: Add __dev_getfirstbyhwtype
[AFS]: Replace rtnetlink client by direct dev_base walking
PATCH 1/4 : Fix use after free in netlink_recvmsg
[NETLINK]: Fix use after free in netlink_recvmsg
When the user passes in MSG_TRUNC the skb is used after getting freed.
---
commit 831e920626706afd5ced0c72ca15c8af340bc157
tree 1320e7a446a55e826f671d32e6b9f35e302eeb0d
parent dc87c3985e9b442c60994308a96f887579addc39
author Patrick McHardy <[email protected]> Wed, 02 May 2007 20:18:57 +0200 committer Patrick McHardy <[email protected]> Wed, 02 May 2007 20:18:57 +0200
net/netlink/af_netlink.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
net/netlink/af_netlink.c +2 -4
@@ -1245,16 +1245,14 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock, siocb->scm = &scm; } siocb->scm->creds = *NETLINK_CREDS (skb); +if (flags &MSG_TRUNC ) + copied = skb->len;skb_free_datagram (sk, skb);if (nlk->cb &&atomic_read (&sk->sk_rmem_alloc) <= sk->sk_rcvbuf /2 )netlink_dump (sk);scm_recv (sock, msg, siocb->scm, flags); - -if (flags &MSG_TRUNC ) - copied = skb->len; - out:netlink_rcv_wake (sk);return err ? : copied;
PATCH 2/4 : Fix memory leak in SRXAFSCB_GetCapabilities
In reply to Patrick McHardy[AFS]: Fix memory leak in SRXAFSCB_GetCapabilities
The interface array is not freed on exit.
---
commit cef7f64469d521dd1dcb991e247ad02e84c3051c
tree bf5b8cd7a7e31053eaf826037c0b9fc97a69cd93
parent 831e920626706afd5ced0c72ca15c8af340bc157
author Patrick McHardy <[email protected]> Wed, 02 May 2007 20:19:04 +0200 committer Patrick McHardy <[email protected]> Wed, 02 May 2007 20:19:04 +0200
fs/afs/cmservice.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
fs/afs/cmservice.c +1 -0
@@ -443,6 +443,7 @@ static void SRXAFSCB_GetCapabilities(struct work_struct *work) reply.ia.netmask[loop] = ifs[loop].netmask.s_addr; reply.ia.mtu[loop] =htonl (ifs[loop].mtu); } +kfree (ifs); } reply.cap.capcount =htonl (1 );
PATCH 3/4 : Add __dev_getfirstbyhwtype
In reply to Patrick McHardy[NET]: Add __dev_getfirstbyhwtype
Add __dev_getfirstbyhwtype for callers that don't want a reference but some data from the device and thus need to take the rtnl anyway.
---
commit 3c87ab894405bb9997ff07ceb7dde4902762596a
tree 2d2dfae5b5cacaeb4dc03600073d1e8716312742
parent cef7f64469d521dd1dcb991e247ad02e84c3051c
author Patrick McHardy <[email protected]> Wed, 02 May 2007 20:19:09 +0200 committer Patrick McHardy <[email protected]> Wed, 02 May 2007 20:19:09 +0200
include/linux/netdevice.h | 1 + net/core/dev.c | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-)
include/linux/netdevice.h +1 -0
@@ -582,6 +582,7 @@ extern int netdev_boot_setup_check(struct net_device *dev);extern unsigned long netdev_boot_base (const char *prefix,int unit);extern struct net_device *dev_getbyhwaddr (unsigned short type,char *hwaddr);extern struct net_device *dev_getfirstbyhwtype (unsigned short type); +extern struct net_device *__dev_getfirstbyhwtype (unsigned short type);extern void dev_add_pack (struct packet_type *pt);extern void dev_remove_pack (struct packet_type *pt);extern void __dev_remove_pack (struct packet_type *pt);
net/core/dev.c +16 -5
@@ -576,17 +576,28 @@ struct net_device *dev_getbyhwaddr(unsigned short type, char *ha)EXPORT_SYMBOL (dev_getbyhwaddr); -struct net_device *dev_getfirstbyhwtype (unsigned short type) +struct net_device *__dev_getfirstbyhwtype (unsigned short type) {struct net_device *dev; -rtnl_lock (); +ASSERT_RTNL ();for (dev = dev_base; dev; dev = dev->next) { -if (dev->type == type) { -dev_hold (dev); +if (dev->type == type)break ; - } } +return dev; +} + +EXPORT_SYMBOL (__dev_getfirstbyhwtype); + +struct net_device *dev_getfirstbyhwtype (unsigned short type) +{ +struct net_device *dev; + +rtnl_lock (); + dev =__dev_getfirstbyhwtype (type); +if (dev) +dev_hold (dev);rtnl_unlock ();return dev; }
PATCH 4/4 : Replace rtnetlink client by direct dev_base walking
In reply to Patrick McHardy[AFS]: Replace rtnetlink client by direct dev_base walking
Replace the large and complicated rtnetlink client by two simple functions for getting the MAC address for the first ethernet device and building a list of IPv4 addresses.
---
commit 66ad658e3c44a6d929340877f1388948c64885be
tree 8dc780b127b05f2a200bfde362b0fedfa25f3609
parent 3c87ab894405bb9997ff07ceb7dde4902762596a
author Patrick McHardy <[email protected]> Wed, 02 May 2007 20:47:14 +0200 committer Patrick McHardy <[email protected]> Wed, 02 May 2007 20:47:14 +0200
fs/afs/Makefile | 2 fs/afs/internal.h | 1 fs/afs/netdevices.c | 54 +++++ fs/afs/use-rtnetlink.c | 473 ------------------------------------------------ 4 files changed, 55 insertions(+), 475 deletions(-)
fs/afs/Makefile +1 -1
@@ -18,7 +18,7 @@ kafs-objs := \ security.o \ server.o \ super.o \ - use-rtnetlink.o \ + netdevices.o \ vlclient.o \ vlocation.o \ vnode.o \
fs/afs/internal.h +0 -1
@@ -349,7 +349,6 @@ struct afs_permits {* record of one of a system's set of network interfaces */ struct afs_interface { -unsigned index;/* interface index */ struct in_addr address;/* IPv4 address bound to interface */ struct in_addr netmask;/* netmask applied to address */ unsigned mtu;/* MTU of interface */
fs/afs/netdevices.c new file +54 -0
54 lines not on this page · raw message
fs/afs/use-rtnetlink.c deleted +0 -473
473 lines not on this page · raw message
Oops, typo in David's address.
David, please look at these patches (especially the last one) on netdev. Thanks.
Quoted 24 lines · Patrick McHardy
These patches fix two bugs introduced by the RXRPC patches. While looking at the other code that came in with these patches, I noticed it includes an entire rtnetlink client in the kernel, which doesn't seem to make much sense since all the information is available in much easier ways, so I've replaced it by two small helper functions that should do exactly the same.
Unless I'm missing something fundamental, please apply :)
fs/afs/Makefile | 2 fs/afs/cmservice.c | 1 fs/afs/internal.h | 1 fs/afs/netdevices.c | 54 +++++ fs/afs/use-rtnetlink.c | 473 ---------------------------------------------- include/linux/netdevice.h | 1 net/core/dev.c | 21 +- net/netlink/af_netlink.c | 6 8 files changed, 75 insertions(+), 484 deletions(-)Patrick McHardy (4):
[NETLINK]: Fix use after free innetlink_recvmsg[AFS]: Fix memory leak inSRXAFSCB_GetCapabilities[NET]: Add__dev_getfirstbyhwtype
[AFS]: Replace rtnetlink client by directdev_basewalking
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Thu, 03 May 2007 02:07:14 +0200
Quoted 3 lines
Oops, typo in David's address.
David, please look at these patches (especially the last one) on netdev.
Sure, no problem.
This netlink stuff is my fault, David H. came to the list asking how to do this and that's what I suggested to him :-)
Quoted 6 lines · David Miller
From: Patrick McHardy <[email protected]>
Date: Thu, 03 May 2007 02:07:14 +0200Quoted 2 lines
Oops, typo in David's address.
Quoted 8 lines
Quoted 1 line
David, please look at these patches (especially the last one) on netdev.
Sure, no problem.
This netlink stuff is my fault, David H. came to the list asking how to do this and that's what I suggested to him :-)
I actually meant the other David :) The fixes are pretty obvious, but I would like an ACK for the last patch since it replaces an AFS file.