SlideShare a Scribd company logo
1 of 13
Download to read offline
Cyclone a safe dialect of C




    Prepared by: Ahmed Magdy Ezzeldin
What is CYCLONE

   Cyclone is a safer dialect of C that is not
    vulnerable to buffer overflows, format string
    attacks, double free bugs, dangling pointer
    accesses, etc...
   It qualifies ordinary C code with some
    annotations to make it safer.
   Cyclone has a special C compiler named
    ”cyclone” (built on GCC) which supports the
    special annotations of Cyclone.
How it works

    Cyclone works on the following aspects to make C safer.
   Pointers
   Regions
   Arrays
   Structs
   Unions
   Exceptions
   Subtyping
   Other Restrictions
Pointers
   @nullable : forces NULL-Check when dereferenced
   @thin : 1 machine word. It does not allow pointer arithmetics.
   @fat : 3 machine words. It allows pointer arithmetics forces
    NULL-Check and Bounds check when dereferenced.
   @notnull : It can never be NULL, so it does not need a NULL-
    Check.
   @zeroterm : It is used with strings to do safe pointer
    arithmetics on pointers by knowing the place of the zero byte
    delimiter.
   @effect(`e) : used to set the memory regions that this pointer
    can work.
   @aqual : used to define aliasability.
Regions

   Every pointer is assigned to a region
   Before dereferencing a pointer cyclone checks
    if its region is deallocated.
   Helps to secure against dangling pointers.
   Also important for securing against memory
    leaks as a data structure like a list or a queue
    can be assigned to one region, so when we
    free the region the whole data structure is freed
    without looping on pointers to free them.
Arrays

   Stack Arrays like in C
   Heap arrays using the word ”new”
   Arrays of pointers all pointers must be
    initialized which make it safer.
   Arrays can have the same annotations
    (qualifiers) as pointers.
Structs

   Cyclone structs are like C structs.
   Tuples is a form of structs that is not
    parameterized which means that its fields are
    accessed by their position (offset)
      $(int,char,bool) x = $(42,'z',true);
      if (x[2]) x[0]++;


   Tuples are equivalent if they are structurally
    equivalent.
Unions

   Tagged Unions: are unions that save the last written
    field identifier in a tag so that if we try to get the value
    of another field an exception is thrown.
    union T a;
    int x;
    a.String = "hello, world";
    /* Next line fails */
    x = a.Integer + 3;

   Untagged Pointers: It has no tag to know the last
    written field but It does not allow to have a pointer as
    one of its fields to be safer.
Exceptions
    Pointers NULL-Check and Bounds check and many
     other checks throw exceptions when they fail.
    Makes it easy for the developer to write robust code and
     take corrective measures on error.
     FILE *f = fopen("/etc/passwd","r"); int c;
try {
    c = getc((FILE *@notnull)f);
} catch {
case &Null_Exception:
    printf("Error: can't open /etc/passwdn");    exit(1);
case &Invalid_argument(s):
    printf("Error: Invalid_argument(%s)n",s);    exit(1);
}
Subtyping

    Cyclone allows structural subtyping which
     allows polymorphism which is not allowed in
     C.
typedef struct Point {float x,y;} *point;
typedef struct CPoint {float x,y; int color;} *cpoint;
float xcoord(point p) {
    return p->x;
}

    Note that both Point and CPoint are equal in
     structure with the exception of the last field in
     CPoint.
Other Restrictions

   Can't cast an integer to a pointer
   Can't do pointer arithmetic on a pointer unless
    the pointer performs bounds check
   Cyclone does not permit gotos from one scope
    into another.
   Can't explicitly free a heap-allocated object,
    but you can either use regions or the garbage
    collector to free memory.
References

   http://cyclone.thelanguage.org:8181/
   "Cyclone: A Type-Safe Dialect of C" by Dan
    Grossman, Michael Hicks, Trevor Jim, and
    Greg Morrisett
   "Region-Based Memory Management in
    Cyclone" by Dan Grossman, Greg Morrisett,
    Trevor Jim, Michael Hicks, Yanling Wang, and
    James Cheney (Computer Science
    Department, Cornell University)
Thank you

More Related Content

What's hot

Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppteShikshak
 
#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - TemplateHadziq Fabroyir
 
Binary expression tree
Binary expression treeBinary expression tree
Binary expression treeShab Bi
 
Can two fixpoint types in Mendler style unite?
Can two fixpoint types in Mendler style unite?Can two fixpoint types in Mendler style unite?
Can two fixpoint types in Mendler style unite?Ki Yung Ahn
 
1.4 expression tree
1.4 expression tree  1.4 expression tree
1.4 expression tree Krish_ver2
 
Computer notes - Expression Tree
Computer notes - Expression TreeComputer notes - Expression Tree
Computer notes - Expression Treeecomputernotes
 
Lesson 4.1 Extreme Values
Lesson 4.1 Extreme ValuesLesson 4.1 Extreme Values
Lesson 4.1 Extreme ValuesSharon Henry
 
Tools for reading papers
Tools for reading papersTools for reading papers
Tools for reading papersJack Fox
 
Aae oop xp_06
Aae oop xp_06Aae oop xp_06
Aae oop xp_06Niit Care
 
Symbian OS - Types And Declarations
Symbian OS - Types And DeclarationsSymbian OS - Types And Declarations
Symbian OS - Types And DeclarationsAndreas Jakl
 
La derivada (jox)
La derivada (jox)La derivada (jox)
La derivada (jox)jeuxevil
 

What's hot (20)

Type cast operator
Type cast operatorType cast operator
Type cast operator
 
7 decision-control
7 decision-control7 decision-control
7 decision-control
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppt
 
Format string vunerability
Format string vunerabilityFormat string vunerability
Format string vunerability
 
#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template
 
Binary expression tree
Binary expression treeBinary expression tree
Binary expression tree
 
Loop Statements [5] M
Loop Statements [5] MLoop Statements [5] M
Loop Statements [5] M
 
Can two fixpoint types in Mendler style unite?
Can two fixpoint types in Mendler style unite?Can two fixpoint types in Mendler style unite?
Can two fixpoint types in Mendler style unite?
 
1.4 expression tree
1.4 expression tree  1.4 expression tree
1.4 expression tree
 
Pointers
 Pointers Pointers
Pointers
 
Stacks
StacksStacks
Stacks
 
Py9 3
Py9 3Py9 3
Py9 3
 
Computer notes - Expression Tree
Computer notes - Expression TreeComputer notes - Expression Tree
Computer notes - Expression Tree
 
Lesson 4.1 Extreme Values
Lesson 4.1 Extreme ValuesLesson 4.1 Extreme Values
Lesson 4.1 Extreme Values
 
Storage classes
Storage classesStorage classes
Storage classes
 
Tools for reading papers
Tools for reading papersTools for reading papers
Tools for reading papers
 
Aae oop xp_06
Aae oop xp_06Aae oop xp_06
Aae oop xp_06
 
Symbian OS - Types And Declarations
Symbian OS - Types And DeclarationsSymbian OS - Types And Declarations
Symbian OS - Types And Declarations
 
La derivada (jox)
La derivada (jox)La derivada (jox)
La derivada (jox)
 
Storage classes
Storage classesStorage classes
Storage classes
 

Viewers also liked

Python - na uzlazu ili silazu?
Python - na uzlazu ili silazu?Python - na uzlazu ili silazu?
Python - na uzlazu ili silazu?Robert Lujo
 
Razvoj softvera: crno/bijeli svijet?
Razvoj softvera: crno/bijeli svijet?Razvoj softvera: crno/bijeli svijet?
Razvoj softvera: crno/bijeli svijet?Robert Lujo
 
Ajeb First Seminar
Ajeb First SeminarAjeb First Seminar
Ajeb First SeminarKhaled Sayed
 
Parallel architecture &programming
Parallel architecture &programmingParallel architecture &programming
Parallel architecture &programmingIsmail El Gayar
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-wayRobert Lujo
 
Object.__class__.__dict__ - python object model and friends - with examples
Object.__class__.__dict__ - python object model and friends - with examplesObject.__class__.__dict__ - python object model and friends - with examples
Object.__class__.__dict__ - python object model and friends - with examplesRobert Lujo
 
Answer Selection and Validation for Arabic Questions
Answer Selection and Validation for Arabic QuestionsAnswer Selection and Validation for Arabic Questions
Answer Selection and Validation for Arabic QuestionsAhmed Magdy Ezzeldin, MSc.
 
Introduction and Starting ASP.NET MVC
Introduction and Starting ASP.NET MVCIntroduction and Starting ASP.NET MVC
Introduction and Starting ASP.NET MVCYogendra Tamang
 
Infromation Reprentation, Structured Data and Semantics
Infromation Reprentation,Structured Data and SemanticsInfromation Reprentation,Structured Data and Semantics
Infromation Reprentation, Structured Data and SemanticsYogendra Tamang
 
Artificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console applicationArtificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console applicationEduardo Gulias Davis
 
ElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseRobert Lujo
 
Object oriented methodology & unified modeling language
Object oriented methodology & unified modeling languageObject oriented methodology & unified modeling language
Object oriented methodology & unified modeling languageIsmail El Gayar
 
Geographic Information System for Egyptian Railway System(GIS)
Geographic Information System for Egyptian Railway System(GIS)Geographic Information System for Egyptian Railway System(GIS)
Geographic Information System for Egyptian Railway System(GIS)Ismail El Gayar
 

Viewers also liked (20)

Python - na uzlazu ili silazu?
Python - na uzlazu ili silazu?Python - na uzlazu ili silazu?
Python - na uzlazu ili silazu?
 
Razvoj softvera: crno/bijeli svijet?
Razvoj softvera: crno/bijeli svijet?Razvoj softvera: crno/bijeli svijet?
Razvoj softvera: crno/bijeli svijet?
 
Networks and Natural Language Processing
Networks and Natural Language ProcessingNetworks and Natural Language Processing
Networks and Natural Language Processing
 
Ajeb First Seminar
Ajeb First SeminarAjeb First Seminar
Ajeb First Seminar
 
Parallel architecture &programming
Parallel architecture &programmingParallel architecture &programming
Parallel architecture &programming
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 
Object.__class__.__dict__ - python object model and friends - with examples
Object.__class__.__dict__ - python object model and friends - with examplesObject.__class__.__dict__ - python object model and friends - with examples
Object.__class__.__dict__ - python object model and friends - with examples
 
Answer Selection and Validation for Arabic Questions
Answer Selection and Validation for Arabic QuestionsAnswer Selection and Validation for Arabic Questions
Answer Selection and Validation for Arabic Questions
 
Bash Scripting Workshop
Bash Scripting WorkshopBash Scripting Workshop
Bash Scripting Workshop
 
ADO.NET Introduction
ADO.NET IntroductionADO.NET Introduction
ADO.NET Introduction
 
Introduction and Starting ASP.NET MVC
Introduction and Starting ASP.NET MVCIntroduction and Starting ASP.NET MVC
Introduction and Starting ASP.NET MVC
 
Infromation Reprentation, Structured Data and Semantics
Infromation Reprentation,Structured Data and SemanticsInfromation Reprentation,Structured Data and Semantics
Infromation Reprentation, Structured Data and Semantics
 
Computer science -
Computer science -Computer science -
Computer science -
 
Artificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console applicationArtificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console application
 
Task programming
Task programmingTask programming
Task programming
 
Electronics projects
Electronics projectsElectronics projects
Electronics projects
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
 
ElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseElasticSearch - index server used as a document database
ElasticSearch - index server used as a document database
 
Object oriented methodology & unified modeling language
Object oriented methodology & unified modeling languageObject oriented methodology & unified modeling language
Object oriented methodology & unified modeling language
 
Geographic Information System for Egyptian Railway System(GIS)
Geographic Information System for Egyptian Railway System(GIS)Geographic Information System for Egyptian Railway System(GIS)
Geographic Information System for Egyptian Railway System(GIS)
 

Similar to Cyclone a safe dialect of C

Missilecommand
MissilecommandMissilecommand
MissilecommandSusan Gold
 
Rust "Hot or Not" at Sioux
Rust "Hot or Not" at SiouxRust "Hot or Not" at Sioux
Rust "Hot or Not" at Siouxnikomatsakis
 
C interview questions
C interview questionsC interview questions
C interview questionsSoba Arjun
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And AnswerJagan Mohan Bishoyi
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answerlavparmar007
 
The c++coreguidelinesforsavercode
The c++coreguidelinesforsavercodeThe c++coreguidelinesforsavercode
The c++coreguidelinesforsavercodeDivyang Panchasara
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
 
Dynamic memory allocation in c++
Dynamic memory allocation in c++Dynamic memory allocation in c++
Dynamic memory allocation in c++Tech_MX
 
Introduction to structures in c lang.ppt
Introduction to structures in c lang.pptIntroduction to structures in c lang.ppt
Introduction to structures in c lang.pptshivani366010
 
presentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxpresentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxKrishanPalSingh39
 

Similar to Cyclone a safe dialect of C (20)

Cpprm
CpprmCpprm
Cpprm
 
Missilecommand
MissilecommandMissilecommand
Missilecommand
 
Rust "Hot or Not" at Sioux
Rust "Hot or Not" at SiouxRust "Hot or Not" at Sioux
Rust "Hot or Not" at Sioux
 
C interview questions
C interview questionsC interview questions
C interview questions
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
 
C language
C languageC language
C language
 
Clanguage
ClanguageClanguage
Clanguage
 
The c++coreguidelinesforsavercode
The c++coreguidelinesforsavercodeThe c++coreguidelinesforsavercode
The c++coreguidelinesforsavercode
 
C language
C languageC language
C language
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
C# note
C# noteC# note
C# note
 
Oops lecture 1
Oops lecture 1Oops lecture 1
Oops lecture 1
 
C++ language
C++ languageC++ language
C++ language
 
5_IntermediateCodeGeneration.ppt
5_IntermediateCodeGeneration.ppt5_IntermediateCodeGeneration.ppt
5_IntermediateCodeGeneration.ppt
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 
Dynamic memory allocation in c++
Dynamic memory allocation in c++Dynamic memory allocation in c++
Dynamic memory allocation in c++
 
structures.ppt
structures.pptstructures.ppt
structures.ppt
 
Introduction to structures in c lang.ppt
Introduction to structures in c lang.pptIntroduction to structures in c lang.ppt
Introduction to structures in c lang.ppt
 
presentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxpresentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptx
 

More from Ahmed Magdy Ezzeldin, MSc.

More from Ahmed Magdy Ezzeldin, MSc. (9)

Distributed RDBMS: Challenges, Solutions & Trade-offs
Distributed RDBMS: Challenges, Solutions & Trade-offsDistributed RDBMS: Challenges, Solutions & Trade-offs
Distributed RDBMS: Challenges, Solutions & Trade-offs
 
Win any Interview like a Boss
Win any Interview like a BossWin any Interview like a Boss
Win any Interview like a Boss
 
Arabic Question Answering: Challenges, Tasks, Approaches, Test-sets, Tools, A...
Arabic Question Answering: Challenges, Tasks, Approaches, Test-sets, Tools, A...Arabic Question Answering: Challenges, Tasks, Approaches, Test-sets, Tools, A...
Arabic Question Answering: Challenges, Tasks, Approaches, Test-sets, Tools, A...
 
A survey of fault prediction using machine learning algorithms
A survey of fault prediction using machine learning algorithmsA survey of fault prediction using machine learning algorithms
A survey of fault prediction using machine learning algorithms
 
GATE : General Architecture for Text Engineering
GATE : General Architecture for Text EngineeringGATE : General Architecture for Text Engineering
GATE : General Architecture for Text Engineering
 
Distributed Coordination-Based Systems
Distributed Coordination-Based SystemsDistributed Coordination-Based Systems
Distributed Coordination-Based Systems
 
Distributed Systems Naming
Distributed Systems NamingDistributed Systems Naming
Distributed Systems Naming
 
Objective C Memory Management
Objective C Memory ManagementObjective C Memory Management
Objective C Memory Management
 
Object Role Modeling
Object Role ModelingObject Role Modeling
Object Role Modeling
 

Recently uploaded

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Cyclone a safe dialect of C

  • 1. Cyclone a safe dialect of C Prepared by: Ahmed Magdy Ezzeldin
  • 2. What is CYCLONE  Cyclone is a safer dialect of C that is not vulnerable to buffer overflows, format string attacks, double free bugs, dangling pointer accesses, etc...  It qualifies ordinary C code with some annotations to make it safer.  Cyclone has a special C compiler named ”cyclone” (built on GCC) which supports the special annotations of Cyclone.
  • 3. How it works Cyclone works on the following aspects to make C safer.  Pointers  Regions  Arrays  Structs  Unions  Exceptions  Subtyping  Other Restrictions
  • 4. Pointers  @nullable : forces NULL-Check when dereferenced  @thin : 1 machine word. It does not allow pointer arithmetics.  @fat : 3 machine words. It allows pointer arithmetics forces NULL-Check and Bounds check when dereferenced.  @notnull : It can never be NULL, so it does not need a NULL- Check.  @zeroterm : It is used with strings to do safe pointer arithmetics on pointers by knowing the place of the zero byte delimiter.  @effect(`e) : used to set the memory regions that this pointer can work.  @aqual : used to define aliasability.
  • 5. Regions  Every pointer is assigned to a region  Before dereferencing a pointer cyclone checks if its region is deallocated.  Helps to secure against dangling pointers.  Also important for securing against memory leaks as a data structure like a list or a queue can be assigned to one region, so when we free the region the whole data structure is freed without looping on pointers to free them.
  • 6. Arrays  Stack Arrays like in C  Heap arrays using the word ”new”  Arrays of pointers all pointers must be initialized which make it safer.  Arrays can have the same annotations (qualifiers) as pointers.
  • 7. Structs  Cyclone structs are like C structs.  Tuples is a form of structs that is not parameterized which means that its fields are accessed by their position (offset) $(int,char,bool) x = $(42,'z',true); if (x[2]) x[0]++;  Tuples are equivalent if they are structurally equivalent.
  • 8. Unions  Tagged Unions: are unions that save the last written field identifier in a tag so that if we try to get the value of another field an exception is thrown. union T a; int x; a.String = "hello, world"; /* Next line fails */ x = a.Integer + 3;  Untagged Pointers: It has no tag to know the last written field but It does not allow to have a pointer as one of its fields to be safer.
  • 9. Exceptions  Pointers NULL-Check and Bounds check and many other checks throw exceptions when they fail.  Makes it easy for the developer to write robust code and take corrective measures on error. FILE *f = fopen("/etc/passwd","r"); int c; try { c = getc((FILE *@notnull)f); } catch { case &Null_Exception: printf("Error: can't open /etc/passwdn"); exit(1); case &Invalid_argument(s): printf("Error: Invalid_argument(%s)n",s); exit(1); }
  • 10. Subtyping  Cyclone allows structural subtyping which allows polymorphism which is not allowed in C. typedef struct Point {float x,y;} *point; typedef struct CPoint {float x,y; int color;} *cpoint; float xcoord(point p) { return p->x; }  Note that both Point and CPoint are equal in structure with the exception of the last field in CPoint.
  • 11. Other Restrictions  Can't cast an integer to a pointer  Can't do pointer arithmetic on a pointer unless the pointer performs bounds check  Cyclone does not permit gotos from one scope into another.  Can't explicitly free a heap-allocated object, but you can either use regions or the garbage collector to free memory.
  • 12. References  http://cyclone.thelanguage.org:8181/  "Cyclone: A Type-Safe Dialect of C" by Dan Grossman, Michael Hicks, Trevor Jim, and Greg Morrisett  "Region-Based Memory Management in Cyclone" by Dan Grossman, Greg Morrisett, Trevor Jim, Michael Hicks, Yanling Wang, and James Cheney (Computer Science Department, Cornell University)