Commit df869cca authored by Ben Hutchings's avatar Ben Hutchings Committed by Khalid Elmously

slcan: Fix double-free on slcan_open() error path

BugLink: https://bugs.launchpad.net/bugs/1883918

Commit 9ebd796e ("can: slcan: Fix use-after-free Read in
slcan_open") was incorrectly backported to 4.4 and 4.9 stable
branches.

Since they do not have commit cf124db5 ("net: Fix inconsistent
teardown and release of private netdev state."), the destructor
function slc_free_netdev() is already responsible for calling
free_netdev() and slcan_open() must not call both of them.

yangerkun previously fixed the same bug in slip.

Fixes: ce624b2089ea ("can: slcan: Fix use-after-free Read in slcan_open") # 4.4
Fixes: f59604a80fa4 ("slcan: not call free_netdev before rtnl_unlock ...") # 4.4
Fixes: 56635a1e ("can: slcan: Fix use-after-free Read in slcan_open") # 4.9
Fixes: a1c9b231 ("slcan: not call free_netdev before rtnl_unlock ...") # 4.9
Cc: yangerkun <yangerkun@huawei.com>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent a0f2a07b
...@@ -618,10 +618,9 @@ static int slcan_open(struct tty_struct *tty) ...@@ -618,10 +618,9 @@ static int slcan_open(struct tty_struct *tty)
sl->tty = NULL; sl->tty = NULL;
tty->disc_data = NULL; tty->disc_data = NULL;
clear_bit(SLF_INUSE, &sl->flags); clear_bit(SLF_INUSE, &sl->flags);
slc_free_netdev(sl->dev);
/* do not call free_netdev before rtnl_unlock */ /* do not call free_netdev before rtnl_unlock */
rtnl_unlock(); rtnl_unlock();
free_netdev(sl->dev); slc_free_netdev(sl->dev);
return err; return err;
err_exit: err_exit:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment