buglwIP - A Lightweight TCP/IP stack - Bugs: bug #54253, same LCP magic number after...


You are not allowed to post comments on this tracker with your current authentication level.

bug #54253: same LCP magic number after power-up.

Submitted by:  Sergey A. Borshch <dushevny>
Submitted on:  Thu 05 Jul 2018 09:23:13 PM UTC  
Category:  PPP Severity:  3 - Normal
Item Group:  Change Request Status:  Fixed
Privacy:  Public Assigned to:  Sylvain Rochet <gradator>
Open/Closed:  Closed Planned Release:  None
lwIP version:  git head

( Jump to the original submission)

Fri 31 Aug 2018 08:24:10 AM UTC, comment #7: 

Improved in fa3826a1d3.

Sylvain Rochet <gradator>
Project MemberIn charge of this item.
Mon 23 Jul 2018 06:11:31 PM UTC, comment #6: 

Reading the code again, LWIP_RAND is used if it is available. Given that magic_randomize() is called from ppp_input(), I see no harm calling it from ppp_connect(), too.


Simon Goldschmidt <goldsimon>
Project Administrator
Tue 10 Jul 2018 08:02:49 PM UTC, comment #5: 

I'd rather use LWIP_RAND() in places where random numbers are needed. You can of course add random seed via modem startup time, but implicitly thinking sys_now() is randomized on connect is not portable enough for us, I think.

Simon Goldschmidt <goldsimon>
Project Administrator
Thu 05 Jul 2018 11:20:36 PM UTC, comment #4: 

>Anyway, the real way to fix that is to provide entropy from your TRNG using LWIP_RAND macro.

Probably yes, but GSM modem startup time is random enough to get unique magic number. Anyway after ppp exchange start magic_randomize() called from ppp_input() at random moments, so using TRNG to get one random number seems overkill to me.

Sergey A. Borshch <dushevny>
Thu 05 Jul 2018 11:14:21 PM UTC, comment #3: 

sys_jiffies() actually mapped to sys_now() in my system. But lwip_init() always takes the same fixed time to execute and first sys_jiffies() call from ppp_init() always return the same value, which leads to same magic number in LCP packets all the time.

Sergey A. Borshch <dushevny>
Thu 05 Jul 2018 11:09:50 PM UTC, comment #2: 

Erm, my bad, this is the same issue with sys_now() if sys_now() is not randomized at boot time. Adding one call to magic_randomize() in ppp_connect might help a little bit to improve that. As long as ppp_connect() is not called right after booting up.

Anyway, the real way to fix that is to provide entropy from your  TRNG using LWIP_RAND macro.

Sylvain Rochet <gradator>
Project MemberIn charge of this item.
Thu 05 Jul 2018 11:02:07 PM UTC, comment #1: 

I don't think that's necessary. sys_now() is a mandatory function for quite a while, what prevent you to aliase sys_jiffies() to sys_now() ?

PPP is actually the last sys_jiffies user (probably for more than a decade now), I would be in favor of remplacing sys_jiffies() calls to sys_now() then remove sys_jiffies() from lwip/sys.h.


Sylvain Rochet <gradator>
Project MemberIn charge of this item.
Thu 05 Jul 2018 09:23:13 PM UTC, original submission:  

magic_init() first time called from ppp_init(), which is called from lwip_init(). If system has no RTC, sys_jiffies() returns same value in this moment after every power-up or system reset. This value used in LCP magic number generation after ppp_connect(), which leads to same magic number after every restart. Subsequent magic_randomize() calls takes place in ppp_input(), after magic number generation.

 Suggestion: call magic_randomize() somewhere near start of ppp_connect() as ppp_connect called after modem init which takes random time.

Sergey A. Borshch <dushevny>


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by gradator (Posted a comment)
  • -email is unavailable- added by dushevny (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-31 gradator StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2018-07-05 gradator StatusNeed Info => Confirmed
    2018-07-05 gradator StatusNone => Need Info
        Assigned toNone => gradator

    Back to the top

    Powered by Savane 3.5