* Netdevice reference leak in af_ax25.c ??
@ 2005-09-01 18:41 Ben Greear
2005-09-01 18:56 ` Patrick McHardy
0 siblings, 1 reply; 5+ messages in thread
From: Ben Greear @ 2005-09-01 18:41 UTC (permalink / raw)
To: linux-hams, ralf; +Cc: netdev
I believe the SO_BINDTODEVICE case in net/ax25/af_x25.c (line 613 or so)
leaks a reference to a net device. It does a dev_get_by_name,
which holds a reference, but since it never assigns the pointer
anywhere, I do not see how it can ever free it later.
Please clue me in as to where it's released if it actually is.
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Netdevice reference leak in af_ax25.c ??
2005-09-01 18:41 Netdevice reference leak in af_ax25.c ?? Ben Greear
@ 2005-09-01 18:56 ` Patrick McHardy
2005-09-01 19:02 ` Ben Greear
2005-09-01 19:30 ` Ralf Baechle
0 siblings, 2 replies; 5+ messages in thread
From: Patrick McHardy @ 2005-09-01 18:56 UTC (permalink / raw)
To: Ben Greear; +Cc: linux-hams, ralf, netdev
Ben Greear wrote:
>
> I believe the SO_BINDTODEVICE case in net/ax25/af_x25.c (line 613 or so)
> leaks a reference to a net device. It does a dev_get_by_name,
> which holds a reference, but since it never assigns the pointer
> anywhere, I do not see how it can ever free it later.
>
> Please clue me in as to where it's released if it actually is.
I can't find the code you're talking about, there's no dev_get* in my
version of af_x25.c. Please paste the code you're talking about in
your bugreports, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Netdevice reference leak in af_ax25.c ??
2005-09-01 18:56 ` Patrick McHardy
@ 2005-09-01 19:02 ` Ben Greear
2005-09-01 19:30 ` Ralf Baechle
1 sibling, 0 replies; 5+ messages in thread
From: Ben Greear @ 2005-09-01 19:02 UTC (permalink / raw)
To: Patrick McHardy; +Cc: linux-hams, ralf, netdev
Patrick McHardy wrote:
> Ben Greear wrote:
>
>>I believe the SO_BINDTODEVICE case in net/ax25/af_x25.c (line 613 or so)
>>leaks a reference to a net device. It does a dev_get_by_name,
>>which holds a reference, but since it never assigns the pointer
>>anywhere, I do not see how it can ever free it later.
>>
>>Please clue me in as to where it's released if it actually is.
>
>
> I can't find the code you're talking about, there's no dev_get* in my
> version of af_x25.c. Please paste the code you're talking about in
> your bugreports, thanks.
Please ignore the NRDK thing..I am adding reference counting debugging
to the netdevice code. This is from the 2.6.13 kernel:
In this method:
/*
* Handling for system calls applied via the various interfaces to an
* AX25 socket object
*/
static int ax25_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, int optlen)
{
.....
case SO_BINDTODEVICE:
if (optlen > IFNAMSIZ)
optlen=IFNAMSIZ;
if (copy_from_user(devname, optval, optlen)) {
res = -EFAULT;
break;
}
dev = dev_get_by_name(devname, NDRK_GENERIC);
if (dev == NULL) {
res = -ENODEV;
break;
}
if (sk->sk_type == SOCK_SEQPACKET &&
(sock->state != SS_UNCONNECTED ||
sk->sk_state == TCP_LISTEN)) {
res = -EADDRNOTAVAIL;
dev_put(dev, NDRK_GENERIC);
break;
}
ax25->ax25_dev = ax25_dev_ax25dev(dev);
ax25_fillin_cb(ax25, ax25->ax25_dev);
dev_put(dev, NDRK_GENERIC); /* TODO: Verify we should put it here. */
break;
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Netdevice reference leak in af_ax25.c ??
2005-09-01 18:56 ` Patrick McHardy
2005-09-01 19:02 ` Ben Greear
@ 2005-09-01 19:30 ` Ralf Baechle
2005-09-01 19:42 ` Ben Greear
1 sibling, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2005-09-01 19:30 UTC (permalink / raw)
To: Patrick McHardy; +Cc: Ben Greear, linux-hams, netdev
On Thu, Sep 01, 2005 at 08:56:19PM +0200, Patrick McHardy wrote:
> > I believe the SO_BINDTODEVICE case in net/ax25/af_x25.c (line 613 or so)
> > leaks a reference to a net device. It does a dev_get_by_name,
> > which holds a reference, but since it never assigns the pointer
> > anywhere, I do not see how it can ever free it later.
> >
> > Please clue me in as to where it's released if it actually is.
>
> I can't find the code you're talking about, there's no dev_get* in my
> version of af_x25.c. Please paste the code you're talking about in
> your bugreports, thanks.
Ben meant net/ax25/af_ax25. The dev value is stored in the ax25_cb
indirectly after converting it to an ax25dev pointer and will be freed
what that ax25_cb (which really is the protocol-specific part of the
socket) is going to be closed.
You poked my nose at a bug though - it is possible to leak references by
performing multiple SO_BINDTODEVICE operations; we should either only
permit the first one to succeed or to drop the reference of the old
device in case of a repeated SO_BINDTODEVICE. After the weekend ...
Ralf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Netdevice reference leak in af_ax25.c ??
2005-09-01 19:30 ` Ralf Baechle
@ 2005-09-01 19:42 ` Ben Greear
0 siblings, 0 replies; 5+ messages in thread
From: Ben Greear @ 2005-09-01 19:42 UTC (permalink / raw)
To: Ralf Baechle; +Cc: Patrick McHardy, linux-hams, netdev
Ralf Baechle wrote:
> On Thu, Sep 01, 2005 at 08:56:19PM +0200, Patrick McHardy wrote:
>
>
>>>I believe the SO_BINDTODEVICE case in net/ax25/af_x25.c (line 613 or so)
>>>leaks a reference to a net device. It does a dev_get_by_name,
>>>which holds a reference, but since it never assigns the pointer
>>>anywhere, I do not see how it can ever free it later.
>>>
>>>Please clue me in as to where it's released if it actually is.
>>
>>I can't find the code you're talking about, there's no dev_get* in my
>>version of af_x25.c. Please paste the code you're talking about in
>>your bugreports, thanks.
>
>
> Ben meant net/ax25/af_ax25. The dev value is stored in the ax25_cb
> indirectly after converting it to an ax25dev pointer and will be freed
> what that ax25_cb (which really is the protocol-specific part of the
> socket) is going to be closed.
Ok, I'm getting hopelessly lost in the ax25 code trying to follow
references, so I'm just going to use the generic ref counting debugging.
That will still point to the right module, but not the line of code,
should a leak occur (and should the patch be accepted) :)
> You poked my nose at a bug though - it is possible to leak references by
> performing multiple SO_BINDTODEVICE operations; we should either only
> permit the first one to succeed or to drop the reference of the old
> device in case of a repeated SO_BINDTODEVICE. After the weekend ...
Thanks for taking a look.
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-09-01 19:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-01 18:41 Netdevice reference leak in af_ax25.c ?? Ben Greear
2005-09-01 18:56 ` Patrick McHardy
2005-09-01 19:02 ` Ben Greear
2005-09-01 19:30 ` Ralf Baechle
2005-09-01 19:42 ` Ben Greear
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).