Skip to content

Conversation

@roxanan1996
Copy link
Contributor

@roxanan1996 roxanan1996 commented Dec 18, 2025

DESCRIPTION

2 cherry picks from cve_remediation scripts.

COMMITS

powerpc/pseries/memhp: Fix access beyond end of drmem array

jira VULN-34786
cve CVE-2023-52451
commit-author Nathan Lynch <[email protected]>
commit bd68ffce69f6cf8ddd3a3c32549d1d2275e49fc5
scsi: lpfc: Fix buffer free/clear order in deferred receive path

jira VULN-156034
cve CVE-2025-39841
commit-author John Evans <[email protected]>
commit 9dba9a45c348e8460da97c450cddf70b2056deb3

TESTING

BUILD

  CLEAN   scripts/mod
  CLEAN   scripts/selinux/genheaders
  CLEAN   scripts/selinux/mdp
  CLEAN   scripts
  CLEAN   include/config include/generated arch/x86/include/generated .config .config.old .version Module.symvers certs/signing_key.pem certs/signing_key.x509 certs/x509.genkey
[TIMER]{MRPROPER}: 7s
x86_64 architecture detected, copying config
'configs/kernel-x86_64-rhel.config' -> '.config'
Setting Local Version for build
CONFIG_LOCALVERSION="-rnicolescu_ciqlts9_4-49d11895b0451"
Making olddefconfig
--
  HOSTCC  scripts/kconfig/util.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
Starting Build
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_x32.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
  SYSHDR  arch/x86/include/generated/asm/unistd_32_ia32.h
--
  BTF [M] sound/x86/snd-hdmi-lpe-audio.ko
  LD [M]  sound/xen/snd_xen_front.ko
  BTF [M] sound/virtio/virtio_snd.ko
  BTF [M] sound/xen/snd_xen_front.ko
  BTF [M] virt/lib/irqbypass.ko
[TIMER]{BUILD}: 1693s
Making Modules
  INSTALL /lib/modules/5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+/kernel/arch/x86/crypto/blake2s-x86_64.ko
  INSTALL /lib/modules/5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+/kernel/arch/x86/crypto/blowfish-x86_64.ko
  INSTALL /lib/modules/5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+/kernel/arch/x86/crypto/camellia-aesni-avx-x86_64.ko
  INSTALL /lib/modules/5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+/kernel/arch/x86/crypto/camellia-aesni-avx2.ko
--
  STRIP   /lib/modules/5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+/kernel/sound/xen/snd_xen_front.ko
  SIGN    /lib/modules/5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+/kernel/virt/lib/irqbypass.ko
  SIGN    /lib/modules/5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+/kernel/sound/xen/snd_xen_front.ko
  SIGN    /lib/modules/5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+/kernel/sound/virtio/virtio_snd.ko
  DEPMOD  /lib/modules/5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+
[TIMER]{MODULES}: 8s
Making Install
sh ./arch/x86/boot/install.sh 5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+ \
	arch/x86/boot/bzImage System.map "/boot"
sed: can't read /boot/.vmlinuz-5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+.hmac: No such file or directory
Can't create '/boot/.vmlinuz-0-rescue-1c187ef8d2c64c77b4ea7554ff8f2bd6.hmac' from '/boot/.vmlinuz-5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+.hmac'!
[TIMER]{INSTALL}: 37s
Checking kABI
kABI check passed
Setting Default Kernel to /boot/vmlinuz-5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+ and Index to 0
The default is /boot/loader/entries/1c187ef8d2c64c77b4ea7554ff8f2bd6-5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+.conf with index 0 and kernel /boot/vmlinuz-5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+
The default is /boot/loader/entries/1c187ef8d2c64c77b4ea7554ff8f2bd6-5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+.conf with index 0 and kernel /boot/vmlinuz-5.14.0-rnicolescu_ciqlts9_4-49d11895b0451+
Generating grub configuration file ...
Adding boot menu entry for UEFI Firmware Settings ...
done
Hopefully Grub2.0 took everything ... rebooting after time metrices
[TIMER]{MRPROPER}: 7s
[TIMER]{BUILD}: 1693s
[TIMER]{MODULES}: 8s
[TIMER]{INSTALL}: 37s
[TIMER]{TOTAL} 1751s
Rebooting in 10 seconds

Kselftests

./kselftest-before.log
368
./kselftest-after.log
366
Before: ./kselftest-before.log
After: ./kselftest-after.log
Diff:
-ok 11 selftests: proc: proc-uptime-001
-ok 6 selftests: net: tls
-ok 7 selftests: timers: raw_skew
+ok 7 selftests: timers: raw_skew # SKIP

Check_kernel_commits

> python3 /home/rnicolescu/ciq/kernel-src-tree-tools/check_kernel_commits.py --repo /home/rnicolescu/ciq/kernels/lts-9.4/kernel-src-tree --pr_branch {rnicolescu}_ciqlts9_4 --base_branch origin/ciqlts9_4 --check-cves
All referenced commits exist upstream and have no Fixes: tags.

Run interdiff

> python3 /home/rnicolescu/ciq/kernel-src-tree-tools/run_interdiff.py --repo /home/rnicolescu/ciq/kernels/lts-9.4/kernel-src-tree --pr_branch {rnicolescu}_ciqlts9_4 --base_branch origin/ciqlts9_4
[DIFF] PR commit 49d11895b0451 (scsi: lpfc: Fix buffer free/clear order in deferred receive path) → upstream 9dba9a45c348
Differences found:

  diff -u b/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
  --- b/drivers/scsi/lpfc/lpfc_nvmet.c
  +++ b/drivers/scsi/lpfc/lpfc_nvmet.c
  @@ -1261,6 +1264,8 @@ INTERDIFF: rejected hunk from patch2, cannot diff context
   				ctxp->oxid, ctxp->flag, ctxp->state);
   		return;
   	}
  +	ctxp->rqb_buffer = NULL;
  +	spin_unlock_irqrestore(&ctxp->ctxlock, iflag);
   
   	tgtp = phba->targetport->private;
   	if (tgtp)
  @@ -1263,6 +1266,8 @@ INTERDIFF: rejected hunk from patch1, cannot diff context
   				ctxp->oxid, ctxp->flag, ctxp->state);
   		return;
   	}
  +	ctxp->rqb_buffer = NULL;
  +	spin_unlock_irqrestore(&ctxp->ctxlock, iflag);
   
   	tgtp = phba->targetport->private;
   	if (tgtp)

Colordiff shows no difference.
Screenshot From 2025-12-18 12-58-28
colordiff.log

Run jira_pr_check

> python3 /home/rnicolescu/ciq/kernel-src-tree-tools/jira_pr_check.py --kernel-src-tree /home/rnicolescu/ciq/kernels/lts-9.4/kernel-src-tree --merge-target {rnicolescu}_ciqlts9_4 --pr-branch origin/ciqlts9_4




## JIRA PR Check Results

✅ **No issues found!**


---
**Summary:** Checked 0 commit(s) total.

jira VULN-34786
cve CVE-2023-52451
commit-author Nathan Lynch <[email protected]>
commit bd68ffc

dlpar_memory_remove_by_index() may access beyond the bounds of the
drmem lmb array when the LMB lookup fails to match an entry with the
given DRC index. When the search fails, the cursor is left pointing to
&drmem_info->lmbs[drmem_info->n_lmbs], which is one element past the
last valid entry in the array. The debug message at the end of the
function then dereferences this pointer:

        pr_debug("Failed to hot-remove memory at %llx\n",
                 lmb->base_addr);

This was found by inspection and confirmed with KASAN:

  pseries-hotplug-mem: Attempting to hot-remove LMB, drc index 1234
  ==================================================================
  BUG: KASAN: slab-out-of-bounds in dlpar_memory+0x298/0x1658
  Read of size 8 at addr c000000364e97fd0 by task bash/949

  dump_stack_lvl+0xa4/0xfc (unreliable)
  print_report+0x214/0x63c
  kasan_report+0x140/0x2e0
  __asan_load8+0xa8/0xe0
  dlpar_memory+0x298/0x1658
  handle_dlpar_errorlog+0x130/0x1d0
  dlpar_store+0x18c/0x3e0
  kobj_attr_store+0x68/0xa0
  sysfs_kf_write+0xc4/0x110
  kernfs_fop_write_iter+0x26c/0x390
  vfs_write+0x2d4/0x4e0
  ksys_write+0xac/0x1a0
  system_call_exception+0x268/0x530
  system_call_vectored_common+0x15c/0x2ec

  Allocated by task 1:
   kasan_save_stack+0x48/0x80
   kasan_set_track+0x34/0x50
   kasan_save_alloc_info+0x34/0x50
   __kasan_kmalloc+0xd0/0x120
   __kmalloc+0x8c/0x320
   kmalloc_array.constprop.0+0x48/0x5c
   drmem_init+0x2a0/0x41c
   do_one_initcall+0xe0/0x5c0
   kernel_init_freeable+0x4ec/0x5a0
   kernel_init+0x30/0x1e0
   ret_from_kernel_user_thread+0x14/0x1c

  The buggy address belongs to the object at c000000364e80000
   which belongs to the cache kmalloc-128k of size 131072
  The buggy address is located 0 bytes to the right of
   allocated 98256-byte region [c000000364e80000, c000000364e97fd0)

  ==================================================================
  pseries-hotplug-mem: Failed to hot-remove memory at 0

Log failed lookups with a separate message and dereference the
cursor only when it points to a valid entry.

	Signed-off-by: Nathan Lynch <[email protected]>
Fixes: 51925fb ("powerpc/pseries: Implement memory hotplug remove in the kernel")
	Signed-off-by: Michael Ellerman <[email protected]>
Link: https://msgid.link/[email protected]

(cherry picked from commit bd68ffc)
	Signed-off-by: Roxana Nicolescu <[email protected]>
jira VULN-156034
cve CVE-2025-39841
commit-author John Evans <[email protected]>
commit 9dba9a4

Fix a use-after-free window by correcting the buffer release sequence in
the deferred receive path. The code freed the RQ buffer first and only
then cleared the context pointer under the lock. Concurrent paths (e.g.,
ABTS and the repost path) also inspect and release the same pointer under
the lock, so the old order could lead to double-free/UAF.

Note that the repost path already uses the correct pattern: detach the
pointer under the lock, then free it after dropping the lock. The
deferred path should do the same.

Fixes: 472e146 ("scsi: lpfc: Correct upcalling nvmet_fc transport during io done downcall")
	Cc: [email protected]
	Signed-off-by: John Evans <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
	Reviewed-by: Justin Tee <[email protected]>
	Signed-off-by: Martin K. Petersen <[email protected]>
(cherry picked from commit 9dba9a4)
	Signed-off-by: Roxana Nicolescu <[email protected]>
@github-actions
Copy link

🔍 Interdiff Analysis

  • ⚠️ PR commit 49d11895b04 (scsi: lpfc: Fix buffer free/clear order in deferred receive path) → upstream 9dba9a45c348
    Differences found:
diff -u b/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
--- b/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -1261,6 +1264,8 @@ INTERDIFF: rejected hunk from patch2, cannot diff context
 				ctxp->oxid, ctxp->flag, ctxp->state);
 		return;
 	}
+	ctxp->rqb_buffer = NULL;
+	spin_unlock_irqrestore(&ctxp->ctxlock, iflag);
 
 	tgtp = phba->targetport->private;
 	if (tgtp)
@@ -1263,6 +1266,8 @@ INTERDIFF: rejected hunk from patch1, cannot diff context
 				ctxp->oxid, ctxp->flag, ctxp->state);
 		return;
 	}
+	ctxp->rqb_buffer = NULL;
+	spin_unlock_irqrestore(&ctxp->ctxlock, iflag);
 
 	tgtp = phba->targetport->private;
 	if (tgtp)

This is an automated interdiff check for backported commits.

@roxanan1996 roxanan1996 self-assigned this Dec 18, 2025
@roxanan1996 roxanan1996 requested a review from a team December 18, 2025 12:57
Copy link
Collaborator

@bmastbergen bmastbergen left a comment

Choose a reason for hiding this comment

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

🥌

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants