SlideShare a Scribd company logo
I/O multiplexing
AIdrifter 2015/1/25
Problem
• Samba smbd will crash when timeout is
negative
• Analysis FreeBSD poll and select…
Descriptive
Name
File
Number
Description
StandardIn 0 Inputfromthe keyboard
StandardOut 1 Outputtothe console
StandardError 2
Error outputtothe
console
Process
File descriptor
Five IO models
blocking I/O: blocked all the way
non-blocking I/O: if no data in buffer, immediate
returns EWOULDBLOCK
I/O multiplexing (select and poll): blocked
separately in wait and copy
signal driven I/O (SIGIO): non-blocked in wait
but blocked in copy (signaled when I/O can be
initiated)
asynchronous I/O (aio_): non-blocked all the way
(signaled when I/O is complete)
Kernel’s
buffer
IO
Device
User
process
Wait for data
copy date
(system call)
Kernel’s
buffer
IO
Device
User
process
Select and poll
Select
1.Is the device readyfor reading? (writing
2.Kernel check the device buffer’s limits
->READY for reading(writing
3.Select return
IO Device
Kernel’s
buffer
User
process
INTPUT OUTPUT
4.Copy data by system
call(READ WRITE
no yes
4. next Select()
Select
• #include <sys/select.h>
• int select( int nfds,
fd_set *readset,
fd_set *writeset,
fd_set *exceptset,
struct timeval *timeout)
• struct timeval { /* Epoch 1970 1/1 00:00 */
long tv_sec; /* seconds*/
long tv_usec; /* microseconds*/
}
Timeout
 NULL blocking infinite time
 timout->tv-sec=10 wait ten seconds
 timout->tv-sec=10 =0 search once and return
nfds
Search range
0 0 0 0 0 0 0 0
fd0 fd1023
0
0 0 0 0 0 0 0 0
fd0 fd1023
0
0 0 0 0 0 0 0 0
fd0 fd1023
0
readset
writeset
execptset
FILE descriptors
0 0 0 0 0 0 0 0
fd0 fd1023
FD_ZERO(fd_set *fdset)
initial
0
0 0 0 0 1 0 0 0
fd0 fd1023
FD_SET(int fd,fd_set *fdset)
loop
0
0 0 0 0 0 0 0 0
fd0 fd1023
FD_CLR(int fd,fd_set *fdset)
Don’t use the device
0
0 0 0 0 0 0 0 0
fd0 fd1023 FD_ISSET(int fd,fd_set *fdset)
Check ready?
->READ or WRITE
0
Check ready?
POLL
poll -- synchronousI/Omultiplexing
int poll (structpollfd fds[],
nfds_t nfds,
int timeout);
1.沒有最大文件描述符數量的限制。
2.Overhead is liners with number of file descriptions
POLL
Samba poll problem
• sys_poll don’t handle timeout < 0
• Solve issue
– 1.superviosr control
• But…..Supervisoralso have
negativetimeout problem
– 2.moodify timeout=1 , if timeout<0
• 2014-2016 negative
• 5- INT_MAX overflow
– 3.smd_parent_loopdefaultis 60s
• default sys_polltimeout range
– /*tv_usec < 10^6 */
– tv_usec and tv_sec is positve

More Related Content

What's hot

DEF CON 27 - HUBER AND ROSKOSCH - im on your phone listening attacking voip c...
DEF CON 27 - HUBER AND ROSKOSCH - im on your phone listening attacking voip c...DEF CON 27 - HUBER AND ROSKOSCH - im on your phone listening attacking voip c...
DEF CON 27 - HUBER AND ROSKOSCH - im on your phone listening attacking voip c...
Felipe Prado
 
ch6-pv2-device-drivers
ch6-pv2-device-driversch6-pv2-device-drivers
ch6-pv2-device-drivers
yushiang fu
 
Network Drivers
Network DriversNetwork Drivers
Network Drivers
Anil Kumar Pugalia
 
Chw00t: How to break out from various chroot solutions
Chw00t: How to break out from various chroot solutionsChw00t: How to break out from various chroot solutions
Chw00t: How to break out from various chroot solutions
Balazs Bucsay
 
Sql Bits Sql Server Crash Dump Analysis
Sql Bits   Sql Server Crash Dump AnalysisSql Bits   Sql Server Crash Dump Analysis
Sql Bits Sql Server Crash Dump Analysis
Pablo Alvarez Doval
 
DEF CON 27 - MICHAEL LEIBOWITZ and TOPHER TIMZEN - edr is coming hide yo sht
DEF CON 27 - MICHAEL LEIBOWITZ and TOPHER TIMZEN - edr is coming hide yo shtDEF CON 27 - MICHAEL LEIBOWITZ and TOPHER TIMZEN - edr is coming hide yo sht
DEF CON 27 - MICHAEL LEIBOWITZ and TOPHER TIMZEN - edr is coming hide yo sht
Felipe Prado
 
Anıl kurmuş pacsec3
Anıl kurmuş pacsec3Anıl kurmuş pacsec3
Anıl kurmuş pacsec3
PacSecJP
 
[HackInTheBox] Breaking virtualization by any means
[HackInTheBox] Breaking virtualization by any means[HackInTheBox] Breaking virtualization by any means
[HackInTheBox] Breaking virtualization by any means
Moabi.com
 
Low-level Accesses
Low-level AccessesLow-level Accesses
Low-level Accesses
Anil Kumar Pugalia
 
Python & FUSE
Python & FUSEPython & FUSE
Python & FUSE
Joseph Scott
 
Surge2014 talk - illumos State of the Community & POSIX Update
Surge2014 talk - illumos State of the Community & POSIX UpdateSurge2014 talk - illumos State of the Community & POSIX Update
Surge2014 talk - illumos State of the Community & POSIX Update
Garrett D'Amore
 
Detect Kernel-Mode Rootkits via Real Time Logging & Controlling Memory Access
Detect Kernel-Mode Rootkits via Real Time Logging & Controlling Memory AccessDetect Kernel-Mode Rootkits via Real Time Logging & Controlling Memory Access
Detect Kernel-Mode Rootkits via Real Time Logging & Controlling Memory Access
Igor Korkin
 

What's hot (12)

DEF CON 27 - HUBER AND ROSKOSCH - im on your phone listening attacking voip c...
DEF CON 27 - HUBER AND ROSKOSCH - im on your phone listening attacking voip c...DEF CON 27 - HUBER AND ROSKOSCH - im on your phone listening attacking voip c...
DEF CON 27 - HUBER AND ROSKOSCH - im on your phone listening attacking voip c...
 
ch6-pv2-device-drivers
ch6-pv2-device-driversch6-pv2-device-drivers
ch6-pv2-device-drivers
 
Network Drivers
Network DriversNetwork Drivers
Network Drivers
 
Chw00t: How to break out from various chroot solutions
Chw00t: How to break out from various chroot solutionsChw00t: How to break out from various chroot solutions
Chw00t: How to break out from various chroot solutions
 
Sql Bits Sql Server Crash Dump Analysis
Sql Bits   Sql Server Crash Dump AnalysisSql Bits   Sql Server Crash Dump Analysis
Sql Bits Sql Server Crash Dump Analysis
 
DEF CON 27 - MICHAEL LEIBOWITZ and TOPHER TIMZEN - edr is coming hide yo sht
DEF CON 27 - MICHAEL LEIBOWITZ and TOPHER TIMZEN - edr is coming hide yo shtDEF CON 27 - MICHAEL LEIBOWITZ and TOPHER TIMZEN - edr is coming hide yo sht
DEF CON 27 - MICHAEL LEIBOWITZ and TOPHER TIMZEN - edr is coming hide yo sht
 
Anıl kurmuş pacsec3
Anıl kurmuş pacsec3Anıl kurmuş pacsec3
Anıl kurmuş pacsec3
 
[HackInTheBox] Breaking virtualization by any means
[HackInTheBox] Breaking virtualization by any means[HackInTheBox] Breaking virtualization by any means
[HackInTheBox] Breaking virtualization by any means
 
Low-level Accesses
Low-level AccessesLow-level Accesses
Low-level Accesses
 
Python & FUSE
Python & FUSEPython & FUSE
Python & FUSE
 
Surge2014 talk - illumos State of the Community & POSIX Update
Surge2014 talk - illumos State of the Community & POSIX UpdateSurge2014 talk - illumos State of the Community & POSIX Update
Surge2014 talk - illumos State of the Community & POSIX Update
 
Detect Kernel-Mode Rootkits via Real Time Logging & Controlling Memory Access
Detect Kernel-Mode Rootkits via Real Time Logging & Controlling Memory AccessDetect Kernel-Mode Rootkits via Real Time Logging & Controlling Memory Access
Detect Kernel-Mode Rootkits via Real Time Logging & Controlling Memory Access
 

Similar to Linux IO Multiplexing for Samba bug

Sysprog 16
Sysprog 16Sysprog 16
Sysprog 16
Ahmed Mekkawy
 
Linux IO
Linux IOLinux IO
Linux IO
Liran Ben Haim
 
Sysprog17
Sysprog17Sysprog17
Sysprog17
Ahmed Mekkawy
 
Epoll - from the kernel side
Epoll -  from the kernel sideEpoll -  from the kernel side
Epoll - from the kernel side
llj098
 
Select and poll functions
Select and poll functionsSelect and poll functions
Select and poll functions
Manju Srinivasan
 
Char Drivers And Debugging Techniques
Char Drivers And Debugging TechniquesChar Drivers And Debugging Techniques
Char Drivers And Debugging Techniques
YourHelper1
 
FreeBSD and Drivers
FreeBSD and DriversFreeBSD and Drivers
FreeBSD and Drivers
Kernel TLV
 
[Python] Quick book for dell switch_os10
[Python] Quick book for dell switch_os10[Python] Quick book for dell switch_os10
[Python] Quick book for dell switch_os10
Jo Hoon
 
Android memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdfAndroid memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdf
VishalKumarJha10
 
Lec45chap4f04
Lec45chap4f04Lec45chap4f04
Lec45chap4f04
screaminc
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting ReviewHKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting Review
Linaro
 
Hardware hacking
Hardware hackingHardware hacking
Hardware hacking
Tavish Naruka
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
RuggedBoardGroup
 
Sysdig Open Source Intro
Sysdig Open Source IntroSysdig Open Source Intro
Sysdig Open Source Intro
Michael Ducy
 
06 - ELF format, knowing your friend
06 - ELF format, knowing your friend06 - ELF format, knowing your friend
06 - ELF format, knowing your friend
Alexandre Moneger
 
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hoodEmbedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
EmbeddedFest
 
When virtualization encounters afl blackhat eu2016--1.4
When virtualization encounters afl blackhat eu2016--1.4When virtualization encounters afl blackhat eu2016--1.4
When virtualization encounters afl blackhat eu2016--1.4
月锋 李
 
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
EneaSoftware
 
MOD server & FreeBSD (FreeBSD Day Taiwan)
MOD server & FreeBSD (FreeBSD Day Taiwan)MOD server & FreeBSD (FreeBSD Day Taiwan)
MOD server & FreeBSD (FreeBSD Day Taiwan)
Kevin Lo
 
DPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingDPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet Processing
Michelle Holley
 

Similar to Linux IO Multiplexing for Samba bug (20)

Sysprog 16
Sysprog 16Sysprog 16
Sysprog 16
 
Linux IO
Linux IOLinux IO
Linux IO
 
Sysprog17
Sysprog17Sysprog17
Sysprog17
 
Epoll - from the kernel side
Epoll -  from the kernel sideEpoll -  from the kernel side
Epoll - from the kernel side
 
Select and poll functions
Select and poll functionsSelect and poll functions
Select and poll functions
 
Char Drivers And Debugging Techniques
Char Drivers And Debugging TechniquesChar Drivers And Debugging Techniques
Char Drivers And Debugging Techniques
 
FreeBSD and Drivers
FreeBSD and DriversFreeBSD and Drivers
FreeBSD and Drivers
 
[Python] Quick book for dell switch_os10
[Python] Quick book for dell switch_os10[Python] Quick book for dell switch_os10
[Python] Quick book for dell switch_os10
 
Android memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdfAndroid memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdf
 
Lec45chap4f04
Lec45chap4f04Lec45chap4f04
Lec45chap4f04
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting ReviewHKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting Review
 
Hardware hacking
Hardware hackingHardware hacking
Hardware hacking
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
 
Sysdig Open Source Intro
Sysdig Open Source IntroSysdig Open Source Intro
Sysdig Open Source Intro
 
06 - ELF format, knowing your friend
06 - ELF format, knowing your friend06 - ELF format, knowing your friend
06 - ELF format, knowing your friend
 
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hoodEmbedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
 
When virtualization encounters afl blackhat eu2016--1.4
When virtualization encounters afl blackhat eu2016--1.4When virtualization encounters afl blackhat eu2016--1.4
When virtualization encounters afl blackhat eu2016--1.4
 
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
 
MOD server & FreeBSD (FreeBSD Day Taiwan)
MOD server & FreeBSD (FreeBSD Day Taiwan)MOD server & FreeBSD (FreeBSD Day Taiwan)
MOD server & FreeBSD (FreeBSD Day Taiwan)
 
DPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingDPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet Processing
 

Recently uploaded

Zener Diode and its V-I Characteristics and Applications
Zener Diode and its V-I Characteristics and ApplicationsZener Diode and its V-I Characteristics and Applications
Zener Diode and its V-I Characteristics and Applications
Shiny Christobel
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
PriyankaKilaniya
 
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENTNATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
Addu25809
 
2. protection of river banks and bed erosion protection works.ppt
2. protection of river banks and bed erosion protection works.ppt2. protection of river banks and bed erosion protection works.ppt
2. protection of river banks and bed erosion protection works.ppt
abdatawakjira
 
Mechatronics material . Mechanical engineering
Mechatronics material . Mechanical engineeringMechatronics material . Mechanical engineering
Mechatronics material . Mechanical engineering
sachin chaurasia
 
Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
mahaffeycheryld
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
Blood finder application project report (1).pdf
Blood finder application project report (1).pdfBlood finder application project report (1).pdf
Blood finder application project report (1).pdf
Kamal Acharya
 
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Transcat
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
OOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming languageOOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming language
PreethaV16
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
PreethaV16
 
P5 Working Drawings.pdf floor plan, civil
P5 Working Drawings.pdf floor plan, civilP5 Working Drawings.pdf floor plan, civil
P5 Working Drawings.pdf floor plan, civil
AnasAhmadNoor
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
ElakkiaU
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
Pressure Relief valve used in flow line to release the over pressure at our d...
Pressure Relief valve used in flow line to release the over pressure at our d...Pressure Relief valve used in flow line to release the over pressure at our d...
Pressure Relief valve used in flow line to release the over pressure at our d...
cannyengineerings
 
Supermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdfSupermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdf
Kamal Acharya
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
AI-Based Home Security System : Home security
AI-Based Home Security System : Home securityAI-Based Home Security System : Home security
AI-Based Home Security System : Home security
AIRCC Publishing Corporation
 

Recently uploaded (20)

Zener Diode and its V-I Characteristics and Applications
Zener Diode and its V-I Characteristics and ApplicationsZener Diode and its V-I Characteristics and Applications
Zener Diode and its V-I Characteristics and Applications
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
 
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENTNATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
NATURAL DEEP EUTECTIC SOLVENTS AS ANTI-FREEZING AGENT
 
2. protection of river banks and bed erosion protection works.ppt
2. protection of river banks and bed erosion protection works.ppt2. protection of river banks and bed erosion protection works.ppt
2. protection of river banks and bed erosion protection works.ppt
 
Mechatronics material . Mechanical engineering
Mechatronics material . Mechanical engineeringMechatronics material . Mechanical engineering
Mechatronics material . Mechanical engineering
 
Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
Blood finder application project report (1).pdf
Blood finder application project report (1).pdfBlood finder application project report (1).pdf
Blood finder application project report (1).pdf
 
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
OOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming languageOOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming language
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
 
P5 Working Drawings.pdf floor plan, civil
P5 Working Drawings.pdf floor plan, civilP5 Working Drawings.pdf floor plan, civil
P5 Working Drawings.pdf floor plan, civil
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
Pressure Relief valve used in flow line to release the over pressure at our d...
Pressure Relief valve used in flow line to release the over pressure at our d...Pressure Relief valve used in flow line to release the over pressure at our d...
Pressure Relief valve used in flow line to release the over pressure at our d...
 
Supermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdfSupermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdf
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
AI-Based Home Security System : Home security
AI-Based Home Security System : Home securityAI-Based Home Security System : Home security
AI-Based Home Security System : Home security
 

Linux IO Multiplexing for Samba bug

  • 2. Problem • Samba smbd will crash when timeout is negative • Analysis FreeBSD poll and select…
  • 3. Descriptive Name File Number Description StandardIn 0 Inputfromthe keyboard StandardOut 1 Outputtothe console StandardError 2 Error outputtothe console Process File descriptor
  • 4. Five IO models blocking I/O: blocked all the way non-blocking I/O: if no data in buffer, immediate returns EWOULDBLOCK I/O multiplexing (select and poll): blocked separately in wait and copy signal driven I/O (SIGIO): non-blocked in wait but blocked in copy (signaled when I/O can be initiated) asynchronous I/O (aio_): non-blocked all the way (signaled when I/O is complete) Kernel’s buffer IO Device User process Wait for data copy date (system call)
  • 6. Select 1.Is the device readyfor reading? (writing 2.Kernel check the device buffer’s limits ->READY for reading(writing 3.Select return IO Device Kernel’s buffer User process INTPUT OUTPUT 4.Copy data by system call(READ WRITE no yes 4. next Select()
  • 7. Select • #include <sys/select.h> • int select( int nfds, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout) • struct timeval { /* Epoch 1970 1/1 00:00 */ long tv_sec; /* seconds*/ long tv_usec; /* microseconds*/ } Timeout  NULL blocking infinite time  timout->tv-sec=10 wait ten seconds  timout->tv-sec=10 =0 search once and return nfds Search range 0 0 0 0 0 0 0 0 fd0 fd1023 0 0 0 0 0 0 0 0 0 fd0 fd1023 0 0 0 0 0 0 0 0 0 fd0 fd1023 0 readset writeset execptset FILE descriptors
  • 8. 0 0 0 0 0 0 0 0 fd0 fd1023 FD_ZERO(fd_set *fdset) initial 0 0 0 0 0 1 0 0 0 fd0 fd1023 FD_SET(int fd,fd_set *fdset) loop 0 0 0 0 0 0 0 0 0 fd0 fd1023 FD_CLR(int fd,fd_set *fdset) Don’t use the device 0 0 0 0 0 0 0 0 0 fd0 fd1023 FD_ISSET(int fd,fd_set *fdset) Check ready? ->READ or WRITE 0 Check ready?
  • 9. POLL poll -- synchronousI/Omultiplexing int poll (structpollfd fds[], nfds_t nfds, int timeout); 1.沒有最大文件描述符數量的限制。 2.Overhead is liners with number of file descriptions
  • 10. POLL
  • 11. Samba poll problem • sys_poll don’t handle timeout < 0 • Solve issue – 1.superviosr control • But…..Supervisoralso have negativetimeout problem – 2.moodify timeout=1 , if timeout<0 • 2014-2016 negative • 5- INT_MAX overflow – 3.smd_parent_loopdefaultis 60s • default sys_polltimeout range – /*tv_usec < 10^6 */ – tv_usec and tv_sec is positve