<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/75598/nrf9160---bsd-lib-crash---udp-recv---potential-security-issue</link><description>I am using nrfconnect 1.5.1 (zephyr/command line) with modem firmware 1.2.3 and believe I have found a fairly serious bug/behavior in the UDP API. It is pretty easy &amp;quot;crash&amp;quot; the NRF9160 with small amounts of UDP data. 
 Details : 
 In my Application, I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 10 Jun 2022 07:31:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/75598/nrf9160---bsd-lib-crash---udp-recv---potential-security-issue" /><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/371781?ContentTypeID=1</link><pubDate>Fri, 10 Jun 2022 07:31:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2759458a-2738-430f-a3d4-0d858e607147</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You might want to check out NCS 2.0.0 and modem firmware 1.3.2.&lt;/p&gt;
&lt;p&gt;We have made some changes under the hood which should increase the flow control between the modem and application cores, reducing the chances of lockups due to full buffers.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/371482?ContentTypeID=1</link><pubDate>Wed, 08 Jun 2022 15:51:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:365264fb-b51e-401a-8230-16d84e1394ec</guid><dc:creator>emh203</dc:creator><description>&lt;p&gt;Hello:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To clarify,&amp;nbsp; &amp;nbsp; the issue happens if you read() &amp;quot;slowy&amp;quot;.&amp;nbsp; &amp;nbsp;For example,&amp;nbsp; if my thread sleeps for 250mS in between read calls.&amp;nbsp; &amp;nbsp;If several packets come in quickly, send() will block forever.&amp;nbsp; &amp;nbsp; The condition appears to be unrecoverable other than a watchdog reset.&lt;/p&gt;
&lt;p&gt;Having separate threads for send and recv() may help but makes the code/logic&amp;nbsp; messy.&lt;/p&gt;
&lt;p&gt;The most stable workaround is&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1.)&amp;nbsp; &amp;nbsp;Implement a task_wdt system that will reset the system if there is a lockup.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2.)&amp;nbsp; &amp;nbsp;When calling recv(),&amp;nbsp; &amp;nbsp;do something like this in a while loop:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; while((rcvd = recv(krusty_client_fd, (uint8_t *)&amp;amp;krusty_rx_buf, sizeof(krusty_rx_buf), MSG_DONTWAIT) ) &amp;gt;0)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This will help drain the queue.&amp;nbsp; &amp;nbsp; &amp;nbsp; In my case,&amp;nbsp; I have send/recv in the same thread/state machine.&amp;nbsp; &amp;nbsp; If I do not use the while() loop,&amp;nbsp; the system can lock up in the time in between the send() and recv() call.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;3.)&amp;nbsp; Minimize an delay/sleep time in between a send() and recv() call.&amp;nbsp; &amp;nbsp; Initially my network thread had some sleep calls in the state machine and I had to make sure I call recv() frequently.&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;4.)&amp;nbsp; Make the packet heap as large as possible.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It is pretty easy to send a bunch of packets from a server quickly to cause the lockup.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It would be nice if the modem library had its source code in the NCS/Zephyr repository.&amp;nbsp; &amp;nbsp; &amp;nbsp;Simply having an option to never have send() block would be beneficial (at the expense of dropping some incoming packets).&amp;nbsp; Applications based upon UDP expect&amp;nbsp; potential packet loss anyway.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/371000?ContentTypeID=1</link><pubDate>Tue, 07 Jun 2022 00:13:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a16478a0-9ede-4b92-9aab-0d2af9026219</guid><dc:creator>wileycwj_ath</dc:creator><description>&lt;p&gt;I also am experiencing this same issue on SDK 1.6.1 and modem_fw 1.3.1.&lt;/p&gt;
&lt;p&gt;Observing&amp;nbsp;same as @emh203&amp;nbsp;where TCP sockets are failing after some amount of minutes / hours depending on how many requests are sent.&lt;/p&gt;
[quote userid="14473" url="~/f/nordic-q-a/75598/nrf9160---bsd-lib-crash---udp-recv---potential-security-issue/313459#313459"]&lt;p&gt;- you observe that when you do read, the send() function will block eventually; this needs investigation&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;&lt;span&gt;Is there a patch or solution for this that doesn&amp;#39;t involve just shutting down the modem and application?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/313459?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 14:01:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8e2581c-e3ac-4436-8fee-9c0ceaf641e5</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;if you do not read incoming data, it is expected that the Heap becomes full and allocations start to fail so I don&amp;#39;t see that as an indication of a leak.&lt;/p&gt;
&lt;p&gt;To sum up what I gathered so far:&lt;/p&gt;
&lt;p&gt;- you observe that when you stop reading, the send() call will block; this is a known issue.&lt;/p&gt;
&lt;p&gt;- you observe that when you stop reading, the heap becomes full and allocation fails; this is expected behavior&lt;/p&gt;
&lt;p&gt;- you observe that when you do read, the send() function will block eventually; this needs investigation&lt;/p&gt;
&lt;p&gt;Are you able to observe the heap filling up and allocations failing when you keep reading from the socket? That would be an indication of a leak.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/313407?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 12:22:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75eee10a-07b2-4c33-b63d-b25b96e6dbd2</guid><dc:creator>emh203</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/didrik-rokhaug"&gt;Didrik Rokhaug&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks.&amp;nbsp; My temporary workaround is to enable a task watchdog to reset the NRF9160.&amp;nbsp; &amp;nbsp; &amp;nbsp; Let me know if there is a new branch I can pull from to test a fix.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/313402?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 12:16:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc819a3d-d320-49a7-9020-6b394e16a2be</guid><dc:creator>emh203</dc:creator><description>&lt;p&gt;Hello Emdi:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;nbsp;If you read the data after the Heap has become full, you should see both the Heap being emptied and your send() call unblocking.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Please read the problem report more carefully.&amp;nbsp; &amp;nbsp;Once this issue occurs,&amp;nbsp; &amp;nbsp; it is unrecoverable.&amp;nbsp; &amp;nbsp; &amp;nbsp; I initially discovered in my application that&amp;nbsp;performs recv().&amp;nbsp; &amp;nbsp; Disabling recv() allows us to demonstrate the error more quickly.&amp;nbsp; &amp;nbsp;(seconds instead of hours/days).&amp;nbsp; &amp;nbsp; &amp;nbsp;Even with recv() being called frequently,&amp;nbsp; &amp;nbsp;several packets coming in quickly&amp;nbsp;can lock up the modem library.&lt;/p&gt;
&lt;p&gt;Once the allocator fails,&amp;nbsp; it looks like the modem library blocks forever (verified w/ debugger).&amp;nbsp; &amp;nbsp; &amp;nbsp;It is not possible to perform any network operations at that point.&amp;nbsp; &amp;nbsp; &amp;nbsp;The library is closed source so the developers need to look into it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/313337?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 09:52:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18f32386-f9cd-499e-9ce2-28fb57849c3a</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It is expected&amp;nbsp;that if you don&amp;#39;t read incoming data, the Heap memory will become full like your logs show. If you read the data after the Heap has become full, you should see both the Heap being emptied and your send() call unblocking.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/313327?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 09:29:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3c5e05b-51ea-46f9-929f-8436e6765e68</guid><dc:creator>visu</dc:creator><description>&lt;p&gt;Hi Didrik&amp;nbsp; and emh203,&lt;/p&gt;
&lt;p&gt;It wasn&amp;#39;t this problem. I will investigate the problem and open a new ticket if necessary.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/313326?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 09:26:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5a52750-4fa2-462a-96df-189a332a2ecb</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/visu"&gt;visu&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;I believe the problems described by emh203 only happens when you receive data.&lt;/p&gt;
&lt;p&gt;I recommend that you open a new ticket with your problem, as it can be hard to keep track of two different problems in one ticket.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/emh203"&gt;emh203&lt;/a&gt;, thanks for the logs. I have forwarded them to our developers, and will let you know when they have looked at them.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/313196?ContentTypeID=1</link><pubDate>Wed, 02 Jun 2021 16:37:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d06b09e-4e0c-4990-b533-c3d7db979891</guid><dc:creator>emh203</dc:creator><description>&lt;p&gt;This issue became apparent in the read case for me.&amp;nbsp; &amp;nbsp;Note that it also affect TCP as well.&amp;nbsp; &amp;nbsp;I have not tested &amp;quot;write only&amp;quot;.&amp;nbsp; &amp;nbsp; &amp;nbsp;I would turn on:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_DEBUG_ALLOC&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_DEBUG_SHM_TX_ALLOC&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_HEAP_DUMP_PERIODIC&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_SHM_TX_DUMP_PERIODIC&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_LOG_LEVEL_DBG&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;If it can happen in the write-only case,&amp;nbsp; then it should be apparent in the UDP example in nrf_connect as well (it writes data only).&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;The &amp;quot;read&amp;quot; side of things makes it much easier to reproduce (within seconds)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/313042?ContentTypeID=1</link><pubDate>Wed, 02 Jun 2021 09:01:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0511cdd3-343b-45a9-b9fe-e47090965819</guid><dc:creator>visu</dc:creator><description>&lt;p&gt;Hi, I am a litle bit curious regarding this issue. Does this only happen if the nrf9160 receives data? &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I have an application which sends udp data every 5-7 seconds, but I never read the recv because I do not expect any data to receive (it sends udp data to a server which does not respond, similiar to your udp-sample-test). the application seems to crash after&amp;nbsp; 1hour-1h30min.&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t debugged it yet, but I am just curious if this maybe something has to do with this issue :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/312947?ContentTypeID=1</link><pubDate>Tue, 01 Jun 2021 15:43:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:981cfa5c-8add-457e-96ca-5a261f013eed</guid><dc:creator>emh203</dc:creator><description>&lt;p&gt;Hello Didrik:&lt;/p&gt;
&lt;p&gt;I was able to turn on those diagnostics and gather a log.&amp;nbsp; &amp;nbsp; &amp;nbsp;Also,&amp;nbsp; &amp;nbsp; I used the UDP example in&amp;nbsp;&lt;/p&gt;
&lt;p&gt;nrf/samples/nrf9160/udp&lt;/p&gt;
&lt;p&gt;to demonstrate the issue on the NRF9160DK&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Setup:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1.) Build the sample in&amp;nbsp;&lt;span&gt;nrf/samples/nrf9160/udp&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I added the following to the prj.conf&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_DEBUG_ALLOC&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_DEBUG_SHM_TX_ALLOC&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_HEAP_DUMP_PERIODIC&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_SHM_TX_DUMP_PERIODIC&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_LOG_LEVEL_DBG&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span&gt;CONFIG_UDP_DATA_UPLOAD_SIZE_BYTES&lt;/span&gt;&lt;span&gt;=10&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_UDP_DATA_UPLOAD_FREQUENCY_SECONDS&lt;/span&gt;&lt;span&gt;=10&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_UDP_SERVER_ADDRESS_STATIC&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt;&amp;quot;104.236.49.95&amp;quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_UDP_SERVER_PORT&lt;/span&gt;&lt;span&gt;=2100&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_UDP_PSM_ENABLE&lt;/span&gt;&lt;span&gt;=n&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_UDP_EDRX_ENABLE&lt;/span&gt;&lt;span&gt;=n&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_UDP_RAI_ENABLE&lt;/span&gt;&lt;span&gt;=n&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Note:&amp;nbsp; &amp;nbsp;The IP address and port is for a test server.&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2.)&amp;nbsp; &amp;nbsp;Start the UDP test script on the test server.&amp;nbsp; &amp;nbsp;I have attached &amp;quot;udp_test.py&amp;quot; to this&amp;nbsp; &amp;nbsp; This code was started on the server terminal:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;python3 udp_test.py&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This code listens on port 2100 (a random test port I picked).&amp;nbsp; &amp;nbsp;It will print the received data and then send back the string&amp;nbsp;&amp;quot;Hello UDP Client&amp;quot;&amp;nbsp; six times for every message it receives.&amp;nbsp; I chose six as it will trigger the issue a bit quicker.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;3.)&amp;nbsp; &amp;nbsp;Start the UDP Sample and capture the output/log messages via putty.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1f743n7vk1"&gt;Results:&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;See NRF9160_putty.log.&amp;nbsp; &amp;nbsp;This is the all the printk/log messages from boot until the program stops.&amp;nbsp; &amp;nbsp;You will be able to see where the memory allocation fails.&lt;/p&gt;
&lt;p&gt;Once the failure occurs,&amp;nbsp; &amp;nbsp;the function&amp;nbsp;to periodically send data on the work queue will stop.&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&amp;nbsp; &amp;nbsp;In this sample,&amp;nbsp; incoming is never read as it will trigger the issue more quickly.&amp;nbsp; &amp;nbsp; &amp;nbsp;I initially found that the issue will still eventually occur even if the socket is periodically read. (it might take several hours or days)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In this test setup,&amp;nbsp; the fault will occur after 4 transmissions from the client.&amp;nbsp; &amp;nbsp;Here is the terminal output from the python script.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;forge@quaint-crater:~$ python3 udp_test.py
UDP server up and listening
Message from Client:b&amp;#39;\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00&amp;#39;
Client IP Address:(&amp;#39;12.153.231.186&amp;#39;, 60881)
Message from Client:b&amp;#39;\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00&amp;#39;
Client IP Address:(&amp;#39;12.153.231.186&amp;#39;, 60881)
Message from Client:b&amp;#39;\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00&amp;#39;
Client IP Address:(&amp;#39;12.153.231.186&amp;#39;, 60881)
Message from Client:b&amp;#39;\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00&amp;#39;
Client IP Address:(&amp;#39;12.153.231.186&amp;#39;, 60881)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here is the putty log from the NRF9160.&amp;nbsp; Note that I captured data until the modem_lib process locked up.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2021.06.01 11:22:21 =~=~=~=~=~=~=~=~=~=~=~=
I: alloc(16) -&amp;gt; 0x200154f4
I: alloc(12) -&amp;gt; 0x2001550c
*** Booting Zephyr OS build v2.4.99-ncs1-3525-g4d068de3f50f  ***
I: alloc(16) -&amp;gt; 0x2001551c
I: alloc(12) -&amp;gt; 0x20015534
UDP sample has started
I: shm_tx_alloc(15) -&amp;gt; 0x20010524
I: shm_tx_free(0x20010524)
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
I: shm_tx_alloc(10) -&amp;gt; 0x20010524
I: shm_tx_free(0x20010524)
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
I: shm_tx_alloc(10) -&amp;gt; 0x20010524
I: shm_tx_free(0x20010524)
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
I: shm_tx_alloc(9) -&amp;gt; 0x20010524
I: shm_tx_free(0x20010524)
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
I: shm_tx_alloc(11) -&amp;gt; 0x20010524
I: shm_tx_free(0x20010524)
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
I: shm_tx_alloc(22) -&amp;gt; 0x20010524
I: shm_tx_free(0x20010524)
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
I: shm_tx_alloc(10) -&amp;gt; 0x20010524
I: shm_tx_free(0x20010524)
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
I: shm_tx_alloc(10) -&amp;gt; 0x20010524
I: shm_tx_free(0x20010524)
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
I: shm_tx_alloc(9) -&amp;gt; 0x20010524
I: shm_tx_free(0x20010524)
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
nrf_modem tx dump:
Heap at 0x200104e8 contains 1023 units in 10 buckets

  bucket#    min units        total      largest      largest
             threshold       chunks      (units)      (bytes)
  -----------------------------------------------------------
        9          512            1         1016         8124

8124 free bytes, 0 allocated bytes, overhead = 64 bytes (0.8%)
Failed allocations: 0
nrf_modem heap dump:
Heap at 0x200154c0 contains 127 units in 7 buckets

  bucket#    min units        total      largest      largest
             threshold       chunks      (units)      (bytes)
  -----------------------------------------------------------
        6           64            1          111          884

884 free bytes, 64 allocated bytes, overhead = 72 bytes (7.1%)
Failed allocations: 0
nrf_modem tx dump:
Heap at 0x200104e8 contains 1023 units in 10 buckets

  bucket#    min units        total      largest      largest
             threshold       chunks      (units)      (bytes)
  -----------------------------------------------------------
        9          512            1         1016         8124

8124 free bytes, 0 allocated bytes, overhead = 64 bytes (0.8%)
Failed allocations: 0
nrf_modem heap dump:
Heap at 0x200154c0 contains 127 units in 7 buckets

  bucket#    min units        total      largest      largest
             threshold       chunks      (units)      (bytes)
  -----------------------------------------------------------
        6           64            1          111          884

884 free bytes, 64 allocated bytes, overhead = 72 bytes (7.1%)
Failed allocations: 0
nrf_modem tx dump:
Heap at 0x200104e8 contains 1023 units in 10 buckets

  bucket#    min units        total      largest      largest
             threshold       chunks      (units)      (bytes)
  -----------------------------------------------------------
        9          512            1         1016         8124

8124 free bytes, 0 allocated bytes, overhead = 64 bytes (0.8%)
Failed allocations: 0
nrf_modem heap dump:
Heap at 0x200154c0 contains 127 units in 7 buckets

  bucket#    min units        total      largest      largest
             threshold       chunks      (units)      (bytes)
  -----------------------------------------------------------
        6           64            1          111          884

884 free bytes, 64 allocated bytes, overhead = 72 bytes (7.1%)
Failed allocations: 0
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
LTE cell changed: Cell ID: 61774082, Tracking area: 61706
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
RRC mode: Connected
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
RRC mode: Idle

I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
LTE cell changed: Cell ID: 122020869, Tracking area: 22018
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
RRC mode: Connected
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
RRC mode: Idle

I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
RRC mode: Connected
I: alloc(20) -&amp;gt; 0x20015544
I: free(0x20015544)
Network registration status: Connected - roaming

I: alloc(16) -&amp;gt; 0x20015544
I: alloc(12) -&amp;gt; 0x2001555c
PSTransmitting UDP/IP payload of 38 bytes to the IP address 104.236.49.95, port number 2100
I: shm_tx_alloc(10) -&amp;gt; 0x20010524
M parameter update: TAU: -1, Active time: -1
I: shm_tx_free(0x20010524)
I: alloc(16) -&amp;gt; 0x2001556c
I: alloc(20) -&amp;gt; 0x20015584
I: alloc(16) -&amp;gt; 0x2001559c
I: alloc(20) -&amp;gt; 0x200155b4
I: alloc(16) -&amp;gt; 0x200155cc
I: alloc(20) -&amp;gt; 0x200155e4
I: alloc(16) -&amp;gt; 0x200155fc
I: alloc(20) -&amp;gt; 0x20015614
I: alloc(16) -&amp;gt; 0x2001562c
I: alloc(20) -&amp;gt; 0x20015644
I: alloc(16) -&amp;gt; 0x2001565c
I: alloc(20) -&amp;gt; 0x20015674
nrf_modem tx dump:
Heap at 0x200104e8 contains 1023 units in 10 buckets

  bucket#    min units        total      largest      largest
             threshold       chunks      (units)      (bytes)
  -----------------------------------------------------------
        9          512            1         1016         8124

8124 free bytes, 0 allocated bytes, overhead = 64 bytes (0.8%)
Failed allocations: 0
nrf_modem heap dump:
Heap at 0x200154c0 contains 127 units in 7 buckets

  bucket#    min units        total      largest      largest
             threshold       chunks      (units)      (bytes)
  -----------------------------------------------------------
        6           64            1           70          556

556 free bytes, 336 allocated bytes, overhead = 128 bytes (12.5%)
Failed allocations: 0
Transmitting UDP/IP payload of 38 bytes to the IP address 104.236.49.95, port number 2100
I: shm_tx_alloc(10) -&amp;gt; 0x20010524
I: shm_tx_free(0x20010524)
I: alloc(16) -&amp;gt; 0x2001568c
I: alloc(20) -&amp;gt; 0x200156a4
I: alloc(16) -&amp;gt; 0x200156bc
I: alloc(20) -&amp;gt; 0x200156d4
I: alloc(16) -&amp;gt; 0x200156ec
I: alloc(20) -&amp;gt; 0x20015704
I: alloc(16) -&amp;gt; 0x2001571c
I: alloc(20) -&amp;gt; 0x20015734
I: alloc(16) -&amp;gt; 0x2001574c
I: alloc(20) -&amp;gt; 0x20015764
I: alloc(16) -&amp;gt; 0x2001577c
I: alloc(20) -&amp;gt; 0x20015794
Transmitting UDP/IP payload of 38 bytes to the IP address 104.236.49.95, port number 2100
I: shm_tx_alloc(10) -&amp;gt; 0x20010524
I: shm_tx_free(0x20010524)
I: alloc(16) -&amp;gt; 0x200157ac
I: alloc(20) -&amp;gt; 0x200157c4
I: alloc(16) -&amp;gt; 0x200157dc
I: alloc(20) -&amp;gt; 0x200157f4
I: alloc(16) -&amp;gt; 0x2001580c
I: alloc(20) -&amp;gt; 0x20015824
I: alloc(16) -&amp;gt; 0x2001583c
I: alloc(20) -&amp;gt; 0x20015854
I: alloc(16) -&amp;gt; 0x2001586c
I: alloc(20) -&amp;gt; 0x20015884
I: alloc(16) -&amp;gt; 0x2001589c
W: alloc(20) -&amp;gt; (nil)
W: alloc(16) -&amp;gt; (nil)
nrf_modem tx dump:
Heap at 0x200104e8 contains 1023 units in 10 buckets

  bucket#    min units        total      largest      largest
             threshold       chunks      (units)      (bytes)
  -----------------------------------------------------------
        9          512            1         1016         8124

8124 free bytes, 0 allocated bytes, overhead = 64 bytes (0.8%)
Failed allocations: 0
nrf_modem heap dump:
Heap at 0x200154c0 contains 127 units in 7 buckets

  bucket#    min units        total      largest      largest
             threshold       chunks      (units)      (bytes)
  -----------------------------------------------------------
        0            1            1            1            4

4 free bytes, 796 allocated bytes, overhead = 220 bytes (21.6%)
Failed allocations: 2
Transmitting UDP/IP payload of 38 bytes to the IP address 104.236.49.95, port number 2100
I: shm_tx_alloc(10) -&amp;gt; 0x20010524
W: alloc(16) -&amp;gt; (nil)
W: alloc(16) -&amp;gt; (nil)
W: alloc(16) -&amp;gt; (nil)
W: alloc(16) -&amp;gt; (nil)
W: alloc(16) -&amp;gt; (nil)
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/nrf9160_5F00_putty.log"&gt;devzone.nordicsemi.com/.../nrf9160_5F00_putty.log&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/udp_5F00_test.py"&gt;devzone.nordicsemi.com/.../udp_5F00_test.py&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ServerOutput.txt"&gt;devzone.nordicsemi.com/.../ServerOutput.txt&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/312602?ContentTypeID=1</link><pubDate>Mon, 31 May 2021 10:24:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48af906f-bcb2-46ef-8a97-4999912f7faf</guid><dc:creator>Didrik Rokhaug</dc:creator><description>[quote user="emh203"]While I understand the need to recv() to read data,&amp;nbsp; I believe it is a serious bug for the modem library to ever block indefinitely.&amp;nbsp; &amp;nbsp; Data should simply be dropped.[/quote]
&lt;p&gt;&amp;nbsp;We can&amp;#39;t drop the data as that would break TCP amongst other things.&lt;/p&gt;
&lt;p&gt;But, it also looks like you have found a memory leak. Could you turn on the modem_lib diagnostics and send us the log?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_NRF_MODEM_LIB_DEBUG_ALLOC=y
CONFIG_NRF_MODEM_LIB_DEBUG_SHM_TX_ALLOC=y
CONFIG_NRF_MODEM_LIB_HEAP_DUMP_PERIODIC=y
CONFIG_NRF_MODEM_LIB_SHM_TX_DUMP_PERIODIC=y
CONFIG_NRF_MODEM_LIB_LOG_LEVEL_DBG=y&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/312188?ContentTypeID=1</link><pubDate>Thu, 27 May 2021 15:58:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37ff90f2-4ea6-49dd-9760-5af103ceb6aa</guid><dc:creator>emh203</dc:creator><description>&lt;p&gt;I have been able to narrow down the issue even further.&amp;nbsp;My goal was to figure out how to trigger the issue on demand and then make it better/worse.&amp;nbsp; &amp;nbsp; Also,&amp;nbsp; I was able to use Segger Ozone w/ Zephyr thread aware debugging to see what is happening.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1f6n8imdm4"&gt;&amp;nbsp;Test 1 -&amp;nbsp; &amp;nbsp;Simple UDP Server Response - No&amp;nbsp;recv()&lt;/h3&gt;
&lt;p&gt;I have a dedicated zephyr thread that will open/connect to UDP socket on a server.&amp;nbsp; &amp;nbsp; &amp;nbsp;I will send a small message to the server every 10 seconds and it will respond with 4 small data packets.&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In my UDP thread,&amp;nbsp; &amp;nbsp;I disable recv().&lt;/p&gt;
&lt;p&gt;The thread will get locked up almost immediately.&amp;nbsp; &amp;nbsp; &amp;nbsp; I found that the thread is lockup up waiting on a semaphore.&amp;nbsp; See attached image&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/lockup.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It looks like the thread is blocked @ interface_socket_wait()&lt;/p&gt;
&lt;p&gt;If I change this parameter:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_HEAP_SIZE&lt;/span&gt;&lt;span&gt;=2048&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The thread will no longer lock up immediately .&amp;nbsp; &amp;nbsp; &amp;nbsp;It would take longer but it would eventually lock up.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1f6n8hpao3"&gt;Test 2 -&amp;nbsp; &amp;nbsp;Simple UDP Server Response -&amp;nbsp; Enable&amp;nbsp;recv()&lt;/h3&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Same as #1 but instead I perform a recv() every 100mS to read incoming packets.&lt;/p&gt;
&lt;p&gt;In this test case,&amp;nbsp; &amp;nbsp;the thread will work for awhile but will eventual get to a locked state &lt;strong&gt;*even with recv()*&lt;/strong&gt; calls.&amp;nbsp; &amp;nbsp;It can take several hours but it will eventually happen&lt;/p&gt;
&lt;p&gt;The server responds to my client with 4 packets.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Packet one is 40 bytes and Packet 2,3 and 4 are 96 bytes.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Packets 1 and 2 are sent immediately and 2,3 and 4 are spaced by 50mS&lt;/p&gt;
&lt;p&gt;It feels like the back to back packets might be an issue.&lt;/p&gt;
&lt;h3 id="mcetoc_1f6n8ec5c0"&gt;Test 3 - Simple TCP Server w/ Netcat&lt;/h3&gt;
&lt;p&gt;This test can be used to easily replicate the issue.&amp;nbsp; &amp;nbsp; In my test thread,&amp;nbsp; I would connect to a remote server using TCP instead of UDP:&lt;/p&gt;
&lt;p&gt;client_fd&amp;nbsp;=&amp;nbsp;socket(AF_INET,&amp;nbsp;SOCK_STREAM,&amp;nbsp;IPPROTO_TCP);&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;On the server side,&amp;nbsp; I could use netcat to accept connections.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I would then simply paste data in the console to send data.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;A.)&amp;nbsp; &amp;nbsp; In my test thread,&amp;nbsp; &amp;nbsp;I disabled recv() calls.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;The thread would lock up almost immediately when the server response.&amp;nbsp; &amp;nbsp; The thread will also block at the same place as test #1&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;B.)&amp;nbsp; Changing to&amp;nbsp;&lt;span&gt;CONFIG_NRF_MODEM_LIB_HEAP_SIZE&lt;/span&gt;&lt;span&gt;=2048&amp;nbsp; &amp;nbsp;helps the problem but it is still possible to lock it up.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;C.)&amp;nbsp; If I enable recv() with a 100mS read rate in my thread,&amp;nbsp; &amp;nbsp; the thread will still eventually lock up.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Conclusion:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I believe there is a memory allocation issue in the modem library.&amp;nbsp; Increasing the heap size helps but does not fix the issue.&amp;nbsp; &amp;nbsp; Even when periodically calling recv(),&amp;nbsp; &amp;nbsp;it will eventually block in the interface_socket_wait semaphore.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I would appreciate a developer to looking at the the modem_lib code as it is not provided in nrf_connect sdk.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;The problem can be easily recreated w/ netcat on a test server.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;While I understand the need to recv() to read data,&amp;nbsp; I believe it is a serious bug for the modem library to ever block indefinitely.&amp;nbsp; &amp;nbsp; Data should simply be dropped.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;My only workaround at this point is to enable the watchdog to reset the CPU.&amp;nbsp; &amp;nbsp; This is occurring&amp;nbsp;with a trivial socket use case with small amounts of data.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/311900?ContentTypeID=1</link><pubDate>Wed, 26 May 2021 16:52:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:859578fa-b19c-4cac-a429-48a8813e3c49</guid><dc:creator>emh203</dc:creator><description>&lt;p&gt;Hello Didrik:&lt;/p&gt;
&lt;p&gt;I understand this.&amp;nbsp; &amp;nbsp; In my description,&amp;nbsp; I completely disabled reads to trigger the issue quicker.&amp;nbsp; &amp;nbsp; In my normal application,&amp;nbsp; I do keep reading but there is a transient error that locks up the modem library completely.&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;After some more experimentation,&amp;nbsp; I actually found that if&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_HEAP_SIZE&lt;/span&gt;&lt;span&gt;=512 (default)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;I can trigger the bug.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;If I change to:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;CONFIG_NRF_MODEM_LIB_HEAP_SIZE=2048&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then my test case where I turn off recv() will not cause the modem_lib to get hung up.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;In any case,&amp;nbsp; &amp;nbsp;not reading a socket fast enough should never cause the underlying modem library to lock up.&amp;nbsp; &amp;nbsp; Can I get source code to see why this is the case?&amp;nbsp; &amp;nbsp;Or can you please ask one of the developers?&amp;nbsp; I noticed that there are only binary blobs in nrf connect sdk.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;I think the underlying issue will trigger if several packets come in quickly.&amp;nbsp; &amp;nbsp; I believe the modem library should simply drop packets if there is a memory allocation issue.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;I would like to at least see if there is a way I can see if there is an ASSERT, etc firing in this case.&amp;nbsp; &amp;nbsp;It really looks like there is a heap failure and the modem lib is locked up.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 - BSD lib crash - UDP recv() - potential security issue</title><link>https://devzone.nordicsemi.com/thread/311867?ContentTypeID=1</link><pubDate>Wed, 26 May 2021 14:41:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6bfedbad-b25b-4198-a27e-29dd65e43833</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If you do not read the data sent from the modem to the application, you will eventually fill up the shared memory buffer, which will prevent other messages from being queued.&lt;/p&gt;
&lt;p&gt;You should therefore always make sure that you read all data sent from the modem to the application.&lt;/p&gt;
&lt;p&gt;This behavior is explained in the documentation: &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfxlib/nrf_modem/doc/architecture.html#rx-area"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfxlib/nrf_modem/doc/architecture.html#rx-area&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>