-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cc1120 random number generator and stack smashing protection #297
base: main
Are you sure you want to change the base?
Conversation
obc/app/app_main.c
Outdated
@@ -40,6 +59,8 @@ int main(void) { | |||
initSciMutex(); | |||
initI2CMutex(); | |||
initSpiMutex(); | |||
cc1120Init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Navtajh04 any issues with this being called twice? I think we also call this in comms mgr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I would remove this from here and change the stack guard from comms mgr. We aren't really susceptible to any kind of stack smashing attacks until comms is established anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
especially since this is accessing cc1120, we should do it in comms mgr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
…l/OBC-firmware into catherine/stack_canary2
obc/app/app_main.c
Outdated
@@ -40,6 +59,8 @@ int main(void) { | |||
initSciMutex(); | |||
initI2CMutex(); | |||
initSpiMutex(); | |||
cc1120Init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I would remove this from here and change the stack guard from comms mgr. We aren't really susceptible to any kind of stack smashing attacks until comms is established anyways
obc/app/app_main.c
Outdated
uint32_t __stack_chk_guard_init(void); | ||
|
||
uint32_t __stack_chk_guard_change(void) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double __ is usually reserved for compiler specific stuff (ex: __stack_chk_guard is a special variable name used by GCC) so for these 2 helper functions we are defining ourselves (not special compiler keywords) we should use our regular function naming convention
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
obc/app/app_main.c
Outdated
@@ -40,6 +59,8 @@ int main(void) { | |||
initSciMutex(); | |||
initI2CMutex(); | |||
initSpiMutex(); | |||
cc1120Init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
especially since this is accessing cc1120, we should do it in comms mgr
obc/app/drivers/cc1120/cc1120_mcu.h
Outdated
#define CC1120_SPI_PORT spiPORT4 | ||
#define CC1120_SPI_CS 0 | ||
#define CC1120_SPI_PORT spiPORT3 | ||
#define CC1120_SPI_CS 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be changed, cc1120 is on SPI port 4 on obc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted
Co-authored-by: Navtajhundal <[email protected]>
… catherine/stack_canary2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some nits, otherwise lgtm
#include "obc_print.h" | ||
#include "obc_sci_io.h" | ||
#include <sci.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
#include "obc_sci_io.h" | ||
#include "cc1120_txrx.h" | ||
#include "cc1120.h" | ||
#include "obc_print.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove sci_io and print. move cc1120 includes to lines after #include lm75bd.h
|
||
#include <FreeRTOS.h> | ||
#include <os_portmacro.h> | ||
#include <os_queue.h> | ||
#include <os_task.h> | ||
#include <sys_common.h> | ||
#include <sci.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
|
||
#if defined(DEBUG) && !defined(OBC_REVISION_2) | ||
#include <gio.h> | ||
#endif | ||
|
||
extern void *__stack_chk_guard; | ||
#define STACK_BYTES 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not a completely accurate name, i would make it more specific. e.g. STACK_CANARY_BYTES
Purpose
Created a number generator function from the c1120 to generate a stack canary for stack overflow protection:
https://www.notion.so/uworbital/6375c5c5dcf1485e8a6c47f18d419ae5?v=72baf90d01f643b09d77418bd3f53b14&p=02e40c1185bb439d93fd92288137edcc&pm=s
New Changes
Testing
Stack canaries generated (generated after every reboot: )
Outstanding Changes