From: Gui-Dong Han <2045gemini(a)gmail.com>
mainline inclusion
from mainline-v6.8-rc3
commit 30926783a46841c2d1bbf3f74067ba85d304fd0d
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB1MRY
CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?…
--------------------------------
In uart_tiocmget():
result = uport->mctrl;
uart_port_lock_irq(uport);
result |= uport->ops->get_mctrl(uport);
uart_port_unlock_irq(uport);
...
return result;
In uart_update_mctrl():
uart_port_lock_irqsave(port, &flags);
...
port->mctrl = (old & ~clear) | set;
...
port->ops->set_mctrl(port, port->mctrl);
...
uart_port_unlock_irqrestore(port, flags);
An atomicity violation is identified due to the concurrent execution of
uart_tiocmget() and uart_update_mctrl(). After assigning
result = uport->mctrl, the mctrl value may change in uart_update_mctrl(),
leading to a mismatch between the value returned by
uport->ops->get_mctrl(uport) and the mctrl value previously read.
This can result in uart_tiocmget() returning an incorrect value.
This possible bug is found by an experimental static analysis tool
developed by our team, BassCheck[1]. This tool analyzes the locking APIs
to extract function pairs that can be concurrently executed, and then
analyzes the instructions in the paired functions to identify possible
concurrency bugs including data races and atomicity violations. The above
possible bug is reported when our tool analyzes the source code of
Linux 5.17.
To address this issue, it is suggested to move the line
result = uport->mctrl inside the uart_port_lock block to ensure atomicity
and prevent the mctrl value from being altered during the execution of
uart_tiocmget(). With this patch applied, our tool no longer reports the
bug, with the kernel configuration allyesconfig for x86_64. Due to the
absence of the requisite hardware, we are unable to conduct runtime
testing of the patch. Therefore, our verification is solely based on code
logic analysis.
[1] https://sites.google.com/view/basscheck/
Fixes: c5f4644e6c8b ("[PATCH] Serial: Adjust serial locking")
Cc: stable(a)vger.kernel.org
Signed-off-by: Gui-Dong Han <2045gemini(a)gmail.com>
Link: https://lore.kernel.org/r/20240112113624.17048-1-2045gemini@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Conflicts:
drivers/tty/serial/serial_core.c
[Commit 559c7ff4e324("serial: core: Use port lock wrappers") not merged,
no functional change.]
Signed-off-by: Yi Yang <yiyang13(a)huawei.com>
---
drivers/tty/serial/serial_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 537bcd7c4941..d9d7506a9f6e 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1078,8 +1078,8 @@ static int uart_tiocmget(struct tty_struct *tty)
goto out;
if (!tty_io_error(tty)) {
- result = uport->mctrl;
spin_lock_irq(&uport->lock);
+ result = uport->mctrl;
result |= uport->ops->get_mctrl(uport);
spin_unlock_irq(&uport->lock);
}
--
2.25.1
Hi Kees,
FYI, the error/warning still remains.
tree: https://gitee.com/openeuler/kernel.git OLK-5.10
head: 400fd9ccb52e01bf78acae2bbc1710923a15f033
commit: 130620d5878d2348208258965876547a69353f9f [2417/2417] x86/entry: Enable random_kstack_offset support
config: x86_64-buildonly-randconfig-003-20241112 (https://download.01.org/0day-ci/archive/20241112/202411121519.FfuB626X-lkp@…)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241112/202411121519.FfuB626X-lkp@…)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp(a)intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411121519.FfuB626X-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> vmlinux.o: warning: objtool: do_syscall_64()+0x8b: call to memset() leaves .noinstr.text section
vmlinux.o: warning: objtool: sync_regs()+0x1c: call to memcpy() leaves .noinstr.text section
vmlinux.o: warning: objtool: fixup_bad_iret()+0x32: call to memset() leaves .noinstr.text section
vmlinux.o: warning: objtool: mce_read_aux()+0x42: call to {dynamic}() leaves .noinstr.text section
vmlinux.o: warning: objtool: do_machine_check()+0x13f: call to mce_no_way_out() leaves .noinstr.text section
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
From: Philip Chen <philipchen(a)chromium.org>
stable inclusion
from stable-v5.10.227
commit 4ce662fe4be6fbc2595d9ef4888b2b6e778c99ed
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IB2YUI
CVE: CVE-2024-50184
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
-------------------------------------------------
[ Upstream commit e25fbcd97cf52c3c9824d44b5c56c19673c3dd50 ]
If a pmem device is in a bad status, the driver side could wait for
host ack forever in virtio_pmem_flush(), causing the system to hang.
So add a status check in the beginning of virtio_pmem_flush() to return
early if the device is not activated.
Signed-off-by: Philip Chen <philipchen(a)chromium.org>
Message-Id: <20240826215313.2673566-1-philipchen(a)chromium.org>
Signed-off-by: Michael S. Tsirkin <mst(a)redhat.com>
Acked-by: Pankaj Gupta <pankaj.gupta.linux(a)gmail.com
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
Signed-off-by: Jinjie Ruan <ruanjinjie(a)huawei.com>
---
drivers/nvdimm/nd_virtio.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
index 10351d5b49fa..41e97c6567cf 100644
--- a/drivers/nvdimm/nd_virtio.c
+++ b/drivers/nvdimm/nd_virtio.c
@@ -44,6 +44,15 @@ static int virtio_pmem_flush(struct nd_region *nd_region)
unsigned long flags;
int err, err1;
+ /*
+ * Don't bother to submit the request to the device if the device is
+ * not activated.
+ */
+ if (vdev->config->get_status(vdev) & VIRTIO_CONFIG_S_NEEDS_RESET) {
+ dev_info(&vdev->dev, "virtio pmem device needs a reset\n");
+ return -EIO;
+ }
+
might_sleep();
req_data = kmalloc(sizeof(*req_data), GFP_KERNEL);
if (!req_data)
--
2.34.1