Re: [PATCH] ax25_cb refcounting & waitqueue usage

From: Jeroen Vreeken (vqyn@roskapostia.tunk.net)
Date: Mon Jul 07 2003 - 20:23:40 EEST

  • Next message: Arnaldo Carvalho de Melo: "Re: [PATCH] ax25_cb refcounting & waitqueue usage"

    On 2003.07.07 15:37:10 +0200 Arnaldo Carvalho de Melo wrote:
    > Em Sun, Jul 06, 2003 at 07:27:34PM +0200, Jeroen Vreeken escreveu:
    > > Hi,
    > >
    > > Second patch for this weekend...
    > > This patch does two things, it adds reference counting to the ax25_cb
    > > structure (until now only the ax25_cb list was protected, not the parts
    > > using it) and it fixes an oops on interrupted socket syscalls. (e.g.
    > > pressing Ctrl-C while in the connect function) The waitqueue was not
    > > removed from the list and caused an oops in the socket release.
    > >
    > > I have had only a quick look at Steven's patch but I don't think the
    > two
    > > will clash...
    >
    > Hey, why not use sk->refcnt by means of sock_hold/sock_put? Current
    > sources
    > even do that implicitely when you do a sk_add_node (sock_hold) and a
    > sk_del_node{_init} (sock_put)... Now it is just a matter of doing a
    > sock_hold
    > when searching in some list and then dropping the refcnt when done using
    > the
    > sock returned by the search function.

    Unfortunatly the ax25_cbs are not directly related to a sock structure...
    Sometimes they don't even have them, e.g. when you do ip in connected mode
    or netrom and rose interlinks. In those cases you can even share an ax25_cb
    between a socket and those protocols in which case you absolutly need the
    refcounting....
    Consider the following:

    - ip datagram is send to ax25 layer.
    - ax25 layer uses a lookup in the ax25_cb list to find an existing
    connection
    - list code locks, searches, unlocks, returns
    ***** preempt/interrupt/other processor
    - application closes socket
    - ax25_cb is removed from the list (again with proper list locking)
    - ax25_cb is freed
    ***** preempt/interrupt/other processor back to ip handling routine
    - ip handling routine uses ax25_cb
    - BOOM!

    Jeroen

    -
    To unsubscribe from this list: send the line "unsubscribe linux-hams" in
    the body of a message to terhi.victor@logonet.com
    More majordomo info at http://vger.kernel.org/majordomo-info.html



    This archive was generated by hypermail 2b30 : Mon Jul 07 2003 - 20:18:41 EEST