Skip to content
Memory corruption Write-up Intermediate

Huawei HKSP Introduces Trivially Exploitable Vulnerability in the Linux Kernel

A kernel patch created a world-writable /proc entry whose write handler copied user data into a fixed 32-byte stack buffer without checking the length, causing a stack buffer overflow. Any unprivileged user could trigger it by writing more than 32 bytes to the entry, potentially leading to kernel compromise.

grsecurity.net

Published on grsecurity.net

5/22/2020 Update: This kind of update should not have been necessary, but due to irresponsible journalists and the nature of social media, it is important to make some things perfectly clear:

The author, on grsecurity.net

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The write handler copied an unbounded user-supplied length into a 32-byte stack buffer without validating len.

Impact

Any unprivileged user could trigger a kernel stack buffer overflow, potentially leading to kernel compromise; the text does not demonstrate full exploitation.

What the attacker needed

The HKSP patch is loaded in the kernel; local unprivileged access

How it was found

  1. Open the world-writable /proc/ksguard/state entry for writing.
  2. Write more than 32 bytes to it, overflowing the stack buffer.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The kernel is the core of the operating system. A patch added a file that any user could write to, and the code that handles writes copied the user's data into a small fixed-size box on the stack without checking how much data was sent. Sending too much data overflows the box and can crash or take over the machine.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.