Samsung Knox DualDAR Use-After-Free - CVE-2026-20968, CVE-2026-21102
Overview
This post analyzes two Use-After-Free vulnerabilities patched in 2026 in the Knox DualDAR kernel driver of the Galaxy S24 (Exynos).
Both vulnerabilities are lifetime issues that arise while the kernel shares memory with a user space daemon through mmap.
CVE-2026-20968 is a case where the kernel keeps referencing a vm_area_struct that has already been freed, and CVE-2026-21102 is a case where a freed physical page stays in the daemon's page table.
Since Samsung publishes kernel source for each build, the root cause and the patch were confirmed by comparing the sources of the builds before and after each patch.
Advisory: Samsung Mobile Security Updates - CVE-2026-20968 (SVE-2025-1183, SMR Jan-2026), CVE-2026-21102 (SVE-2026-3092, SMR Sep-2026)
Source: Samsung Open Source - SM-S921B S921BXXU9CYI5 → S921BXXSCCZA1 (Jan) → S921BXXUHEZIF (Sep)
Background
Knox DualDAR
DualDAR is a feature that encrypts Knox Workspace data with two layers. The outer layer is Android FBE, and the inner layer is handled by a separate cryptographic module. Knox DualDAR architecture
The kernel side lives in security/ddar/, and on the S24 it is built into the kernel image through CONFIG_DDAR=y in s5e9945-sec_defconfig.
When the DualDAR policy applied to a file requires user space encryption (dd_policy_user_space_crypto), the kernel delegates encryption and decryption of that file to a user space daemon.
According to the comments in the September patch, this daemon is dualdard, running as the vendor_knoxcore account.
/dev/dd
dualdard and the kernel communicate through the /dev/dd misc device.
const struct file_operations dd_dev_operations = {
.owner = THIS_MODULE,
.unlocked_ioctl = dd_ioctl,
.compat_ioctl = dd_ioctl,
.mmap = dd_mmap,
...
};
static struct miscdevice dd_miscdevice = {
.minor = MISC_DYNAMIC_MINOR,
.name = "dd",
.fops = &dd_dev_operations,
};
The daemon handles the kernel's crypto requests in the following order.
- It registers itself as a crypto worker with the
DD_IOCTL_REGISTER_CRYPTO_TASK ioctl. The kernel allocates a dd_proc object and stores it in filp->private_data.
- It mmaps
/dev/dd four times to create the control, metadata, plaintext and ciphertext areas.
- It waits for requests with the
DD_IOCTL_WAIT_CRYPTO_REQUEST ioctl. When a request arrives, the kernel maps the related pages into the four areas.
- It encrypts or decrypts using the mapped pages and returns the result with the
DD_IOCTL_SUBMIT_CRYPTO_RESULT ioctl.
mmap areas
Each area is identified by its mmap offset.
struct dd_mmap_layout default_mmap_layout = {
...
.control_area = { .start = 0x00000000, ... },
.metadata_area = { .start = 0x01000000, ... },
.plaintext_page_area = { .start = 0x02000000, ... },
.ciphertext_page_area = { .start = 0x03000000, ... }
};
The pages mapped into each area are as follows.
- control: control pages holding the request list. The 16 pages allocated at worker registration are used.
- metadata: per-file crypto metadata. This is
info->mdpage, allocated per file with alloc_page().
- plaintext / ciphertext: data pages of the original bio and the cloned bio.
The dd_mmap function identifies the area by its offset and stores the given VMA in dd_proc as is.
// security/ddar/dd_core.c (S921BXXU9CYI5)
static int dd_mmap(struct file *filp, struct vm_area_struct *vma)
{
struct dd_proc *proc = filp->private_data;
struct dd_context *context = proc->context;
unsigned long addr = vma->vm_pgoff << PAGE_SHIFT;
...
if (addr == context->layout->control_area.start) {
proc->control_vma = vma; //<----- stores the VMA pointer
...
} else if (addr == context->layout->metadata_area.start) {
proc->metadata_vma = vma;
...
} else if (addr == context->layout->plaintext_page_area.start) {
proc->plaintext_vma = vma;
...
} else if (addr == context->layout->ciphertext_page_area.start) {
proc->ciphertext_vma = vma;
...
}
...
}
After that, whenever a request is processed, the kernel maps pages into the stored VMA with the remap_pfn_range function.
static inline void __get_md_page(struct dd_proc *proc, struct page *mdpage,
unsigned long int ino, struct dd_transaction *t)
{
int i = 0;
unsigned long metadata_area_addr = proc->metadata_vma->vm_start;
...
mmap_write_lock(proc->metadata_vma->vm_mm);
remap_pfn_range(proc->metadata_vma, //<----- does not increment the page refcount
metadata_area_addr + (t->num_md_pg << PAGE_SHIFT),
page_to_pfn(mdpage), PAGE_SIZE,
proc->metadata_vma->vm_page_prot);
mmap_write_unlock(proc->metadata_vma->vm_mm);
t->mapped_ino[i] = ino;
t->num_md_pg++;
}
What's interesting is that in this design the kernel has to manage two lifetimes by itself.
One is the lifetime of the VMA created by the daemon, and the other is the lifetime of the kernel pages mapped to the daemon.
The two vulnerabilities each come from one of these.
Root Cause Analysis
CVE-2026-20968: Dangling VMA Pointer
The dd_mmap function stores the VMA pointer, but it does not set vma->vm_ops.
As a result, the kernel has no way of knowing when the daemon munmaps the area. The vm_area_struct is freed, but the pointer stored in dd_proc remains.
Before processing requests, the DD_IOCTL_WAIT_CRYPTO_REQUEST ioctl checks with the dd_mmap_available function whether the areas are registered.
long dd_ioctl_wait_crypto_request(struct dd_proc *proc, struct dd_ioc *ioc)
{
...
if (!dd_mmap_available(proc)) { //<----- 1. only checks for NULL
dd_error("dd_ioctl_wait_crypto_request: user space memory not registered\n");
return -ENOMEM;
}
...
}
static int dd_mmap_available(struct dd_proc *proc)
{
if (!proc->control_vma ||
!proc->metadata_vma ||
!proc->plaintext_vma ||
!proc->ciphertext_vma)
return 0;
return 1;
}
However, this function only checks whether the pointers are NULL, so it cannot filter out a VMA that has already been freed.
Later, while processing a request, the __get_next_ctr_page function uses the freed VMA as is.
static inline struct dd_mmap_control *__get_next_ctr_page(struct dd_transaction *t)
{
struct dd_proc *proc = t->proc;
unsigned long control_area_addr = proc->control_vma->vm_start; //<----- 2. reads the freed VMA
...
mmap_write_lock(proc->control_vma->vm_mm);
remap_pfn_range(proc->control_vma, //<----- 3. maps into the freed VMA
control_area_addr + (t->num_ctr_pg << PAGE_SHIFT),
page_to_pfn(proc->control_page[t->num_ctr_pg]), PAGE_SIZE,
proc->control_vma->vm_page_prot);
mmap_write_unlock(proc->control_vma->vm_mm);
...
}
To summarize, the UAF happens in the following order.
- The daemon mmaps the control area. The VMA pointer is stored in
proc->control_vma.
- The daemon munmaps the control area. The VMA is freed, but
proc->control_vma remains.
- The daemon calls the
DD_IOCTL_WAIT_CRYPTO_REQUEST ioctl. The pointer is not NULL, so the check passes. (marked 1 in the comments)
- When a request arrives, the
__get_next_ctr_page function reads vm_start and vm_mm of the freed VMA and calls remap_pfn_range. (marked 2 and 3 in the comments)
The remap_pfn_range function sets VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP in the given VMA's vm_flags and writes PTEs into that VMA's vm_mm.
If another VMA has been reallocated in place of the freed one, the kernel may map its control page into the address space that VMA belongs to.
CVE-2026-21102: Dangling PTE to Freed Page
The second vulnerability is a lifetime issue not of the VMA, but of the page mapped into it.
The page in question is the metadata page allocated once per file, info->mdpage.
struct dd_info *alloc_dd_info(struct inode *inode,
const struct dd_policy *dd_policy, struct dd_crypt_context *crypt_context)
{
...
if (dd_policy_user_space_crypto(dd_policy->flags)) {
struct metadata_hdr *hdr;
info->mdpage = alloc_page(GFP_KERNEL); //<----- 1. mdpage allocated
hdr = (struct metadata_hdr *) page_address(info->mdpage);
...
}
...
}
void dd_info_try_free(struct dd_info *info)
{
...
if (atomic_dec_and_test(&info->refcount)) {
dd_verbose("freeing dd info ino:%ld\n", info->ino);
if (info->mdpage)
__free_page(info->mdpage); //<----- 3. mdpage freed
...
kmem_cache_free(ext4_dd_info_cachep, info);
}
}
The dd_info_try_free function is called when the file's fscrypt info is released.
// fs/crypto/keysetup.c
static void put_crypt_info(struct fscrypt_info *ci)
{
...
#ifdef CONFIG_DDAR
ext_ci = GET_EXT_CI(ci);
dd_info_try_free(ext_ci->ci_dd_info);
#endif
...
}
The mdpage goes through the following steps.
- It is allocated with
alloc_page in the alloc_dd_info function. At this point the page refcount is 1. (marked 1 in the comments)
- While processing a request, the
__get_md_page function maps it into the daemon's metadata area with remap_pfn_range. As seen in the Background, the refcount does not increase here.
- When the file's fscrypt info is released and the refcount of
dd_info reaches 0, the page is freed with __free_page. (marked 3 in the comments)
The problem is that nobody cleans up the daemon's PTE in step 3.
A PTE created by remap_pfn_range is a special PTE in a VM_PFNMAP area, so it does not hold a reference to the page. Therefore __free_page returns the page to the buddy allocator without any restriction, and the daemon's PTE keeps pointing to the returned physical page.
If that physical page is later reallocated for another purpose, the daemon can read and write it directly from its own address space.
In other words, the UAF is not on a single kernel object but on an entire physical page, which is generally an easier primitive to work with than the VMA UAF above.
Patch Analysis
dd_vm_close (S921BXXSCCZA1)
In the January build, vm_ops->close was added to the dd_mmap function.
+static void dd_vm_close(struct vm_area_struct *vma)
+{
+ struct file *file = vma->vm_file;
+ struct dd_proc *proc = file->private_data;
+
+ if (proc) {
+ proc->control_vma = NULL;
+ proc->metadata_vma = NULL;
+ proc->plaintext_vma = NULL;
+ proc->ciphertext_vma = NULL;
+ }
+}
+
+const struct vm_operations_struct dd_vm_ops = {
+ .close = dd_vm_close,
+};
+
static int dd_mmap(struct file *filp, struct vm_area_struct *vma)
{
struct dd_proc *proc = filp->private_data;
struct dd_context *context = proc->context;
unsigned long addr = vma->vm_pgoff << PAGE_SHIFT;
+ vma->vm_ops = &dd_vm_ops;
+
Now, if the daemon munmaps any one of the four areas, dd_vm_close is called and all four VMA pointers become NULL.
So the next DD_IOCTL_WAIT_CRYPTO_REQUEST call fails in dd_mmap_available, and the freed VMA is never referenced again.
The same build also added dput(de), which releases the dentry reference taken by d_find_alias. This is a separate fix for a reference leak.
vm_insert_page (S921BXXUHEZIF)
In the September build, the __get_md_page function was changed to use vm_insert_page instead of remap_pfn_range.
+ /* SVE-2026-3092 UAF Fix: Use vm_insert_page() instead of remap_pfn_range()
+ *
+ * vm_insert_page() increments the page refcount, preventing page-UAF.
+ * remap_pfn_range(VM_PFNMAP) does NOT increment refcount, leaving dangling
+ * PTEs when the page is freed (even if info->proc becomes NULL).
+ ...
+ */
mmap_write_lock(proc->metadata_vma->vm_mm);
- remap_pfn_range(proc->metadata_vma,
- metadata_area_addr + (t->num_md_pg << PAGE_SHIFT),
- page_to_pfn(mdpage), PAGE_SIZE,
- proc->metadata_vma->vm_page_prot);
+ zap_vma_ptes(proc->metadata_vma, md_addr, PAGE_SIZE);
+ ret = vm_insert_page(proc->metadata_vma, md_addr, mdpage);
mmap_write_unlock(proc->metadata_vma->vm_mm);
+
+ if (ret) {
+ dd_error("vm_insert_page(metadata) failed ret:%d ino:%ld\n", ret, ino);
+ return; /* mapping failed: don't update mapped_ino/num_md_pg */
+ }
if (atomic_dec_and_test(&info->refcount)) {
dd_verbose("freeing dd info ino:%ld\n", info->ino);
if (info->mdpage)
- __free_page(info->mdpage);
+ put_page(info->mdpage);
The SVE-2026-3092 left in the comment corresponds to CVE-2026-21102 in the September security bulletin.
The vm_insert_page function increments the page refcount by 1 with get_page when it creates the PTE.
So when dd_info is released, put_page only drops the kernel's reference, and the page is freed only after the daemon's PTE is gone as well.
The zap_vma_ptes call added right before the mapping removes any previous PTE left at the same address first. This is because vm_insert_page returns -EBUSY for an address that already has a PTE.
// mm/memory.c
static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte,
unsigned long addr, struct page *page, pgprot_t prot)
{
if (!pte_none(*pte))
return -EBUSY;
/* Ok, finally just insert the thing.. */
get_page(page);
...
}
Besides the UAF fix, the same build also added two checks marked "Mitigation 1" and "Mitigation 2" in the comments. Neither of them has an SVE number.
Mitigation 1: DD_IOCTL_REGISTER_CRYPTO_TASK
Before the patch, anyone who could open /dev/dd could become a crypto worker through the DD_IOCTL_REGISTER_CRYPTO_TASK ioctl.
The reason this matters is how the kernel hands requests to workers.
static int __request_user(struct dd_req *req)
{
...
if (!info->proc) {
spin_lock(&context->lock);
info->proc = list_first_entry_or_null(&context->procs, struct dd_proc, proc_node); //<----- 1.
spin_unlock(&context->lock);
}
...
spin_lock(&context->lock);
list_move_tail(&proc->proc_node, &context->procs); //<----- 2.
spin_unlock(&context->lock);
...
}
The kernel assigns the request to the first worker in the list of registered workers (marked 1 in the comments) and then moves that worker to the end of the list (marked 2 in the comments).
So once an attacker registers as a worker, it receives crypto requests for other files in turn, and the pages of those files get mapped into the attacker's address space.
In the September build, the caller is verified with the dd_verify_crypto_task_caller function before registration.
case DD_IOCTL_REGISTER_CRYPTO_TASK:
{
dd_info("DD_IOCTL_REGISTER_CRYPTO_TASK");
+ /* Mitigation 1: Verify only dualdard daemon can register */
+ err = dd_verify_crypto_task_caller();
+ if (err) {
+ dd_error("Crypto task registration denied: caller verification failed\n");
+ return err;
+ }
+
return dd_ioctl_add_crypto_proc(filp);
}
The dd_verify_crypto_task_caller function checks whether the caller belongs to the vendor_knoxcore group (gid 5250) and whether its uid matches 5250, the uid of dualdard. If either check fails, it returns -EACCES.
Mitigation 2: FS_IOC_SET_DD_POLICY
FS_IOC_SET_DD_POLICY is the ioctl that applies a DualDAR policy to a file.
On success, Knox flags are written into the file's fscrypt context and the alloc_dd_info function is called.
Before the patch, it only checked whether the file already had a policy applied, and the f2fs ioctl dispatch does not check for write permission on the file either.
case FS_IOC_SET_DD_POLICY: {
struct dd_policy policy;
+ /* Mitigation 2: Add inode owner check - prevent arbitrary file coercion */
+ /* Only the owner or capable process (CAP_FOWNER) can set DD policy on a file */
+ if (!inode_owner_or_capable(&init_user_ns, inode)) {
+ dd_error("FS_IOC_SET_DD_POLICY denied: caller is not inode owner (ino:%ld)\n",
+ inode->i_ino);
+ return -EACCES;
+ }
+
if (fscrypt_dd_encrypted_inode(inode))
return -EEXIST;
The "arbitrary file coercion" in the comment seems to mean pulling another user's file into the DualDAR path. Now only the file owner or a process with CAP_FOWNER can apply a policy.
Putting the three fixes back into the pre-patch code, the following flow can be reconstructed.
- Open
/dev/dd and register as a crypto worker. (blocked by Mitigation 1)
- Apply a user space encryption policy to the target file. (blocked by Mitigation 2)
- While a request is processed, the file's
mdpage gets mapped into the attacker's address space.
- Trigger the release of the file's
dd_info so that mdpage is freed.
- Access the reallocated physical page through the remaining PTE. (blocked by the SVE-2026-3092 patch)
Conclusion
In short, the January patch fixed the kernel and the daemon continuing to share a freed VMA, and the September patch fixed them continuing to share a freed page.
Both patches use methods the kernel already provides, vm_ops->close and vm_insert_page.
Just like with PROCA, a security feature added by Samsung ended up becoming attack surface again. Project Zero - Mitigations are attack surface, too
CVE-2026-21102 could be confirmed right away because the SVE number is left in the patch comment. CVE-2026-20968, on the other hand, was matched because the only DualDAR changes in the January build were dd_vm_close and dput, and of those dd_vm_close is the one that fixes a UAF.