-
-
Notifications
You must be signed in to change notification settings - Fork 501
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
gopass must remove syscall(2) usage on OpenBSD #2683
Comments
One other additional note, this patched and working gopass still does reference syscall(2), but I could not find where, and have not seen any other linking crashes. It might be benign, or I may not have tested thoroughly enough.
|
Thank you. I think we might try switching to https://github.com/ergochat/readline if the author doesn't merge your PR soon. |
I found one other issue performing system calls on OpenBSD, in the otp screenshot action. It's likely the only remaining reason why syscall(2) remains seen in the nm symbol output.
The reason this dies with "abort trap" is due to a pledge violation ("inet" is required, but the pledge promise is missing in this codepath). If pledge were to be commented out:
There are no shmat(2) wrappers in x/sys/unix to replace the shm package. This would need to be another addition to the x/sys module if this feature is to work at all (along with adding an inet pledge...). I suspect nobody actually wants to add an inet pledge to a password manager, so it's probably best to completely disable this feature on OpenBSD, and use conditional compilation to avoid the lazy syscall(2) linking. |
In most cases where you'd want to use this (fetching from a local X display) it would actually be a "unix" pledge, "inet" would only be needed if DISPLAY points to a remote machine. But then it requires shmget which is not permitted by any pledge. I'm not really convinced pledge is adding much here anyway, firstly what's committed is incorrect ("fattr" is also needed because chmod is called), but since "exec" is also used, if you can subvert the process sufficiently you can just run some other command anyway (which is unrestricted), it might make more sense to just remove the pledge call. |
I not very familiar with OpenBSD. IIRC pledge was contributed by an OpenBSD user. We can remove it if we have a good reason to do so. Also disabling the screenshot feature via build tags / conditional builds sounds good. |
A decision needs to be made whether to keep pledge, and disable the screenshot feature, or leave it enabled but disable pledge entirely. As @sthen noted, we don't need "inet" to open the socket for the local display, but we do need to call shmget(), which is not allowed by any pledged program (pledge starts with nothing and enables subsets of POSIX, it doesn't simply remove parts, and nothing pledge can do can give you back shmget()). (And also, for this screenshot feature to work in a pledge-disabled gopass, it will need to make the proper libc calls instead of syscall(2). That will need more additions to x/sys.) |
If that's the case, then disabling the screenshot feature on OpenBSD with a build tag sounds like the more logical thing to do anyway. I wish I knew if our users even use the feature. I sure do, but maybe I'm the only one, especially since it requires CGO on Darwin 😅 |
@AnomalRoil Could you maybe take care of disabling the screenshot feature on OpenBSD? You did contribute this feature in the first place. I will take care of switching out readline and the x/sys change should eventually land upstream - nothing we can do here to speed that up. |
Unfortunately switching out the readline lib is not entirely trivial, so I'd wait a bit if they still merge that PR. If not I'd first consider a replacement rule. |
The former seemed unmaintained and was lacking patches required for OpenBSD. See gopasspwGH-2683 Signed-off-by: Dominik Schulz <[email protected]>
@jrick Do you know if NetBSD and FreeBSD are also concerned by the same issue? |
they are not, this is something happening first (and only?) in openbsd |
* Replace chzyer/readline with ergochat/readline The former seemed unmaintained and was lacking patches required for OpenBSD. See GH-2683 Signed-off-by: Dominik Schulz <[email protected]> * Add an error message when using clear on windows. Signed-off-by: Dominik Schulz <[email protected]> * use readline 0.0.6's ClearScreen method --------- Signed-off-by: Dominik Schulz <[email protected]> Co-authored-by: Shivaram Lingamneni <[email protected]>
A new version of x/sys was tagged a few days back (v0.14.0) that fixes the pledge calls. With just that module updated over current master branch, gopass is working properly again on OpenBSD. edit: oh and "fattr" also needs to be added to the pledge list still. https://man.openbsd.org/pledge#fattr |
Here I can get it to hit the pledge violation after setting incorrect permissions in my store.
Adding fattr fixes this (but hits some other issue regarding git after the fact.
|
See gopasspw#2683 Signed-off-by: Dominik Schulz <[email protected]>
See #2683 Signed-off-by: Dominik Schulz <[email protected]>
I think we fixed all relevant issues here, correct? Otherwise feel free to re-open. |
Summary
gopass built for OpenBSD from the master branch will fail to link to syscall(2) at runtime once OpenBSD removes syscall(2) from libc.
There are two usages of syscall(2) that I could find: one is due to pledge (will be fixed by https://golang.org/cl/468095), and the other is in readline, which I've opened a PR for. Unfortunately, it doesn't seem that the owner is maintaining that readline library anymore, and a switch to that other fork might be needed, unless you wish to use a module replacement that points to my PR's branch.
Steps To Reproduce
Expected behavior
gopass executes without hitting a lazy linking error.
Environment
Additional context
A working gopass can be built with patches to x/sys and readline.
The text was updated successfully, but these errors were encountered: