dma_ip_drivers icon indicating copy to clipboard operation
dma_ip_drivers copied to clipboard

Fix ERESTARTSYS leak to userspace

Open dmitrym1 opened this issue 11 months ago • 3 comments

Fix ERESTARTSYS leak to userspace by replacing it with the appropriate for userspace error codes. Fixes #320

dmitrym1 avatar Jan 17 '25 16:01 dmitrym1

Hi, what is your change used for? what problem do you find with the current design?

jason77-wang avatar Jan 19 '25 07:01 jason77-wang

Hi @jason77-wang, current code returns error 512 in case of timeout of r/w transaction and in case of blocking read of event device. This error code is undefined in userspace and it is a common practice to keep such error codes inside kernel and instead return one of defined error codes. So that programmers don't puzzle over that error code (it's non standard so it is not described anywhere) and instead have a clear understanding of why their syscall returns an error and what to do with it. It may break existing userspace apps if they explicitly expect error code 512, in this case you need either to modify code of such apps, or just don't include that change in your XDMA module build.

dmitrym1 avatar Jan 20 '25 14:01 dmitrym1

Hi @jason77-wang, current code returns error 512 in case of timeout of r/w transaction and in case of blocking read of event device. This error code is undefined in userspace and it is a common practice to keep such error codes inside kernel and instead return one of defined error codes. So that programmers don't puzzle over that error code (it's non standard so it is not described anywhere) and instead have a clear understanding of why their syscall returns an error and what to do with it. It may break existing userspace apps if they explicitly expect error code 512, in this case you need either to modify code of such apps, or just don't include that change in your XDMA module build.

Got it. thanks.

jason77-wang avatar Jan 23 '25 01:01 jason77-wang