Skip to content

openssh: allow cryptodev ioctls#29116

Open
hurrian wants to merge 1 commit intoopenwrt:masterfrom
hurrian:openssh_cryptodev_fix
Open

openssh: allow cryptodev ioctls#29116
hurrian wants to merge 1 commit intoopenwrt:masterfrom
hurrian:openssh_cryptodev_fix

Conversation

@hurrian
Copy link
Copy Markdown

@hurrian hurrian commented Apr 11, 2026

📦 Package Details

Maintainer: @hnyman

Description:
When OpenSSL is built with the devcrypto engine, crypto operations are serviced via ioctl() calls on /dev/crypto.

The pre-auth child inherits the open fd from the monitor but the seccomp filter only whitelists FIONREAD and TIOCGWINSZ, causing any cryptodev ioctl to trigger SIGSYS.

The child is killed immediately after authentication succeeds, during the keystate transfer phase where it first attempts to perform a cipher or MAC operation through the devcrypto engine:

  monitor_child_preauth: preauth child terminated
  by signal 31

As this was tested on the Airoha AN7581 with Cortex-A53 cores, signal 31 on aarch64 is SIGSYS, confirming seccomp violation rather than a code defect.

Add a BPF rule that allows ioctl commands with type byte 'c' (0x63), which is the ioctl type used by all cryptodev operations (CIOCGSESSION, CIOCCRYPT, CIOCFSESSION, etc.).

The rule matches on the type byte rather than the exact ioctl command values because cryptodev is an out-of-tree kernel module and its header is not available at OpenSSH build time.

The rule is gated on ALLOW_CRYPTODEV_IOCTL, defined by the build system only when libopenssl-devcrypto is enabled.


🧪 Run Testing Details

  • OpenWrt Version: SNAPSHOT
  • OpenWrt Target/Subtarget: airoha/an7581
  • OpenWrt Device: Gemtek W1700K

✅ Formalities

  • I have reviewed the CONTRIBUTING.md file for detailed contributing guidelines.

If your PR contains a patch:

  • It can be applied using git am
  • It has been refreshed to avoid offsets, fuzzes, etc., using
    make package/<your-package>/refresh V=s
  • It is structured in a way that it is potentially upstreamable
    (e.g., subject line, commit description, etc.)
    We must try to upstream patches to reduce maintenance burden.

Copy link
Copy Markdown

@glassd00r glassd00r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested on w1700k.

@GeorgeSapkin
Copy link
Copy Markdown
Member

This needs a PKG_RELEASE bump.

When OpenSSL is built with the devcrypto engine, crypto
operations are serviced via ioctl() calls on /dev/crypto.

The pre-auth child inherits the open fd from the monitor
but the seccomp filter only whitelists FIONREAD and
TIOCGWINSZ, causing any cryptodev ioctl to trigger SIGSYS.

The child is killed immediately after authentication
succeeds, during the keystate transfer phase where it
first attempts to perform a cipher or MAC operation
through the devcrypto engine:
```
  monitor_child_preauth: preauth child terminated
  by signal 31
```

As this was tested on the Airoha AN7581 with Cortex-A53
cores, signal 31 on aarch64 is SIGSYS, confirming seccomp
violation rather than a code defect.

Add a BPF rule that allows ioctl commands with type byte
'c' (0x63), which is the ioctl type used by all cryptodev
operations (CIOCGSESSION, CIOCCRYPT, CIOCFSESSION, etc.).

The rule matches on the type byte rather than the exact
ioctl command values because cryptodev is an out-of-tree
kernel module and its header is not available at OpenSSH
build time.

The rule is gated on ALLOW_CRYPTODEV_IOCTL, defined by
the build system only when libopenssl-devcrypto is enabled.

Signed-off-by: Kenneth Kasilag <kenneth@kasilag.me>
@hurrian hurrian force-pushed the openssh_cryptodev_fix branch from eeb9e6b to f3cc940 Compare April 23, 2026 22:52
@hurrian
Copy link
Copy Markdown
Author

hurrian commented Apr 23, 2026

This needs a PKG_RELEASE bump.

Rebased on main and pumped PKG_RELEASE, thanks!

Comment on lines +1 to +4
From 275730c69326cefeb62aedc3a08cec88ff9c295e Mon Sep 17 00:00:00 2001
From: Kenneth Kasilag <kenneth@kasilag.me>
Date: Sat, 11 Apr 2026 03:29:42 +0000
Subject: [PATCH] openssh: allow cryptodev ioctls
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No matter how hard I look, I don't see this patch in the upstream repository, nor do I see it pending in the pull requests - https://github.com/openssh/openssh-portable/pulls

I think it would be better if it were part of the upstream project, rather than us keeping the patch to ourselves and having to rebase and maintain it with every update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants