Skip to contentSkip to conversation

6.4.5-rc1 review

PATCH In review Greg Kroah-Hartman 17 participants 320 messages Jul 21, 2023 – Jul 27, 2023 Page 3 of 3

Subsystems (9)
lore
Share & tools
lore
author maintainer
#295 lore raw

PATCH 288/292 scsi: qla2xxx: Remove unused nvme_ls_waitq wait queue

In reply to Greg Kroah-Hartman

From: Manish Rangankar <[email protected]>

commit 20fce500b232b970e40312a9c97e7f3b6d7a709c upstream.

System crash when qla2x00_start_sp(sp) returns error code EGAIN and wake_up gets called for uninitialized wait queue sp->nvme_ls_waitq.

    qla2xxx [0000:37:00.1]-2121:5: Returning existing qpair of ffff8ae2c0513400 for idx=0
    qla2xxx [0000:37:00.1]-700e:5: qla2x00_start_sp failed = 11
    BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
    PGD 0 P4D 0
    Oops: 0000 [#1] SMP NOPTI
    Hardware name: HPE ProLiant DL360 Gen10/ProLiant DL360 Gen10, BIOS U32 09/03/2021
    Workqueue: nvme-wq nvme_fc_connect_ctrl_work [nvme_fc]
    RIP: 0010:__wake_up_common+0x4c/0x190
    RSP: 0018:ffff95f3e0cb7cd0 EFLAGS: 00010086
    RAX: 0000000000000000 RBX: ffff8b08d3b26328 RCX: 0000000000000000
    RDX: 0000000000000001 RSI: 0000000000000003 RDI: ffff8b08d3b26320
    RBP: 0000000000000001 R08: 0000000000000000 R09: ffffffffffffffe8
    R10: 0000000000000000 R11: ffff95f3e0cb7a60 R12: ffff95f3e0cb7d20
    R13: 0000000000000003 R14: 0000000000000000 R15: 0000000000000000
    FS:  0000000000000000(0000) GS:ffff8b2fdf6c0000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000000000000000 CR3: 0000002f1e410002 CR4: 00000000007706e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    PKRU: 55555554
    Call Trace:
     __wake_up_common_lock+0x7c/0xc0
     qla_nvme_ls_req+0x355/0x4c0 [qla2xxx]
     ? __nvme_fc_send_ls_req+0x260/0x380 [nvme_fc]
     ? nvme_fc_send_ls_req.constprop.42+0x1a/0x45 [nvme_fc]
     ? nvme_fc_connect_ctrl_work.cold.63+0x1e3/0xa7d [nvme_fc]

Remove unused nvme_ls_waitq wait queue. nvme_ls_waitq logic was removed previously in the commits tagged Fixed: below.

Fixes 219d27d7147e ("scsi: qla2xxx: Fix race conditions in the code for aborting SCSI commands")
Fixes 5621b0dd7453 ("scsi: qla2xxx: Simpify unregistration of FC-NVMe local/remote ports")
---
 drivers/scsi/qla2xxx/qla_def.h  |    1 -
 drivers/scsi/qla2xxx/qla_nvme.c |    3 ---
 2 files changed, 4 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +0 -1
@@ -703,7 +703,6 @@ typedef struct srb {
 	struct iocb_resource iores;
 	struct kref cmd_kref;	/* need to migrate ref_count over to this */
 	void *priv;
-	wait_queue_head_t nvme_ls_waitq;
 	struct fc_port *fcport;
 	struct scsi_qla_host *vha;
 	unsigned int start_timer:1;
drivers/scsi/qla2xxx/qla_nvme.c +0 -3
@@ -360,7 +360,6 @@ static int qla_nvme_ls_req(struct nvme_f
 	if (rval != QLA_SUCCESS) {
 		ql_log(ql_log_warn, vha, 0x700e,
 		    "qla2x00_start_sp failed = %d\n", rval);
-		wake_up(&sp->nvme_ls_waitq);
 		sp->priv = NULL;
 		priv->sp = NULL;
 		qla2x00_rel_sp(sp);
@@ -652,7 +651,6 @@ static int qla_nvme_post_cmd(struct nvme
 	if (!sp)
 		return -EBUSY;
 
-	init_waitqueue_head(&sp->nvme_ls_waitq);
 	kref_init(&sp->cmd_kref);
 	spin_lock_init(&priv->cmd_lock);
 	sp->priv = priv;
@@ -671,7 +669,6 @@ static int qla_nvme_post_cmd(struct nvme
 	if (rval != QLA_SUCCESS) {
 		ql_log(ql_log_warn, vha, 0x212d,
 		    "qla2x00_start_nvme_mq failed = %d\n", rval);
-		wake_up(&sp->nvme_ls_waitq);
 		sp->priv = NULL;
 		priv->sp = NULL;
 		qla2xxx_rel_qpair_sp(sp->qpair, sp);
author maintainer
#296 lore raw

PATCH 289/292 scsi: qla2xxx: Fix end of loop test

In reply to Greg Kroah-Hartman

From: Dan Carpenter <[email protected]>

commit 339020091e246e708c1381acf74c5f8e3fe4d2b5 upstream.

This loop will exit successfully when "found" is false or in the failure case it times out with "wait_iter" set to -1. The test for timeouts is impossible as is.

Fixes b843adde8d49 ("scsi: qla2xxx: Fix mem access after free")
---
 drivers/scsi/qla2xxx/qla_os.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_os.c +1 -1
@@ -1409,7 +1409,7 @@ __qla2x00_eh_wait_for_pending_commands(s
 			break;
 	}
 
-	if (!wait_iter && found)
+	if (wait_iter == -1)
 		status = QLA_FUNCTION_FAILED;
 
 	return status;
author maintainer
#287 lore raw

PATCH 280/292 scsi: qla2xxx: Fix mem access after free

In reply to Greg Kroah-Hartman

From: Quinn Tran <[email protected]>

commit b843adde8d490934d042fbe9e3e46697cb3a64d2 upstream.

System crash, where driver is accessing scsi layer's memory (scsi_cmnd->device->host) to search for a well known internal pointer (vha). The scsi_cmnd was released back to upper layer which could be freed, but the driver is still accessing it.

7 [ffffa8e8d2c3f8d0] page_fault at ffffffff86c010fe
[exception RIP: __qla2x00_eh_wait_for_pending_commands+240]

  RIP: ffffffffc0642350  RSP: ffffa8e8d2c3f988  RFLAGS: 00010286
  RAX: 0000000000000165  RBX: 0000000000000002  RCX: 00000000000036d8
  RDX: 0000000000000000  RSI: ffff9c5c56535188  RDI: 0000000000000286
  RBP: ffff9c5bf7aa4a58   R8: ffff9c589aecdb70   R9: 00000000000003d1
  R10: 0000000000000001  R11: 0000000000380000 R12: ffff9c5c5392bc78
  R13: ffff9c57044ff5c0 R14: ffff9c56b5a3aa00  R15: 00000000000006db
  ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018

8 [ffffa8e8d2c3f9c8] qla2x00_eh_wait_for_pending_commands at ffffffffc0646dd5 [qla2xxx] 9 [ffffa8e8d2c3fa00] __qla2x00_async_tm_cmd at ffffffffc0658094 [qla2xxx]

Remove access of freed memory. Currently the driver was checking to see if scsi_done was called by seeing if the sp->type has changed. Instead, check to see if the command has left the oustanding_cmds[] array as sign of scsi_done was called.

---
 drivers/scsi/qla2xxx/qla_isr.c |   38 +++++++++--
 drivers/scsi/qla2xxx/qla_os.c  |  130 ++++++++++++++++++++---------------------
 2 files changed, 95 insertions(+), 73 deletions(-)
drivers/scsi/qla2xxx/qla_isr.c +31 -7
@@ -1862,9 +1862,9 @@ qla2x00_process_completed_request(struct
 	}
 }
 
-srb_t *
-qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
-    struct req_que *req, void *iocb)
+static srb_t *
+qla_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
+		       struct req_que *req, void *iocb, u16 *ret_index)
 {
 	struct qla_hw_data *ha = vha->hw;
 	sts_entry_t *pkt = iocb;
@@ -1899,12 +1899,25 @@ qla2x00_get_sp_from_handle(scsi_qla_host
 		return NULL;
 	}
 
-	req->outstanding_cmds[index] = NULL;
-
+	*ret_index = index;
 	qla_put_fw_resources(sp->qpair, &sp->iores);
 	return sp;
 }
 
+srb_t *
+qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
+			   struct req_que *req, void *iocb)
+{
+	uint16_t index;
+	srb_t *sp;
+
+	sp = qla_get_sp_from_handle(vha, func, req, iocb, &index);
+	if (sp)
+		req->outstanding_cmds[index] = NULL;
+
+	return sp;
+}
+
 static void
 qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
     struct mbx_entry *mbx)
@@ -3237,13 +3250,13 @@ qla2x00_status_entry(scsi_qla_host_t *vh
 		return;
 	}
 
-	req->outstanding_cmds[handle] = NULL;
 	cp = GET_CMD_SP(sp);
 	if (cp == NULL) {
 		ql_dbg(ql_dbg_io, vha, 0x3018,
 		    "Command already returned (0x%x/%p).\n",
 		    sts->handle, sp);
 
+		req->outstanding_cmds[handle] = NULL;
 		return;
 	}
 
@@ -3514,6 +3527,9 @@ out:
 
 	if (rsp->status_srb == NULL)
 		sp->done(sp, res);
+
+	/* for io's, clearing of outstanding_cmds[handle] means scsi_done was called */
+	req->outstanding_cmds[handle] = NULL;
 }
 
 /**
@@ -3590,6 +3606,7 @@ qla2x00_error_entry(scsi_qla_host_t *vha
 	uint16_t que = MSW(pkt->handle);
 	struct req_que *req = NULL;
 	int res = DID_ERROR << 16;
+	u16 index;
 
 	ql_dbg(ql_dbg_async, vha, 0x502a,
 	    "iocb type %xh with error status %xh, handle %xh, rspq id %d\n",
@@ -3608,7 +3625,6 @@ qla2x00_error_entry(scsi_qla_host_t *vha
 
 	switch (pkt->entry_type) {
 	case NOTIFY_ACK_TYPE:
-	case STATUS_TYPE:
 	case STATUS_CONT_TYPE:
 	case LOGINOUT_PORT_IOCB_TYPE:
 	case CT_IOCB_TYPE:
@@ -3628,6 +3644,14 @@ qla2x00_error_entry(scsi_qla_host_t *vha
 	case CTIO_TYPE7:
 	case CTIO_CRC2:
 		return 1;
+	case STATUS_TYPE:
+		sp = qla_get_sp_from_handle(vha, func, req, pkt, &index);
+		if (sp) {
+			sp->done(sp, res);
+			req->outstanding_cmds[index] = NULL;
+			return 0;
+		}
+		break;
 	}
 fatal:
 	ql_log(ql_log_warn, vha, 0x5030,
drivers/scsi/qla2xxx/qla_os.c +64 -66

154 lines not on this page · raw message

#68 lore raw

Re: [PATCH 6.4 067/292] x86/fineibt: Poison ENDBR at +0

In reply to Greg Kroah-Hartman
Quoted 28 lines · Greg Kroah-Hartman

From: Peter Zijlstra <[email protected]>

[ Upstream commit 04505bbbbb15da950ea0239e328a76a3ad2376e0 ]

Alyssa noticed that when building the kernel with CFI_CLANG+IBT and booting on IBT enabled hardware to obtain FineIBT, the indirect functions look like:

__cfi_foo:

	endbr64
	subl	$hash, %r10d
	jz	1f
	ud2
	nop
  1:
  foo:
	endbr64

This is because the compiler generates code for kCFI+IBT. In that case the caller does the hash check and will jump to +0, so there must be an ENDBR there. The compiler doesn't know about FineIBT at all; also it is possible to actually use kCFI+IBT when booting with 'cfi=kcfi' on IBT enabled hardware.

Having this second ENDBR however makes it possible to elide the CFI check. Therefore, we should poison this second ENDBR when switching to FineIBT mode.

Quoted 7 lines

If you take this patch you should also take the patches from Brian that moves ret_from_fork() into C, otherwise you end up with a non-bootable kernel.

Tested-by on the v1 series
#300 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.4.5 release. There are 292 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Sun, 23 Jul 2023 16:04:29 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.4.5-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.4.y
and the diffstat can be found below.

thanks,

greg k-h

Tested rc1 against the Fedora build system (aarch64, ppc64le, s390x, x86_64), and boot tested x86_64. No regressions noted.

Tested-by on the v1 series
#301 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.4.5 release. There are 292 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Sun, 23 Jul 2023 16:04:29 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.4.5-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.4.y
and the diffstat can be found below.

thanks,

greg k-h

Built and booted successfully on RISC-V RV64 (HiFive Unmatched).

Tested-by on the v1 series
#302 lore raw
In reply to Greg Kroah-Hartman
Quoted 5 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.4.5 release. There are 292 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Successfully compiled and installed bindeb-pkgs on my computer (Acer Aspire E15, Intel Core i3 Haswell). No noticeable regressions.

Signature · 1 line
An old man doll... just what I always wanted! - Clara
Tested-by Linux Kernel Functional Testing on the v1 series
#303 lore raw
In reply to Greg Kroah-Hartman
Quoted 10 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.4.5 release. There are 292 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Sun, 23 Jul 2023 16:04:29 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
        https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.4.5-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.4.y
and the diffstat can be found below.

thanks,

greg k-h

Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.

NOTE:
The following kernel warning was noticed while booting qemu-arm64 with these configs enabled on stable rc 6.4.5-rc1.

CONFIG_ARM64_64K_PAGES=y
CONFIG_KFENCE=y

This crash is not easily reproducible.

boot logs:
--------

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x000f0510]
[    0.000000] Linux version 6.4.5-rc1 (tuxmake@tuxmake)
(aarch64-linux-gnu-gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils
for Debian) 2.40) #1 SMP PREEMPT @1689957802
[    0.000000] random: crng init done
[    0.000000] Machine model: linux,dummy-virt
...
<6>[    0.006821] kfence: initialized - using 33554432 bytes for 255
objects at 0x(____ptrval____)-0x(____ptrval____)
...
<4>[    7.726994] ------------[ cut here ]------------
<4>[    7.727704] WARNING: CPU: 1 PID: 1 at mm/kfence/core.c:1097
__kfence_free+0x84/0xc8
<4>[    7.730078] Modules linked in: ip_tables x_tables
<4>[    7.732637] CPU: 1 PID: 1 Comm: systemd Not tainted 6.4.5-rc1 #1
<4>[    7.733334] Hardware name: linux,dummy-virt (DT)
<4>[    7.734765] pstate: 83400009 (Nzcv daif +PAN -UAO +TCO +DIT
-SSBS BTYPE=--)
<4>[    7.735323] pc : __kfence_free+0x84/0xc8
<4>[    7.736036] lr : __slab_free+0x490/0x508
<4>[    7.736374] sp : ffff8000080afb40
<4>[    7.736657] x29: ffff8000080afb40 x28: ffffffc0003fa100 x27:
0000000000000000
<4>[    7.738294] x26: 0000000000000000 x25: 0000000000000001 x24:
0000000000000000
<4>[    7.739138] x23: ffffcd8ea7099000 x22: ffffcd8ea45cac38 x21:
ffff0000fe840000
<4>[    7.739961] x20: ffffcd8ea45cac38 x19: ffff0000c0012300 x18:
0000000000000000
<4>[    7.740778] x17: 0000000000000000 x16: 0000000000000000 x15:
0000000000000000
<4>[    7.741636] x14: 0000000000000000 x13: 0000000000000000 x12:
0000000000000000
<4>[    7.742474] x11: 0000000000000000 x10: 0000000000000000 x9 :
ffffcd8ea45601e0
<4>[    7.743407] x8 : ffff8000080afc20 x7 : 0000000000000000 x6 :
0000000000009901
<4>[    7.744268] x5 : ffffcd8ea45cac38 x4 : ffffcd8ea7099000 x3 :
ffffcd8ea76e7aa0
<4>[    7.745093] x2 : ffff0000c162e000 x1 : ffffcd8ea76fa5b0 x0 :
ffff0000fe840000
<4>[    7.746478] Call trace:
<4>[    7.746776]  __kfence_free+0x84/0xc8
<4>[    7.747134]  __slab_free+0x490/0x508
<4>[    7.748063]  __kmem_cache_free+0x2b4/0x2d0
<4>[    7.748377]  kfree+0x78/0x140
<4>[    7.748638]  single_release+0x40/0x60
<4>[    7.750664]  __fput+0x78/0x260
<4>[    7.751065]  ____fput+0x18/0x30
<4>[    7.752086]  task_work_run+0x80/0xe0
<4>[    7.753122]  do_notify_resume+0x200/0x1398
<4>[    7.754292]  el0_svc+0xec/0x100
<4>[    7.754573]  el0t_64_sync_handler+0xf4/0x120
<4>[    7.755559]  el0t_64_sync+0x190/0x198
<4>[    7.756643] ---[ end trace 0000000000000000 ]---

Links
- https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.4.y/build/v6.4.4-293-g4f44255da83d/testrun/18526234/suite/log-parser-boot/test/check-kernel-exception/log
- https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.4.y/build/v6.4.4-293-g4f44255da83d/testrun/18526234/suite/log-parser-boot/tests/
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/

## Build
* kernel: 6.4.5-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-6.4.y
* git commit: 4f44255da83d4e0d6c39114e6d90f43705c9159d
* git describe: v6.4.4-293-g4f44255da83d
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.4.y/build/v6.4.4-293-g4f44255da83d

## Test Regressions (compared to v6.4.4-150-g698271d38e0b)

## Metric Regressions (compared to v6.4.4-150-g698271d38e0b)

## Test Fixes (compared to v6.4.4-150-g698271d38e0b)

## Metric Fixes (compared to v6.4.4-150-g698271d38e0b)

## Test result summary
total: 165616, pass: 143054, fail: 2212, skip: 20190, xfail: 160

## Build Summary
* arc: 5 total, 5 passed, 0 failed
* arm: 141 total, 141 passed, 0 failed
* arm64: 50 total, 50 passed, 0 failed
* i386: 37 total, 37 passed, 0 failed
* mips: 26 total, 26 passed, 0 failed
* parisc: 3 total, 3 passed, 0 failed
* powerpc: 34 total, 34 passed, 0 failed
* riscv: 22 total, 22 passed, 0 failed
* s390: 12 total, 12 passed, 0 failed
* sh: 12 total, 12 passed, 0 failed
* sparc: 6 total, 6 passed, 0 failed
* x86_64: 42 total, 42 passed, 0 failed

## Test suites summary
* boot
* kselftest-android
* kselftest-arm64
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-drivers-dma-buf
* kselftest-efivarfs
* kselftest-exec
* kselftest-filesystems
* kselftest-filesystems-binderfs
* kselftest-filesytems-epoll
* kselftest-firmware
* kselftest-fpu
* kselftest-ftrace
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-kvm
* kselftest-lib
* kselftest-livepatch
* kselftest-membarrier
* kselftest-memfd
* kselftest-memory-hotplug
* kselftest-mincore
* kselftest-mount
* kselftest-mqueue
* kselftest-net
* kselftest-net-forwarding
* kselftest-net-mptcp
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-seccomp
* kselftest-sigaltstack
* kselftest-size
* kselftest-splice
* kselftest-static_keys
* kselftest-sync
* kselftest-sysctl
* kselftest-tc-testing
* kselftest-timens
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user
* kselftest-user_events
* kselftest-vDSO
* kselftest-vm
* kselftest-watchdog
* kselftest-x86
* kselftest-zram
* kunit
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* network-basic-tests
* perf
* rcutorture
* v4l2-compliance

--
Linaro LKFT
https://lkft.linaro.org

author maintainer
#69 lore raw

Re: [PATCH 6.4 067/292] x86/fineibt: Poison ENDBR at +0

In reply to Peter Zijlstra
Quoted 37 lines · Peter Zijlstra
Quoted 28 lines · Greg Kroah-Hartman

From: Peter Zijlstra <[email protected]>

[ Upstream commit 04505bbbbb15da950ea0239e328a76a3ad2376e0 ]

Alyssa noticed that when building the kernel with CFI_CLANG+IBT and booting on IBT enabled hardware to obtain FineIBT, the indirect functions look like:

__cfi_foo:

	endbr64
	subl	$hash, %r10d
	jz	1f
	ud2
	nop
  1:
  foo:
	endbr64

This is because the compiler generates code for kCFI+IBT. In that case the caller does the hash check and will jump to +0, so there must be an ENDBR there. The compiler doesn't know about FineIBT at all; also it is possible to actually use kCFI+IBT when booting with 'cfi=kcfi' on IBT enabled hardware.

Having this second ENDBR however makes it possible to elide the CFI check. Therefore, we should poison this second ENDBR when switching to FineIBT mode.

Quoted 7 lines
Quoted 3 lines

If you take this patch you should also take the patches from Brian that moves ret_from_fork() into C, otherwise you end up with a non-bootable kernel.

Thanks for letting me know, I've just dropped this patch instead for now.

greg k-h

Tested-by on the v1 series
#316 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.4.5 release. There are 292 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Sun, 23 Jul 2023 16:04:29 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.4.5-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.4.y
and the diffstat can be found below.

thanks,

greg k-h

On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:

Signature · 1 line
Florian
#304 lore raw
In reply to Naresh Kamboju

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Anybody?

Linus

Quoted 30 lines · Naresh Kamboju

Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.

NOTE:
The following kernel warning was noticed while booting qemu-arm64 with these configs enabled on stable rc 6.4.5-rc1.

CONFIG_ARM64_64K_PAGES=y
CONFIG_KFENCE=y

This crash is not easily reproducible.

boot logs:
--------

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x000f0510]
[    0.000000] Linux version 6.4.5-rc1 (tuxmake@tuxmake)
(aarch64-linux-gnu-gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils
for Debian) 2.40) #1 SMP PREEMPT @1689957802
[    0.000000] random: crng init done
[    0.000000] Machine model: linux,dummy-virt
...
[    0.006821] kfence: initialized - using 33554432 bytes for 255
objects at 0x(____ptrval____)-0x(____ptrval____)
...
[    7.726994] ------------[ cut here ]------------
[    7.727704] WARNING: CPU: 1 PID: 1 at mm/kfence/core.c:1097

__kfence_free+0x84/0xc8

...

Quoted 13 lines
[    7.746478] Call trace:
[    7.746776]  __kfence_free+0x84/0xc8
[    7.747134]  __slab_free+0x490/0x508
[    7.748063]  __kmem_cache_free+0x2b4/0x2d0
[    7.748377]  kfree+0x78/0x140
[    7.748638]  single_release+0x40/0x60
[    7.750664]  __fput+0x78/0x260
[    7.751065]  ____fput+0x18/0x30
[    7.752086]  task_work_run+0x80/0xe0
[    7.753122]  do_notify_resume+0x200/0x1398
[    7.754292]  el0_svc+0xec/0x100
[    7.754573]  el0t_64_sync_handler+0xf4/0x120
[    7.755559]  el0t_64_sync+0x190/0x198
Tested-by on the v1 series
#317 lore raw
In reply to Greg Kroah-Hartman
Quoted 8 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.4.5 release. There are 292 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Sun, 23 Jul 2023 16:04:29 +0000. Anything received after that time might be too late.

Build results:

	total: 157 pass: 157 fail: 0
Qemu test results:
	total: 523 pass: 523 fail: 0

Guenter

maintainer Tested-by on the v1 series
#318 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.4.5 release. There are 292 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Sun, 23 Jul 2023 16:04:29 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.4.5-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.4.y
and the diffstat can be found below.

thanks,

greg k-h

All tests passing for Tegra ...

Test results for stable-v6.4:

    11 builds:	11 pass, 0 fail
    28 boots:	28 pass, 0 fail
    130 tests:	130 pass, 0 fail

Linux version: 6.4.5-rc1-g698271d38e0b
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,

                tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000,
                tegra20-ventana, tegra210-p2371-2180,
                tegra210-p3450-0000, tegra30-cardhu-a04

Jon

#175 lore raw

Re: [PATCH 6.4 172/292] PCI: acpiphp: Reassign resources on bridge if necessary

In reply to Greg Kroah-Hartman
Quoted 13 lines · Greg Kroah-Hartman

From: Igor Mammedov <[email protected]>

commit 40613da52b13fb21c5566f10b287e0ca8c12c4e9 upstream.

When using ACPI PCI hotplug, hotplugging a device with large BARs may fail if bridge windows programmed by firmware are not large enough.

Reproducer:

  $ qemu-kvm -monitor stdio -M q35  -m 4G \
      -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=on \
      -device id=rp1,pcie-root-port,bus=pcie.0,chassis=4 \
      disk_image
Quoted 4 lines

wait till linux guest boots, then hotplug device:
(qemu) device_add qxl,bus=rp1

[...]

Greg, just so you know, that patch (which is also queued for 6.1 and 5.15) is known to cause a regression in 6.5-rc. To quote
https://lore.kernel.org/all/[email protected]/

```
Laptop shows a kernel crash trace after a first suspend to ram, on a
second attempt to suspend it becomes frozen solid. This is 100%
repeatable with a 6.5-rc2 kernel, not happening with a 6.4 kernel - see
the attached dmesg output.

I have bisected the kernel uilds and it points to :
[40613da52b13fb21c5566f10b287e0ca8c12c4e9] PCI: acpiphp: Reassign
resources on bridge if necessary

Reversing this patch seems to fix the kernel crash problem on my laptop.
```

Ciao, Thorsten

P.S.: I only noticed this by chance and yet again wonder how to handle these situations better. I guess exporting the list of regressions regzbot tracks in some simple format might be a start; then the stable scripts could simply look up commit ids there when a patch is queued and warn if they find it (which won't help in caes the regression is reported after the patch is queued :-/ ).

#176 lore raw

Re: [PATCH 6.4 172/292] PCI: acpiphp: Reassign resources on bridge if necessary

Quoted 14 lines · Thorsten Leemhuis
Quoted 8 lines · Greg Kroah-Hartman

From: Igor Mammedov <[email protected]>

commit 40613da52b13fb21c5566f10b287e0ca8c12c4e9 upstream.

When using ACPI PCI hotplug, hotplugging a device with large BARs may fail if bridge windows programmed by firmware are not large enough.

[...]

Greg, just so you know, that patch (which is also queued for 6.1 and 5.15) is known to cause a regression in 6.5-rc. To quote
https://lore.kernel.org/all/[email protected]/

Quoted 12 lines
```
Laptop shows a kernel crash trace after a first suspend to ram, on a
second attempt to suspend it becomes frozen solid. This is 100%
repeatable with a 6.5-rc2 kernel, not happening with a 6.4 kernel - see
the attached dmesg output.

I have bisected the kernel uilds and it points to :
[40613da52b13fb21c5566f10b287e0ca8c12c4e9] PCI: acpiphp: Reassign
resources on bridge if necessary

Reversing this patch seems to fix the kernel crash problem on my laptop.
```

Forgot to mention the reply from Bjorn:

```
I queued up a revert of 40613da52b13 ("PCI: acpiphp: Reassign
resources on bridge if necessary") (on my for-linus branch for v6.5).

It looks like a NULL pointer dereference; hopefully the fix is obvious
and I can drop the revert and replace it with the fix.
```

Ciao, Thorsten

author maintainer
#177 lore raw

Re: [PATCH 6.4 172/292] PCI: acpiphp: Reassign resources on bridge if necessary

In reply to Linux regression tracking (Thorsten Leemhuis)
Quoted 30 lines · Linux regression tracking (Thorsten Leemhuis)
Quoted 14 lines · Thorsten Leemhuis
Quoted 8 lines · Greg Kroah-Hartman

From: Igor Mammedov <[email protected]>

commit 40613da52b13fb21c5566f10b287e0ca8c12c4e9 upstream.

When using ACPI PCI hotplug, hotplugging a device with large BARs may fail if bridge windows programmed by firmware are not large enough.

[...]

Greg, just so you know, that patch (which is also queued for 6.1 and 5.15) is known to cause a regression in 6.5-rc. To quote
https://lore.kernel.org/all/[email protected]/

Quoted 12 lines
```
Laptop shows a kernel crash trace after a first suspend to ram, on a
second attempt to suspend it becomes frozen solid. This is 100%
repeatable with a 6.5-rc2 kernel, not happening with a 6.4 kernel - see
the attached dmesg output.

I have bisected the kernel uilds and it points to :
[40613da52b13fb21c5566f10b287e0ca8c12c4e9] PCI: acpiphp: Reassign
resources on bridge if necessary

Reversing this patch seems to fix the kernel crash problem on my laptop.
```

Forgot to mention the reply from Bjorn:

Quoted 7 lines
```
I queued up a revert of 40613da52b13 ("PCI: acpiphp: Reassign
resources on bridge if necessary") (on my for-linus branch for v6.5).

It looks like a NULL pointer dereference; hopefully the fix is obvious
and I can drop the revert and replace it with the fix.
```

Thanks, I've dropped this from the stable queues now.

greg k-h

#305 lore raw
In reply to Linus Torvalds
Quoted 7 lines · Linus Torvalds

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

Quoted 16 lines

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Anybody?

Linus

Quoted 6 lines

NOTE:
The following kernel warning was noticed while booting qemu-arm64 with these configs enabled on stable rc 6.4.5-rc1.

CONFIG_ARM64_64K_PAGES=y
CONFIG_KFENCE=y

Is there a full config somewhere?

Quoted 1 line
Quoted 1 line

This crash is not easily reproducible.

CONFIG_KFENCE_SAMPLE_INTERVAL=10
CONFIG_KFENCE_NUM_OBJECTS=2048

might improve reproducibility.

Quoted 17 lines
Quoted 16 lines

boot logs:
--------

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x000f0510]
[    0.000000] Linux version 6.4.5-rc1 (tuxmake@tuxmake)
(aarch64-linux-gnu-gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils
for Debian) 2.40) #1 SMP PREEMPT @1689957802
[    0.000000] random: crng init done
[    0.000000] Machine model: linux,dummy-virt
...
[    0.006821] kfence: initialized - using 33554432 bytes for 255
objects at 0x(____ptrval____)-0x(____ptrval____)
...
[    7.726994] ------------[ cut here ]------------
[    7.727704] WARNING: CPU: 1 PID: 1 at mm/kfence/core.c:1097

__kfence_free+0x84/0xc8

...

Quoted 13 lines
Quoted 5 lines
[    7.746478] Call trace:
[    7.746776]  __kfence_free+0x84/0xc8
[    7.747134]  __slab_free+0x490/0x508
[    7.748063]  __kmem_cache_free+0x2b4/0x2d0
[    7.748377]  kfree+0x78/0x140
Quoted 8 lines
[    7.748638]  single_release+0x40/0x60
[    7.750664]  __fput+0x78/0x260
[    7.751065]  ____fput+0x18/0x30
[    7.752086]  task_work_run+0x80/0xe0
[    7.753122]  do_notify_resume+0x200/0x1398
[    7.754292]  el0_svc+0xec/0x100
[    7.754573]  el0t_64_sync_handler+0xf4/0x120
[    7.755559]  el0t_64_sync+0x190/0x198

It would be interesting to see the contents of /sys/kernel/debug/kfence/objects together with the object address. Would it be possible to boot the kernel with no_hash_pointers and add a line printing the object address:

mm/kfence/core.c +4 -1
index dad3c0eb70a01..23f27f6cb18cf 100644
@@ -1094,7 +1094,10 @@ void __kfence_free(void *addr)
        struct kfence_metadata *meta = addr_to_metadata((unsigned long)addr);
 
 #ifdef CONFIG_MEMCG
-       KFENCE_WARN_ON(meta->objcg);
+       if (meta->objcg) {
+               pr_err("ADDR: %px\n", addr);
+               KFENCE_WARN_ON(1);
+       }
 #endif
        /*
         * If the objects of the cache are SLAB_TYPESAFE_BY_RCU, defer freeing

, and then dump /sys/kernel/debug/kfence/objects?

Knowing the kfence pool location (the line starting with "kfence:
initialized") and the object address, we can probably understand from the allocation stack in sysfs, whether the object is supposed to be deleted.

#306 lore raw
Quoted 20 lines · Alexander Potapenko
Quoted 15 lines · Linus Torvalds

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Anybody?

Linus

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

NOTE:
The following kernel warning was noticed while booting qemu-arm64 with these configs enabled on stable rc 6.4.5-rc1.

CONFIG_ARM64_64K_PAGES=y
CONFIG_KFENCE=y

Is there a full config somewhere?

Please find build details
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/config
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/vmlinux.xz
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/System.map
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/Image.gz

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

This crash is not easily reproducible.

CONFIG_KFENCE_SAMPLE_INTERVAL=10
CONFIG_KFENCE_NUM_OBJECTS=2048

might improve reproducibility.

The above test have following Kconfigs enabled.

CONFIG_HAVE_ARCH_KASAN=y
CONFIG_HAVE_ARCH_KASAN_SW_TAGS=y
CONFIG_HAVE_ARCH_KASAN_HW_TAGS=y
CONFIG_HAVE_ARCH_KASAN_VMALLOC=y
CONFIG_CC_HAS_KASAN_GENERIC=y
CONFIG_CC_HAS_KASAN_SW_TAGS=y
CONFIG_CC_HAS_WORKING_NOSANITIZE_ADDRESS=y
# CONFIG_KASAN is not set
CONFIG_HAVE_ARCH_KFENCE=y
CONFIG_KFENCE=y
CONFIG_KFENCE_SAMPLE_INTERVAL=100
CONFIG_KFENCE_NUM_OBJECTS=255
# CONFIG_KFENCE_DEFERRABLE is not set
CONFIG_KFENCE_STRESS_TEST_FAULTS=0

Quoted 54 lines
Quoted 18 lines
Quoted 17 lines

boot logs:
--------

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x000f0510]
[    0.000000] Linux version 6.4.5-rc1 (tuxmake@tuxmake)
(aarch64-linux-gnu-gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils
for Debian) 2.40) #1 SMP PREEMPT @1689957802
[    0.000000] random: crng init done
[    0.000000] Machine model: linux,dummy-virt
...
[    0.006821] kfence: initialized - using 33554432 bytes for 255
objects at 0x(____ptrval____)-0x(____ptrval____)
...
[    7.726994] ------------[ cut here ]------------
[    7.727704] WARNING: CPU: 1 PID: 1 at mm/kfence/core.c:1097

__kfence_free+0x84/0xc8

...

Quoted 13 lines
Quoted 5 lines
[    7.746478] Call trace:
[    7.746776]  __kfence_free+0x84/0xc8
[    7.747134]  __slab_free+0x490/0x508
[    7.748063]  __kmem_cache_free+0x2b4/0x2d0
[    7.748377]  kfree+0x78/0x140
Quoted 8 lines
[    7.748638]  single_release+0x40/0x60
[    7.750664]  __fput+0x78/0x260
[    7.751065]  ____fput+0x18/0x30
[    7.752086]  task_work_run+0x80/0xe0
[    7.753122]  do_notify_resume+0x200/0x1398
[    7.754292]  el0_svc+0xec/0x100
[    7.754573]  el0t_64_sync_handler+0xf4/0x120
[    7.755559]  el0t_64_sync+0x190/0x198

It would be interesting to see the contents of /sys/kernel/debug/kfence/objects together with the object address. Would it be possible to boot the kernel with no_hash_pointers and add a line printing the object address:

mm/kfence/core.c +4 -1
index dad3c0eb70a01..23f27f6cb18cf 100644
@@ -1094,7 +1094,10 @@ void __kfence_free(void *addr)
        struct kfence_metadata *meta = addr_to_metadata((unsigned long)addr);
 
 #ifdef CONFIG_MEMCG
-       KFENCE_WARN_ON(meta->objcg);
+       if (meta->objcg) {
+               pr_err("ADDR: %px\n", addr);
+               KFENCE_WARN_ON(1);
+       }
 #endif
        /*
         * If the objects of the cache are SLAB_TYPESAFE_BY_RCU, defer freeing
Quoted 2 lines

, and then dump /sys/kernel/debug/kfence/objects?

This testing is running on CI loops and however, I will try to reproduce this locally.

Quoted 4 lines

Knowing the kfence pool location (the line starting with "kfence:
initialized") and the object address, we can probably understand from the allocation stack in sysfs, whether the object is supposed to be deleted.

- Naresh

#307 lore raw

Hi Alexander,

Quoted 117 lines · Naresh Kamboju
Quoted 20 lines · Alexander Potapenko
Quoted 15 lines · Linus Torvalds

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Anybody?

Linus

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

NOTE:
The following kernel warning was noticed while booting qemu-arm64 with these configs enabled on stable rc 6.4.5-rc1.

CONFIG_ARM64_64K_PAGES=y
CONFIG_KFENCE=y

Is there a full config somewhere?

Please find build details
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/config
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/vmlinux.xz
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/System.map
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/Image.gz

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

This crash is not easily reproducible.

CONFIG_KFENCE_SAMPLE_INTERVAL=10
CONFIG_KFENCE_NUM_OBJECTS=2048

might improve reproducibility.

The above test have following Kconfigs enabled.

CONFIG_HAVE_ARCH_KASAN=y
CONFIG_HAVE_ARCH_KASAN_SW_TAGS=y
CONFIG_HAVE_ARCH_KASAN_HW_TAGS=y
CONFIG_HAVE_ARCH_KASAN_VMALLOC=y
CONFIG_CC_HAS_KASAN_GENERIC=y
CONFIG_CC_HAS_KASAN_SW_TAGS=y
CONFIG_CC_HAS_WORKING_NOSANITIZE_ADDRESS=y
# CONFIG_KASAN is not set
CONFIG_HAVE_ARCH_KFENCE=y
CONFIG_KFENCE=y
CONFIG_KFENCE_SAMPLE_INTERVAL=100
CONFIG_KFENCE_NUM_OBJECTS=255
# CONFIG_KFENCE_DEFERRABLE is not set
CONFIG_KFENCE_STRESS_TEST_FAULTS=0

Quoted 54 lines
Quoted 18 lines
Quoted 17 lines

boot logs:
--------

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x000f0510]
[    0.000000] Linux version 6.4.5-rc1 (tuxmake@tuxmake)
(aarch64-linux-gnu-gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils
for Debian) 2.40) #1 SMP PREEMPT @1689957802
[    0.000000] random: crng init done
[    0.000000] Machine model: linux,dummy-virt
...
[    0.006821] kfence: initialized - using 33554432 bytes for 255
objects at 0x(____ptrval____)-0x(____ptrval____)
...
[    7.726994] ------------[ cut here ]------------
[    7.727704] WARNING: CPU: 1 PID: 1 at mm/kfence/core.c:1097

__kfence_free+0x84/0xc8

...

Quoted 13 lines
Quoted 5 lines
[    7.746478] Call trace:
[    7.746776]  __kfence_free+0x84/0xc8
[    7.747134]  __slab_free+0x490/0x508
[    7.748063]  __kmem_cache_free+0x2b4/0x2d0
[    7.748377]  kfree+0x78/0x140
Quoted 8 lines
[    7.748638]  single_release+0x40/0x60
[    7.750664]  __fput+0x78/0x260
[    7.751065]  ____fput+0x18/0x30
[    7.752086]  task_work_run+0x80/0xe0
[    7.753122]  do_notify_resume+0x200/0x1398
[    7.754292]  el0_svc+0xec/0x100
[    7.754573]  el0t_64_sync_handler+0xf4/0x120
[    7.755559]  el0t_64_sync+0x190/0x198

It would be interesting to see the contents of /sys/kernel/debug/kfence/objects together with the object address. Would it be possible to boot the kernel with no_hash_pointers and add a line printing the object address:

mm/kfence/core.c +4 -1
index dad3c0eb70a01..23f27f6cb18cf 100644
@@ -1094,7 +1094,10 @@ void __kfence_free(void *addr)
        struct kfence_metadata *meta = addr_to_metadata((unsigned long)addr);
 
 #ifdef CONFIG_MEMCG
-       KFENCE_WARN_ON(meta->objcg);
+       if (meta->objcg) {
+               pr_err("ADDR: %px\n", addr);
+               KFENCE_WARN_ON(1);
+       }
 #endif
        /*
         * If the objects of the cache are SLAB_TYPESAFE_BY_RCU, defer freeing
Quoted 5 lines
Quoted 2 lines

, and then dump /sys/kernel/debug/kfence/objects?

This testing is running on CI loops and however, I will try to reproduce this locally.

I have applied the above debug patch and tested in a loop but the issues did not reproduce yet.

- Naresh

#308 lore raw
In reply to Naresh Kamboju
Quoted 29 lines · Naresh Kamboju
Quoted 27 lines · Alexander Potapenko
Quoted 23 lines · Linus Torvalds

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Anybody?

Linus

Quoted 6 lines

NOTE:
The following kernel warning was noticed while booting qemu-arm64 with these configs enabled on stable rc 6.4.5-rc1.

CONFIG_ARM64_64K_PAGES=y
CONFIG_KFENCE=y

Quoted 8 lines
Quoted 1 line

Is there a full config somewhere?

Please find build details
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/config
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/vmlinux.xz
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/System.map
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/Image.gz

I am afraid it still doesn't help much.
I installed tuxmake into a virtualenv and tried running:

 $ tuxmake --runtime podman --target-arch arm64 --toolchain gcc-12
--kconfig https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/config

, but after downloading some Docker stuff it died with the following error:

Error: copying system image from manifest list: writing blob: adding layer with blob "sha256:faef57eae888cbe4a5613eca6741b5e48d768b83f6088858aee9a5a2834f8151":
processing tar file(potentially insufficient UIDs or GIDs available in user namespace (requested 0:42 for /etc/gshadow): Check /etc/subuid and /etc/subgid if configured locally and run podman-system-migrate:
lchown /etc/gshadow: invalid argument): exit status 1

I also tried building with the config you provided, but the resulting kernel didn't boot with my existing rootfs.

The third attempt was to take a config that's known to work, and enable CONFIG_ARM64_64K_PAGES=y in it, and boot on a rootfs that's known to work, but it didn't boot either, claiming that "/sbin/init exists but couldn't execute it".

Are there any additional requirements to rootfs related to 64k pages? Or maybe there's a system image somewhere at tuxsite.com that I can use?

#309 lore raw
Quoted 41 lines · Alexander Potapenko
Quoted 29 lines · Naresh Kamboju
Quoted 27 lines · Alexander Potapenko
Quoted 23 lines · Linus Torvalds

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Anybody?

Linus

Quoted 6 lines

NOTE:
The following kernel warning was noticed while booting qemu-arm64 with these configs enabled on stable rc 6.4.5-rc1.

CONFIG_ARM64_64K_PAGES=y
CONFIG_KFENCE=y

Quoted 8 lines
Quoted 1 line

Is there a full config somewhere?

Please find build details
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/config
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/vmlinux.xz
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/System.map
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/Image.gz

Quoted 2 lines

I am afraid it still doesn't help much.
I installed tuxmake into a virtualenv and tried running:

Ok, my buildroot indeed lacked the BR2_ARM64_PAGE_SIZE_64K. I am now able to boot a kernel with your config, trying to reproduce the problem locally...

#315 lore raw
In reply to Alexander Potapenko
Quoted 49 lines · Alexander Potapenko
Quoted 29 lines · Naresh Kamboju
Quoted 27 lines · Alexander Potapenko
Quoted 23 lines · Linus Torvalds

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Anybody?

Linus

Quoted 6 lines

NOTE:
The following kernel warning was noticed while booting qemu-arm64 with these configs enabled on stable rc 6.4.5-rc1.

CONFIG_ARM64_64K_PAGES=y
CONFIG_KFENCE=y

Quoted 8 lines
Quoted 1 line

Is there a full config somewhere?

Please find build details
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/config
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/vmlinux.xz
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/System.map
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/Image.gz

I am afraid it still doesn't help much.
I installed tuxmake into a virtualenv and tried running:

 $ tuxmake --runtime podman --target-arch arm64 --toolchain gcc-12
--kconfig https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/config

, but after downloading some Docker stuff it died with the following error:

Quoted 7 lines

Error: copying system image from manifest list: writing blob: adding layer with blob "sha256:faef57eae888cbe4a5613eca6741b5e48d768b83f6088858aee9a5a2834f8151":
processing tar file(potentially insufficient UIDs or GIDs available in user namespace (requested 0:42 for /etc/gshadow): Check /etc/subuid and /etc/subgid if configured locally and run podman-system-migrate:
lchown /etc/gshadow: invalid argument): exit status 1

This might helpful,

# Some images require this range in the user namespace

echo "{username}:4000:165535" > /etc/subuid
echo "{username}:4000:165535" > /etc/subgid

Replace {username} with the username in your machine.

- Naresh

#310 lore raw
In reply to Alexander Potapenko
Quoted 43 lines · Alexander Potapenko
Quoted 41 lines · Alexander Potapenko
Quoted 37 lines · Naresh Kamboju
Quoted 20 lines · Alexander Potapenko
Quoted 15 lines · Linus Torvalds

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Anybody?

Linus

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

NOTE:
The following kernel warning was noticed while booting qemu-arm64 with these configs enabled on stable rc 6.4.5-rc1.

CONFIG_ARM64_64K_PAGES=y
CONFIG_KFENCE=y

Is there a full config somewhere?

Please find build details
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/config
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/vmlinux.xz
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/System.map
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2StEPFnEfoD076PRu8fIxjexhnM/Image.gz

Quoted 5 lines
Quoted 2 lines

I am afraid it still doesn't help much.
I installed tuxmake into a virtualenv and tried running:

Ok, my buildroot indeed lacked the BR2_ARM64_PAGE_SIZE_64K. I am now able to boot a kernel with your config, trying to reproduce the problem locally...

Great to know that, boot successfully with a 64k page size kernel image.

- Naresh

#311 lore raw
Quoted 23 lines · Naresh Kamboju
Quoted 21 lines · Alexander Potapenko
Quoted 19 lines · Alexander Potapenko
Quoted 16 lines · Naresh Kamboju
Quoted 14 lines · Alexander Potapenko
Quoted 11 lines · Linus Torvalds

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Anybody?

Linus

Muchun, any chance you know under what circumstances a KFENCE object has its meta->objcg set to a non-NULL value?
It seems to be a quite rare case, and I've only seen it in live radix_tree_node objects.
Since the check here:
https://elixir.bootlin.com/linux/latest/source/mm/kfence/core.c#L1097
ensures that this value is NULL when the object is freed, where is the code that is supposed to zero it?
Could there be a race somewhere?

#312 lore raw
Quoted 32 lines · Alexander Potapenko
Quoted 23 lines · Naresh Kamboju
Quoted 21 lines · Alexander Potapenko
Quoted 19 lines · Alexander Potapenko
Quoted 16 lines · Naresh Kamboju
Quoted 14 lines · Alexander Potapenko
Quoted 11 lines · Linus Torvalds

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Anybody?

Linus

Quoted 9 lines

Muchun, any chance you know under what circumstances a KFENCE object has its meta->objcg set to a non-NULL value?
It seems to be a quite rare case, and I've only seen it in live radix_tree_node objects.
Since the check here:
https://elixir.bootlin.com/linux/latest/source/mm/kfence/core.c#L1097
ensures that this value is NULL when the object is freed, where is the code that is supposed to zero it?
Could there be a race somewhere?

I am still puzzled about what is going on.

As far as I can see, when KFENCE pool is initialized, for ith object page in the pool its page_slab()->memcg_data is set to a value derived from kfence_metadata[i].objcg
Because KFENCE objects always occupy one page, no two objects are expected to share memcg_data at any time.

When slab_alloc_node() is called, it first invokes slab_pre_alloc_hook(), figures out the obj_cgroup and charges it for the allocated memory. The obj_cgroup is returned to slab_alloc_node() and after KFENCE allocation succeeds is passed to slab_post_alloc_hook(), which then writes obj_cgroup to *(page_slab(object)->memcg_data).

When an object is deallocated, slab_free() calls memcg_slab_free_hook(), which zeroes *(page_slab(object)->memcg_data) and passes the object to kfence_free().
At this point the object's meta->objcg must be NULL, so the warning should not be firing.

--
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Liana Sebastian
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

#313 lore raw
Quoted 63 lines · Alexander Potapenko
Quoted 32 lines · Alexander Potapenko
Quoted 23 lines · Naresh Kamboju
Quoted 21 lines · Alexander Potapenko
Quoted 19 lines · Alexander Potapenko
Quoted 16 lines · Naresh Kamboju
Quoted 14 lines · Alexander Potapenko
Quoted 11 lines · Linus Torvalds

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Anybody?

Linus

Quoted 9 lines

Muchun, any chance you know under what circumstances a KFENCE object has its meta->objcg set to a non-NULL value?
It seems to be a quite rare case, and I've only seen it in live radix_tree_node objects.
Since the check here:
https://elixir.bootlin.com/linux/latest/source/mm/kfence/core.c#L1097
ensures that this value is NULL when the object is freed, where is the code that is supposed to zero it?
Could there be a race somewhere?

I am still puzzled about what is going on.

As far as I can see, when KFENCE pool is initialized, for ith object page in the pool its page_slab()->memcg_data is set to a value derived from kfence_metadata[i].objcg
Because KFENCE objects always occupy one page, no two objects are expected to share memcg_data at any time.

When slab_alloc_node() is called, it first invokes slab_pre_alloc_hook(), figures out the obj_cgroup and charges it for the allocated memory. The obj_cgroup is returned to slab_alloc_node() and after KFENCE allocation succeeds is passed to slab_post_alloc_hook(), which then writes obj_cgroup to *(page_slab(object)->memcg_data).

Quoted 5 lines

When an object is deallocated, slab_free() calls memcg_slab_free_hook(), which zeroes *(page_slab(object)->memcg_data) and passes the object to kfence_free().
At this point the object's meta->objcg must be NULL, so the warning should not be firing.

At least, totally agree. This call stack comes from slab_free() which makes sure memcg_slab_free_hook() is called before kfence_free(), so meta->objcg must be NULL. Otherwise, seems something is corrupted. So I really want to know what's the value of "meta->objcg" when the warning is firing (e.g. whether it is a valid pointer or does the last bit is set with MEMCG_DATA_OBJCGS). Maybe we could improve the warning message, e.g. print the current value of "meta->objcg".

Thanks.

#314 lore raw
Quoted 73 lines · Muchun Song
Quoted 64 lines · Alexander Potapenko
Quoted 32 lines · Alexander Potapenko
Quoted 23 lines · Naresh Kamboju
Quoted 21 lines · Alexander Potapenko
Quoted 19 lines · Alexander Potapenko
Quoted 16 lines · Naresh Kamboju
Quoted 14 lines · Alexander Potapenko
Quoted 11 lines · Linus Torvalds

[ Removed the stable reviewers, bringing in the kfence people ]

See

https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/

for the original report. The warning was introduced in 8f0b36497303 ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find any other cases of this.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Anybody?

Linus

Quoted 9 lines

Muchun, any chance you know under what circumstances a KFENCE object has its meta->objcg set to a non-NULL value?
It seems to be a quite rare case, and I've only seen it in live radix_tree_node objects.
Since the check here:
https://elixir.bootlin.com/linux/latest/source/mm/kfence/core.c#L1097
ensures that this value is NULL when the object is freed, where is the code that is supposed to zero it?
Could there be a race somewhere?

I am still puzzled about what is going on.

As far as I can see, when KFENCE pool is initialized, for ith object page in the pool its page_slab()->memcg_data is set to a value derived from kfence_metadata[i].objcg
Because KFENCE objects always occupy one page, no two objects are expected to share memcg_data at any time.

When slab_alloc_node() is called, it first invokes slab_pre_alloc_hook(), figures out the obj_cgroup and charges it for the allocated memory. The obj_cgroup is returned to slab_alloc_node() and after KFENCE allocation succeeds is passed to slab_post_alloc_hook(), which then writes obj_cgroup to *(page_slab(object)->memcg_data).

Quoted 5 lines

When an object is deallocated, slab_free() calls memcg_slab_free_hook(), which zeroes *(page_slab(object)->memcg_data) and passes the object to kfence_free().
At this point the object's meta->objcg must be NULL, so the warning should not be firing.

Quoted 6 lines

At least, totally agree. This call stack comes from slab_free() which makes sure memcg_slab_free_hook() is called before kfence_free(), so meta->objcg must be NULL. Otherwise, seems something is corrupted. So I really want to know what's the value of "meta->objcg" when the warning is firing (e.g. whether it is a valid pointer or does the last bit is set with MEMCG_DATA_OBJCGS). Maybe we could improve the warning message,

Sorry for the confusing, meta->objcg should be a objcg pointer, it cannot be set with MEMCG_DATA_OBJCGS.

Quoted 3 lines

e.g. print the current value of "meta->objcg".

Thanks.