J1939 kernel panic with old 3.10 implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all, hi Kurt,
i'm aware that J1939 as been redesigned and rewritten, but anyway, may
be this can help.
We are using old J1939 implementation from Kurt, with iproute2
patched, based on a 3.10 kernel.

Making some test we've seen that when adding twice an interface with
her name, this leads to a kernel panic.
The way to reproduce:
ip link set can0 up type can bitrate 250000
ip link set can0 j1939 on
ip addr add j1939 name 12345678 dev can0
ip addr add j1939 name 12345678 dev can0 => kernel panic

after some debuging, it seems that in bus.c/j1939_ecu_get_register,
when it is called the second time, we have a goto duplicate
in the duplicate section, we call the macro ecu_alert, which wants to
display ecu->parent.ifindex
But the ecu->parent is set after the goto, so we have anull pointer

i've made this little patch to avoid crashing
------------------------------------------------------------------------------------------
net/can/sj1939/bus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/can/sj1939/bus.c b/net/can/sj1939/bus.c
index dd3a3adfb2a..1625817e7aa 100644
--- a/net/can/sj1939/bus.c
+++ b/net/can/sj1939/bus.c
@@ -206,6 +206,8 @@ struct j1939_ecu *j1939_ecu_get_register(name_t
name, int ifindex, int flags,
  ecu->sa = J1939_IDLE_ADDR;
  ecu->name = name;
  ecu->flags = flags;
+ /* a ref to parent is held */
+ ecu->parent = parent;

  hrtimer_init(&ecu->ac_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
  ecu->ac_timer.function = j1939_ecu_timer_handler;
@@ -219,8 +221,6 @@ struct j1939_ecu *j1939_ecu_get_register(name_t
name, int ifindex, int flags,
  goto duplicate;
  }
  get_j1939_ecu(ecu);
- /* a ref to parent is held */
- ecu->parent = parent;
  list_add_tail(&ecu->list, &parent->ecus);
  write_unlock_bh(&parent->lock);
  ecu_dbg(ecu, "register\n");
-- 
------------------------------------------------------------------------------------------

I hope it can be usefull to people using this old version.

Regards
Laurent



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux