SlideShare a Scribd company logo
1 of 3
Brooks Davis: Is it time to replace mmap?
“Memory” Throughout Unix History
● PDP-11 c. 1970
Process Address Space
● 0x0 - 0x7ff..f
● code, data, bss
● Null pointer trapping, Stack, Heap
● Physical address space
○ Copy on write
Process Address Space (cont.)
● Break -> … <- SP
● Break: highest address in address space that’s in use
● Single thread programs have their stack space magically managed
UNIX and BSD
● (combed through combined Unix history git repo)
● How was the break set?
○ PDP-7? 1970
○ 1972 V1: sysbreak syscall
○ 1972 V2: break syscall
○ 1973 V3: break syscall and docs
■ break sets the system’s idea of the highest location used by the program to addr.
Locations greater than addr and below the stack pointer are not swapped and are thus
liable to unexpected modifications.
○ 1974 V4: sbrk syscall, no with protection
■ manpage: memory violation will occur
○ 1975 V5: brk() introduced
○ 1983 4.2BSD: references to mmap()
Heap fragmentation (Problem with sbrk)
Memory Sharing
● read only mappings share physical memory, potentially TLB entries though not generally
Dynamic Linking
● use case where sharing is crucial (e.g. libc size v.s. Unix tool)
Multi-threaded programs
● multiple stacks
● brk, sbrk interface problematic for stack allocation (stack interleaved with heap)
● no guard pages
● want stack to still be at the bottom of the address space plus guard pages
4.2BSD memory interfaces
● mmap()
○ allocate addr space
○ alter backing mappings
● mremap()
○ relocate or extend mapping, no BSD implements it, Linux has a implementation
● munmap()
○ remove backing
● mprotect()
○ alter page protections
● madvise()
○ hints memory usage to kernel (Will need soon, page it in. Won’t need again. Free content after
read)
● mincore()
○ query backing status
● sbrk()
○ extend or reduce “break”
● sstk()
○ extend or reduce stack.
● 4.2BSD: only sbrk() was implemented. All other interfaces were empty functions.
Back to History
● 1990 4.3-Reno: mmap() implemented with VM from Mach
○ VM implementation came from Mach but the mmap() interface was a BSD invention
● 2003 OpenBSD 3.3: implements W^X (writable or executable)
W^X and JITs
● Map PROT_WRITE then remove PROT_WRITE and add PROT_EXEC
● most pages cannot express “most pages should not become executable”
Back to History
● 2010 CHERI Project
○ pointers with bounds and permissions
■ strong monotonicity guarantees: read capability cannot turn into executable capability
○ Want W^X for pointers (in addition to pages)
○ API changes required:
■ make mprotect() return a pointer?
■ some other interface?
mmap() functionality issues
● conflates address reservation and mapping
○ lack of boundaries between reservations leads to bugs: e.g. Stack Clash
● Lack of expressiveness
○ portable way to express alignment (e.g. on superpage boundary)
○ no way to express maximum permission
mmap() API issues
● Too many arguments
● Too many failure modes
○ FreeBSD 11: 19 documented errors (15 use the same error code, EINVAL)
Other mmap() issues
● No support for mapping more pages than requested
○ can’t round up to superpage size
○ CHERI bounds compression requires rounding for very large allocations
● No concept of address space ownership
○ math errors mean changing the wrong region
RFC: cmmap (⅓)
● int cmreserve(cmt_t *handlep, size_t length, vaddr_t hint, int prot, cmreq_t *cmr);
○ reserve a region (optionally mapping)
● int cmgetptr(cm_t handle void **ptrp);
○ get pointer to region
RFC cmmap(⅔)
● int cmap(cm_t handle, cmreq_t *cmr);
○ replace (part of) a region’s mappings
● int cmclose(cmt _handle);
○ close a handle, freeing memory
● int cmrestrict(cm_t handle, XX ops, XX *oops);
○ restrict the set of operations on a handle
● int cmstat(cmt_t handle, size_t index, struct cm_stat *cs);
○ return data on a series of submaps
○ want cm_t handle to not be a file descriptor or all mappings would be enumerable and would
break ASLR
● cmadvise(), …
○ operate within a region
Map request objects
● cm_request_t is like pthread_attr_t
● Accessor functions
● Goal: useful defaults
CHERI extensions
● int cmgetcap(cm_t cookie, void **ptrp, perm_t perms)
○ get capability pointer
● int cmandperm()
○ reduce permissions
Should We Replace mmap()?
● Yes, No
Q&A
● ...
Aside: FreeBSD 11 shipped ARM64 and RISC-V without sbrk(), pretty much only Emacs broke as a result

More Related Content

What's hot

Parallel computing in bioinformatics t.seemann - balti bioinformatics - wed...
Parallel computing in bioinformatics   t.seemann - balti bioinformatics - wed...Parallel computing in bioinformatics   t.seemann - balti bioinformatics - wed...
Parallel computing in bioinformatics t.seemann - balti bioinformatics - wed...Torsten Seemann
 
Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...
Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...
Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...Codemotion
 
Cassandra 2.1 boot camp, exercise
Cassandra 2.1 boot camp, exerciseCassandra 2.1 boot camp, exercise
Cassandra 2.1 boot camp, exerciseJoshua McKenzie
 
自分だけのデバイスを作るお話
自分だけのデバイスを作るお話自分だけのデバイスを作るお話
自分だけのデバイスを作るお話kishima7
 
Data Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of HanoiData Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of HanoiManishPrajapati78
 
Tower Of Hanoi -A MatheMatical PuZzle
Tower Of Hanoi -A MatheMatical PuZzleTower Of Hanoi -A MatheMatical PuZzle
Tower Of Hanoi -A MatheMatical PuZzlepurvanahar
 
Your data isn't that big @ Big Things Meetup 2016-05-16
Your data isn't that big @ Big Things Meetup 2016-05-16Your data isn't that big @ Big Things Meetup 2016-05-16
Your data isn't that big @ Big Things Meetup 2016-05-16Boaz Menuhin
 
Clusters with GlusterFS
Clusters with GlusterFSClusters with GlusterFS
Clusters with GlusterFSMarian Marinov
 
Vrml, or There and Back Again
Vrml, or There and Back AgainVrml, or There and Back Again
Vrml, or There and Back AgainTony Parisi
 
Dc8c4f010f40.hanoi.towers
Dc8c4f010f40.hanoi.towersDc8c4f010f40.hanoi.towers
Dc8c4f010f40.hanoi.towersSumedha
 
Cassandra 2.1 boot camp, Compaction
Cassandra 2.1 boot camp, CompactionCassandra 2.1 boot camp, Compaction
Cassandra 2.1 boot camp, CompactionJoshua McKenzie
 
Tower of Hanoi Method
Tower of Hanoi MethodTower of Hanoi Method
Tower of Hanoi MethodMDHALIM7
 

What's hot (17)

Parallel computing in bioinformatics t.seemann - balti bioinformatics - wed...
Parallel computing in bioinformatics   t.seemann - balti bioinformatics - wed...Parallel computing in bioinformatics   t.seemann - balti bioinformatics - wed...
Parallel computing in bioinformatics t.seemann - balti bioinformatics - wed...
 
Project_Report1
Project_Report1Project_Report1
Project_Report1
 
Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...
Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...
Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...
 
Tower Of Hanoi
Tower Of HanoiTower Of Hanoi
Tower Of Hanoi
 
Cassandra 2.1 boot camp, exercise
Cassandra 2.1 boot camp, exerciseCassandra 2.1 boot camp, exercise
Cassandra 2.1 boot camp, exercise
 
自分だけのデバイスを作るお話
自分だけのデバイスを作るお話自分だけのデバイスを作るお話
自分だけのデバイスを作るお話
 
Sysprog 15
Sysprog 15Sysprog 15
Sysprog 15
 
Data Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of HanoiData Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of Hanoi
 
Tower Of Hanoi -A MatheMatical PuZzle
Tower Of Hanoi -A MatheMatical PuZzleTower Of Hanoi -A MatheMatical PuZzle
Tower Of Hanoi -A MatheMatical PuZzle
 
Your data isn't that big @ Big Things Meetup 2016-05-16
Your data isn't that big @ Big Things Meetup 2016-05-16Your data isn't that big @ Big Things Meetup 2016-05-16
Your data isn't that big @ Big Things Meetup 2016-05-16
 
Tower of Hanoi
Tower of HanoiTower of Hanoi
Tower of Hanoi
 
Clusters with GlusterFS
Clusters with GlusterFSClusters with GlusterFS
Clusters with GlusterFS
 
Tower of hanoi
Tower of hanoiTower of hanoi
Tower of hanoi
 
Vrml, or There and Back Again
Vrml, or There and Back AgainVrml, or There and Back Again
Vrml, or There and Back Again
 
Dc8c4f010f40.hanoi.towers
Dc8c4f010f40.hanoi.towersDc8c4f010f40.hanoi.towers
Dc8c4f010f40.hanoi.towers
 
Cassandra 2.1 boot camp, Compaction
Cassandra 2.1 boot camp, CompactionCassandra 2.1 boot camp, Compaction
Cassandra 2.1 boot camp, Compaction
 
Tower of Hanoi Method
Tower of Hanoi MethodTower of Hanoi Method
Tower of Hanoi Method
 

Similar to Bsdtw17: brooks davis: is it time to replace mmap?

MapDB - taking Java collections to the next level
MapDB - taking Java collections to the next levelMapDB - taking Java collections to the next level
MapDB - taking Java collections to the next levelJavaDayUA
 
Bsdtw17: ruslan bukin: free bsd/risc-v and device drivers
Bsdtw17: ruslan bukin: free bsd/risc-v and device driversBsdtw17: ruslan bukin: free bsd/risc-v and device drivers
Bsdtw17: ruslan bukin: free bsd/risc-v and device driversScott Tsai
 
C++ Advanced Memory Management With Allocators
C++ Advanced Memory Management With AllocatorsC++ Advanced Memory Management With Allocators
C++ Advanced Memory Management With AllocatorsGlobalLogic Ukraine
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)shimosawa
 
Linux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBLinux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBshimosawa
 
FreeBSD and Drivers
FreeBSD and DriversFreeBSD and Drivers
FreeBSD and DriversKernel TLV
 
Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Graham Wihlidal
 
Understanding the virtual memory - Ixia Connect #2
Understanding the virtual memory - Ixia Connect #2Understanding the virtual memory - Ixia Connect #2
Understanding the virtual memory - Ixia Connect #2IxiaRomania
 
LECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphesLECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphesAhmedMahjoub15
 
Scaling Cassandra for Big Data
Scaling Cassandra for Big DataScaling Cassandra for Big Data
Scaling Cassandra for Big DataDataStax Academy
 
GPU Introduction.pptx
 GPU Introduction.pptx GPU Introduction.pptx
GPU Introduction.pptxSherazMunawar5
 
Physical Memory Models.pdf
Physical Memory Models.pdfPhysical Memory Models.pdf
Physical Memory Models.pdfAdrian Huang
 
Caching in (DevoxxUK 2013)
Caching in (DevoxxUK 2013)Caching in (DevoxxUK 2013)
Caching in (DevoxxUK 2013)RichardWarburton
 

Similar to Bsdtw17: brooks davis: is it time to replace mmap? (20)

Unix Ramblings
Unix RamblingsUnix Ramblings
Unix Ramblings
 
memory_mapping.ppt
memory_mapping.pptmemory_mapping.ppt
memory_mapping.ppt
 
Linux memory
Linux memoryLinux memory
Linux memory
 
Feel++ webinar 9 27 2012
Feel++ webinar 9 27 2012Feel++ webinar 9 27 2012
Feel++ webinar 9 27 2012
 
MapDB - taking Java collections to the next level
MapDB - taking Java collections to the next levelMapDB - taking Java collections to the next level
MapDB - taking Java collections to the next level
 
Memory
MemoryMemory
Memory
 
Bsdtw17: ruslan bukin: free bsd/risc-v and device drivers
Bsdtw17: ruslan bukin: free bsd/risc-v and device driversBsdtw17: ruslan bukin: free bsd/risc-v and device drivers
Bsdtw17: ruslan bukin: free bsd/risc-v and device drivers
 
Virtual memory 20070222-en
Virtual memory 20070222-enVirtual memory 20070222-en
Virtual memory 20070222-en
 
C++ Advanced Memory Management With Allocators
C++ Advanced Memory Management With AllocatorsC++ Advanced Memory Management With Allocators
C++ Advanced Memory Management With Allocators
 
Linux Huge Pages
Linux Huge PagesLinux Huge Pages
Linux Huge Pages
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 
Linux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBLinux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKB
 
FreeBSD and Drivers
FreeBSD and DriversFreeBSD and Drivers
FreeBSD and Drivers
 
Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016
 
Understanding the virtual memory - Ixia Connect #2
Understanding the virtual memory - Ixia Connect #2Understanding the virtual memory - Ixia Connect #2
Understanding the virtual memory - Ixia Connect #2
 
LECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphesLECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphes
 
Scaling Cassandra for Big Data
Scaling Cassandra for Big DataScaling Cassandra for Big Data
Scaling Cassandra for Big Data
 
GPU Introduction.pptx
 GPU Introduction.pptx GPU Introduction.pptx
GPU Introduction.pptx
 
Physical Memory Models.pdf
Physical Memory Models.pdfPhysical Memory Models.pdf
Physical Memory Models.pdf
 
Caching in (DevoxxUK 2013)
Caching in (DevoxxUK 2013)Caching in (DevoxxUK 2013)
Caching in (DevoxxUK 2013)
 

More from Scott Tsai

Bsdtw17: arun thomas: risc v berkeley hardware for your berkeley software dis...
Bsdtw17: arun thomas: risc v berkeley hardware for your berkeley software dis...Bsdtw17: arun thomas: risc v berkeley hardware for your berkeley software dis...
Bsdtw17: arun thomas: risc v berkeley hardware for your berkeley software dis...Scott Tsai
 
Bsdtw17: george neville neil: realities of dtrace on free-bsd
Bsdtw17: george neville neil: realities of dtrace on free-bsdBsdtw17: george neville neil: realities of dtrace on free-bsd
Bsdtw17: george neville neil: realities of dtrace on free-bsdScott Tsai
 
Bsdtw17: allan jude: zfs: advanced integration
Bsdtw17: allan jude: zfs: advanced integrationBsdtw17: allan jude: zfs: advanced integration
Bsdtw17: allan jude: zfs: advanced integrationScott Tsai
 
Bsdtw17: theo de raadt: mitigations and other real security features
Bsdtw17: theo de raadt: mitigations and other real security featuresBsdtw17: theo de raadt: mitigations and other real security features
Bsdtw17: theo de raadt: mitigations and other real security featuresScott Tsai
 
Bsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicum
Bsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicumBsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicum
Bsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicumScott Tsai
 
Bsdtw17: lightning talks/wip sessions
Bsdtw17: lightning talks/wip sessionsBsdtw17: lightning talks/wip sessions
Bsdtw17: lightning talks/wip sessionsScott Tsai
 
Bsdtw17: johannes m dieterich: high performance computing and gpu acceleratio...
Bsdtw17: johannes m dieterich: high performance computing and gpu acceleratio...Bsdtw17: johannes m dieterich: high performance computing and gpu acceleratio...
Bsdtw17: johannes m dieterich: high performance computing and gpu acceleratio...Scott Tsai
 

More from Scott Tsai (7)

Bsdtw17: arun thomas: risc v berkeley hardware for your berkeley software dis...
Bsdtw17: arun thomas: risc v berkeley hardware for your berkeley software dis...Bsdtw17: arun thomas: risc v berkeley hardware for your berkeley software dis...
Bsdtw17: arun thomas: risc v berkeley hardware for your berkeley software dis...
 
Bsdtw17: george neville neil: realities of dtrace on free-bsd
Bsdtw17: george neville neil: realities of dtrace on free-bsdBsdtw17: george neville neil: realities of dtrace on free-bsd
Bsdtw17: george neville neil: realities of dtrace on free-bsd
 
Bsdtw17: allan jude: zfs: advanced integration
Bsdtw17: allan jude: zfs: advanced integrationBsdtw17: allan jude: zfs: advanced integration
Bsdtw17: allan jude: zfs: advanced integration
 
Bsdtw17: theo de raadt: mitigations and other real security features
Bsdtw17: theo de raadt: mitigations and other real security featuresBsdtw17: theo de raadt: mitigations and other real security features
Bsdtw17: theo de raadt: mitigations and other real security features
 
Bsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicum
Bsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicumBsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicum
Bsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicum
 
Bsdtw17: lightning talks/wip sessions
Bsdtw17: lightning talks/wip sessionsBsdtw17: lightning talks/wip sessions
Bsdtw17: lightning talks/wip sessions
 
Bsdtw17: johannes m dieterich: high performance computing and gpu acceleratio...
Bsdtw17: johannes m dieterich: high performance computing and gpu acceleratio...Bsdtw17: johannes m dieterich: high performance computing and gpu acceleratio...
Bsdtw17: johannes m dieterich: high performance computing and gpu acceleratio...
 

Recently uploaded

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 

Recently uploaded (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 

Bsdtw17: brooks davis: is it time to replace mmap?

  • 1. Brooks Davis: Is it time to replace mmap? “Memory” Throughout Unix History ● PDP-11 c. 1970 Process Address Space ● 0x0 - 0x7ff..f ● code, data, bss ● Null pointer trapping, Stack, Heap ● Physical address space ○ Copy on write Process Address Space (cont.) ● Break -> … <- SP ● Break: highest address in address space that’s in use ● Single thread programs have their stack space magically managed UNIX and BSD ● (combed through combined Unix history git repo) ● How was the break set? ○ PDP-7? 1970 ○ 1972 V1: sysbreak syscall ○ 1972 V2: break syscall ○ 1973 V3: break syscall and docs ■ break sets the system’s idea of the highest location used by the program to addr. Locations greater than addr and below the stack pointer are not swapped and are thus liable to unexpected modifications. ○ 1974 V4: sbrk syscall, no with protection ■ manpage: memory violation will occur ○ 1975 V5: brk() introduced ○ 1983 4.2BSD: references to mmap() Heap fragmentation (Problem with sbrk) Memory Sharing ● read only mappings share physical memory, potentially TLB entries though not generally Dynamic Linking ● use case where sharing is crucial (e.g. libc size v.s. Unix tool) Multi-threaded programs ● multiple stacks ● brk, sbrk interface problematic for stack allocation (stack interleaved with heap) ● no guard pages ● want stack to still be at the bottom of the address space plus guard pages 4.2BSD memory interfaces ● mmap() ○ allocate addr space ○ alter backing mappings ● mremap() ○ relocate or extend mapping, no BSD implements it, Linux has a implementation ● munmap() ○ remove backing ● mprotect() ○ alter page protections ● madvise() ○ hints memory usage to kernel (Will need soon, page it in. Won’t need again. Free content after read) ● mincore()
  • 2. ○ query backing status ● sbrk() ○ extend or reduce “break” ● sstk() ○ extend or reduce stack. ● 4.2BSD: only sbrk() was implemented. All other interfaces were empty functions. Back to History ● 1990 4.3-Reno: mmap() implemented with VM from Mach ○ VM implementation came from Mach but the mmap() interface was a BSD invention ● 2003 OpenBSD 3.3: implements W^X (writable or executable) W^X and JITs ● Map PROT_WRITE then remove PROT_WRITE and add PROT_EXEC ● most pages cannot express “most pages should not become executable” Back to History ● 2010 CHERI Project ○ pointers with bounds and permissions ■ strong monotonicity guarantees: read capability cannot turn into executable capability ○ Want W^X for pointers (in addition to pages) ○ API changes required: ■ make mprotect() return a pointer? ■ some other interface? mmap() functionality issues ● conflates address reservation and mapping ○ lack of boundaries between reservations leads to bugs: e.g. Stack Clash ● Lack of expressiveness ○ portable way to express alignment (e.g. on superpage boundary) ○ no way to express maximum permission mmap() API issues ● Too many arguments ● Too many failure modes ○ FreeBSD 11: 19 documented errors (15 use the same error code, EINVAL) Other mmap() issues ● No support for mapping more pages than requested ○ can’t round up to superpage size ○ CHERI bounds compression requires rounding for very large allocations ● No concept of address space ownership ○ math errors mean changing the wrong region RFC: cmmap (⅓) ● int cmreserve(cmt_t *handlep, size_t length, vaddr_t hint, int prot, cmreq_t *cmr); ○ reserve a region (optionally mapping) ● int cmgetptr(cm_t handle void **ptrp); ○ get pointer to region RFC cmmap(⅔) ● int cmap(cm_t handle, cmreq_t *cmr); ○ replace (part of) a region’s mappings ● int cmclose(cmt _handle); ○ close a handle, freeing memory ● int cmrestrict(cm_t handle, XX ops, XX *oops); ○ restrict the set of operations on a handle ● int cmstat(cmt_t handle, size_t index, struct cm_stat *cs); ○ return data on a series of submaps ○ want cm_t handle to not be a file descriptor or all mappings would be enumerable and would break ASLR ● cmadvise(), …
  • 3. ○ operate within a region Map request objects ● cm_request_t is like pthread_attr_t ● Accessor functions ● Goal: useful defaults CHERI extensions ● int cmgetcap(cm_t cookie, void **ptrp, perm_t perms) ○ get capability pointer ● int cmandperm() ○ reduce permissions Should We Replace mmap()? ● Yes, No Q&A ● ... Aside: FreeBSD 11 shipped ARM64 and RISC-V without sbrk(), pretty much only Emacs broke as a result