csanchezdll opened a new pull request, #8058:
URL: https://github.com/apache/nuttx/pull/8058

   s32k1xx: fix initialization of MAXMB field in MCR.
   
   ## Summary
   
   This includes two fixes for s32k1xx CAN driver.
   
   First, MSG_DATA was not included in TX/RX buffer frames for non-FD builds of 
the driver. However, both CONFIG_NET_CAN_RAW_TX_DEADLINE and 
CONFIG_NET_TIMESTAMP can be used with non-FD CAN, and doing do would cause a 
buffer overflow as code expects extra space for MSG_DATA to be present in those 
cases.
   
   Second, MAXMB field of MCR has a reset value of 0xF. Current code just OR's 
the desired value into this register without cleaning it first. For the 
settings in the file (5 RX MBs and 2 TX MBs) this means a 7 should end up 
there, but without my patch, the reset 0xF is not correctly overwritten meaning 
the HW device tries to use unconfigured mailboxes when the expeted & configured 
ones are full.
   
   ## Impact
   
   Buffer overflow is serious and will break any code using time features. In 
my case, I am using CONFIG_NET_TIMESTAMP and SO_TIMESTAMP in my CAN sockets and 
I get a buffer overflow.
   
   The mailbox initialization will cause data loss as received CAN frames are 
placed on those unexpected mailboxes and RX code never checks them. On 
low-traffic scenarios this will be very unlikely as the first 5 RX mailboxes 
will be empty most of the time, not causing the "unconfigured" ones to be used.
   
   ## Testing
   
   I have observed both issues on my custom HW.
   
   To reproduce buffer overflow: just create a socket CAN and 
ioctl(...SO_TIMESTAMP...) to enable timestamping.
   To observe MAXMB problem: step into s32k1xx_reset using gdb and check the 
value of MCR after it is written.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to