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.

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>
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.

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.

2 participants