[Deepin-Kernel-SIG] [linux 6.18-y] [Upstream] Update kernel base to 6.18.26#1662
Conversation
commit 24daca4fc07f3ff8cd0e3f629cd982187f48436a upstream.
privcmd_vm_ops defines .close (privcmd_close), but neither .may_split
nor .open. When userspace does a partial munmap() on a privcmd mapping,
the kernel splits the VMA via __split_vma(). Since may_split is NULL,
the split is allowed. vm_area_dup() copies vm_private_data (a pages
array allocated in alloc_empty_pages()) into the new VMA without any
fixup, because there is no .open callback.
Both VMAs now point to the same pages array. When the unmapped portion
is closed, privcmd_close() calls:
- xen_unmap_domain_gfn_range()
- xen_free_unpopulated_pages()
- kvfree(pages)
The surviving VMA still holds the dangling pointer. When it is later
destroyed, the same sequence runs again, which leads to a double free.
Fix this issue by adding a .may_split callback denying the VMA split.
This is XSA-487 / CVE-2026-31787
Fixes: d71f513 ("xen: privcmd: support autotranslated physmap guests.")
Reported-by: Atharva Vartak <atharva.a.vartak@gmail.com>
Suggested-by: Atharva Vartak <atharva.a.vartak@gmail.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 446ee446d9ae66f36e95c3c90bbcc4e56b94cde0)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
commit 27fdbab4221b375de54bf91919798d88520c6e28 upstream. The build id returned by HYPERVISOR_xen_version(XENVER_build_id) is neither NUL terminated nor a string. The first causes a buffer overflow as sprintf in buildid_show will read and copy till it finds a NUL. 00000000 f4 91 51 f4 dd 38 9e 9d 65 47 52 eb 10 71 db 50 |..Q..8..eGR..q.P| 00000010 b9 a8 01 42 6f 2e 32 |...Bo.2| 00000017 So use a memcpy instead of sprintf to have the correct value: 00000000 f4 91 51 f4 dd 00 9e 9d 65 47 52 eb 10 71 db 50 |..Q.....eGR..q.P| 00000010 b9 a8 01 42 |...B| 00000014 (the above have a hack to embed a zero inside and check it's returned correctly). This is XSA-485 / CVE-2026-31786 Fixes: 84b7625 ("xen: add sysfs node for hypervisor build id") Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com> Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit d5f59216650c51e5e3fcb7517c825bc8047f60ef) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 1fe06068166d4fc16722201f267b1fe19efad639) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates the kernel base from 6.18.25 to 6.18.26 and incorporates upstream Xen fixes for build ID handling and privcmd VMA splitting semantics. Sequence diagram for Xen hypervisor build ID sysfs read behaviorsequenceDiagram
actor UserSpace
participant Sysfs as sysfs_hypervisor_buildid
participant Kernel as buildid_show
participant Hypervisor as XenHypervisor
UserSpace->>Sysfs: read /sys/hypervisor/buildid
Sysfs->>Kernel: buildid_show(attr, buffer)
alt permission_denied
Kernel-->>Sysfs: "<denied>" (string)
Sysfs-->>UserSpace: error or "<denied>"
else permission_granted
Kernel->>Hypervisor: HYPERVISOR_xen_version(XENVER_build_id, NULL)
Hypervisor-->>Kernel: required_length
alt length_gt_PAGE_SIZE
Kernel-->>Sysfs: -ENOSPC
Sysfs-->>UserSpace: error ENOSPC
else length_le_PAGE_SIZE
Kernel->>Kernel: kmalloc(sizeof(buildid) + required_length)
Kernel->>Hypervisor: HYPERVISOR_xen_version(XENVER_build_id, buildid)
Hypervisor-->>Kernel: buildid_bytes
alt ret_gt_0
Kernel->>Kernel: memcpy(buffer, buildid_buf, ret)
Kernel-->>Sysfs: ret (binary bytes)
Sysfs-->>UserSpace: binary build_id data
else ret_le_0
Kernel-->>Sysfs: ret (error)
Sysfs-->>UserSpace: error
end
end
end
Sequence diagram for Xen privcmd VMA split preventionsequenceDiagram
participant Process as UserProcess
participant MM as KernelMemoryManager
participant VMA as privcmd_vma
participant Ops as privcmd_vm_ops
Process->>MM: mmap privcmd device
MM->>VMA: create VMA with vm_ops = privcmd_vm_ops
note over MM,VMA: Later, an operation implies splitting the VMA
MM->>Ops: may_split(privcmd_vma, split_addr)
Ops-->>MM: -EINVAL
alt may_split_rejects_split
MM->>MM: do not split VMA
note over MM,VMA: Avoids double free in privcmd_close
else may_split_allows_split
MM->>VMA: split into two VMAs
MM->>Ops: close on old VMA
note over MM,VMA: (Old behavior risked double privcmd_close)
end
Class diagram for Xen privcmd vm_operations_struct changesclassDiagram
class vm_area_struct {
unsigned long vm_start
unsigned long vm_end
struct vm_operations_struct *vm_ops
void *vm_private_data
}
class vm_operations_struct {
+int (*open)(struct vm_area_struct *area)
+void (*close)(struct vm_area_struct *area)
+int (*may_split)(struct vm_area_struct *area, unsigned long addr)
+vm_fault_t (*fault)(struct vm_fault *vmf)
}
class privcmd_vm_ops {
+close(area struct vm_area_struct *)
+may_split(area struct vm_area_struct *, addr unsigned long)
+fault(vmf struct vm_fault *)
}
class vm_fault {
struct vm_area_struct *vma
unsigned long address
unsigned int flags
}
vm_area_struct --> vm_operations_struct : has_vm_ops
privcmd_vm_ops --|> vm_operations_struct : implements
vm_fault --> vm_area_struct : references_vma
class privcmd_close {
+void privcmd_close(vma struct vm_area_struct *)
}
class privcmd_may_split {
+int privcmd_may_split(area struct vm_area_struct *, addr unsigned long)
}
class privcmd_fault {
+vm_fault_t privcmd_fault(vmf struct vm_fault *)
}
privcmd_vm_ops o--> privcmd_close : uses_as_close
privcmd_vm_ops o--> privcmd_may_split : uses_as_may_split
privcmd_vm_ops o--> privcmd_fault : uses_as_fault
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
/approve |
There was a problem hiding this comment.
Pull request overview
This pull request updates the Deepin kernel base from Linux 6.18.25 to 6.18.26, pulling in the corresponding upstream stable fixes. The included changes primarily address Xen-related robustness/safety issues and bump the kernel sublevel.
Changes:
- Bump kernel sublevel from 6.18.25 to 6.18.26.
- Xen sysfs: enforce
PAGE_SIZEbounds for build ID exposure and treat the build ID as binary data. - Xen privcmd: prevent VMA splitting via
vm_ops->may_splitto avoid a potential double-free path inprivcmd_close().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
Makefile |
Updates kernel SUBLEVEL to 26 (6.18.26). |
drivers/xen/sys-hypervisor.c |
Bounds-checkes build ID size and copies build ID bytes as binary into the sysfs read buffer. |
drivers/xen/privcmd.c |
Adds .may_split hook to forbid VMA splitting for privcmd mappings, preventing close-time double-free scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Avenger-285714 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1 similar comment
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Avenger-285714 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Update kernel base to 6.18.26.
git log --oneline v6.18.25..v6.18.26 | wc
3 16 151
Summary by Sourcery
Update Xen hypervisor interfaces and bump the kernel version to 6.18.26.
Bug Fixes:
Build: