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

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Simon Goldschmidt
URL:
  <http://savannah.nongnu.org/bugs/?54253>

                 Summary: same LCP magic number after power-up.
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: dushevny
            Submitted on: Thu 05 Jul 2018 09:23:13 PM UTC
                Category: PPP
                Severity: 3 - Normal
              Item Group: Change Request
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: git head

    _______________________________________________________

Details:

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.




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?54253>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Simon Goldschmidt
Update of bug #54253 (project lwip):

                  Status:                    None => Need Info              
             Assigned to:                    None => gradator              

    _______________________________________________________

Follow-up 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

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?54253>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Simon Goldschmidt
Update of bug #54253 (project lwip):

                  Status:               Need Info => Confirmed              

    _______________________________________________________

Follow-up 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.


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?54253>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Simon Goldschmidt
Follow-up Comment #3, bug #54253 (project lwip):

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.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?54253>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Simon Goldschmidt
Follow-up Comment #4, bug #54253 (project lwip):

>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.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?54253>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Simon Goldschmidt
Follow-up Comment #5, bug #54253 (project lwip):

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.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?54253>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Simon Goldschmidt
Follow-up Comment #6, bug #54253 (project lwip):

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.

Sylvain?

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?54253>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Simon Goldschmidt
Update of bug #54253 (project lwip):

                  Status:               Confirmed => Fixed                  
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up Comment #7:

Improved in fa3826a1d3.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?54253>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel