Hi Geert,
FYI, the error/warning still remains.
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: d2a40c79ddef4b96b8a7a396bd7273121b1b4a5c
commit: 9dae7e237a64858407b7626260bad53aa13c9198 [2662/23859] serial: sh-sci: Fix locking in sci_submit_rx()
config: arm64-randconfig-002-20241026 (https://download.01.org/0day-ci/archive/20241026/202410260911.Qmhlx5mF-lkp@…)
compiler: aarch64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241026/202410260911.Qmhlx5mF-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/202410260911.Qmhlx5mF-lkp@intel.com/
Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
All warnings (new ones prefixed by >>):
In file included from include/linux/irqflags.h:16,
from include/linux/spinlock.h:54,
from include/linux/rwsem.h:16,
from include/linux/notifier.h:15,
from include/linux/clk.h:17,
from drivers/tty/serial/sh-sci.c:24:
In function 'arch_local_irq_restore',
inlined from '__raw_spin_unlock_irqrestore' at include/linux/spinlock_api_smp.h:160:2,
inlined from 'spin_unlock_irqrestore' at include/linux/spinlock.h:384:2,
inlined from 'sci_submit_rx' at drivers/tty/serial/sh-sci.c:1376:3:
>> arch/arm64/include/asm/irqflags.h:88:9: warning: 'flags' may be used uninitialized [-Wmaybe-uninitialized]
88 | asm volatile(
| ^~~
drivers/tty/serial/sh-sci.c: In function 'sci_submit_rx':
drivers/tty/serial/sh-sci.c:1338:23: note: 'flags' was declared here
1338 | unsigned long flags;
| ^~~~~
In file included from drivers/tty/serial/sh-sci.c:53:
In function 'tty_insert_flip_char',
inlined from 'sci_handle_errors' at drivers/tty/serial/sh-sci.c:940:7:
include/linux/tty_flip.h:27:53: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
27 | *flag_buf_ptr(tb, tb->used) = flag;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
In file included from include/linux/serial_core.h:29,
from include/linux/serial_sci.h:6,
from drivers/tty/serial/sh-sci.c:46:
include/linux/tty.h: In function 'sci_handle_errors':
include/linux/tty.h:69:23: note: destination object 'data' of size 0
69 | unsigned long data[0];
| ^~~~
In function 'tty_insert_flip_char',
inlined from 'sci_handle_errors' at drivers/tty/serial/sh-sci.c:940:7:
include/linux/tty_flip.h:28:47: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
28 | *char_buf_ptr(tb, tb->used++) = ch;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
include/linux/tty.h: In function 'sci_handle_errors':
include/linux/tty.h:69:23: note: destination object 'data' of size 0
69 | unsigned long data[0];
| ^~~~
In function 'tty_insert_flip_char',
inlined from 'sci_handle_errors' at drivers/tty/serial/sh-sci.c:950:7:
include/linux/tty_flip.h:27:53: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
27 | *flag_buf_ptr(tb, tb->used) = flag;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
include/linux/tty.h: In function 'sci_handle_errors':
include/linux/tty.h:69:23: note: destination object 'data' of size 0
69 | unsigned long data[0];
| ^~~~
In function 'tty_insert_flip_char',
inlined from 'sci_handle_errors' at drivers/tty/serial/sh-sci.c:950:7:
include/linux/tty_flip.h:28:47: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
28 | *char_buf_ptr(tb, tb->used++) = ch;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
include/linux/tty.h: In function 'sci_handle_errors':
include/linux/tty.h:69:23: note: destination object 'data' of size 0
69 | unsigned long data[0];
| ^~~~
In function 'tty_insert_flip_char',
inlined from 'sci_handle_errors' at drivers/tty/serial/sh-sci.c:960:7:
include/linux/tty_flip.h:27:53: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
27 | *flag_buf_ptr(tb, tb->used) = flag;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
include/linux/tty.h: In function 'sci_handle_errors':
include/linux/tty.h:69:23: note: destination object 'data' of size 0
69 | unsigned long data[0];
| ^~~~
In function 'tty_insert_flip_char',
inlined from 'sci_handle_errors' at drivers/tty/serial/sh-sci.c:960:7:
include/linux/tty_flip.h:28:47: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
28 | *char_buf_ptr(tb, tb->used++) = ch;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
include/linux/tty.h: In function 'sci_handle_errors':
include/linux/tty.h:69:23: note: destination object 'data' of size 0
69 | unsigned long data[0];
| ^~~~
In function 'tty_insert_flip_char',
inlined from 'sci_receive_chars' at drivers/tty/serial/sh-sci.c:906:5:
include/linux/tty_flip.h:27:53: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
27 | *flag_buf_ptr(tb, tb->used) = flag;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
include/linux/tty.h: In function 'sci_receive_chars':
include/linux/tty.h:69:23: note: destination object 'data' of size 0
69 | unsigned long data[0];
| ^~~~
In function 'tty_insert_flip_char',
inlined from 'sci_receive_chars' at drivers/tty/serial/sh-sci.c:906:5:
include/linux/tty_flip.h:28:47: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
28 | *char_buf_ptr(tb, tb->used++) = ch;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
include/linux/tty.h: In function 'sci_receive_chars':
include/linux/tty.h:69:23: note: destination object 'data' of size 0
69 | unsigned long data[0];
| ^~~~
In function 'tty_insert_flip_char',
inlined from 'sci_receive_chars' at drivers/tty/serial/sh-sci.c:883:5:
include/linux/tty_flip.h:27:53: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
27 | *flag_buf_ptr(tb, tb->used) = flag;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
include/linux/tty.h: In function 'sci_receive_chars':
include/linux/tty.h:69:23: note: destination object 'data' of size 0
69 | unsigned long data[0];
| ^~~~
In function 'tty_insert_flip_char',
inlined from 'sci_receive_chars' at drivers/tty/serial/sh-sci.c:883:5:
include/linux/tty_flip.h:28:47: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
28 | *char_buf_ptr(tb, tb->used++) = ch;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
include/linux/tty.h: In function 'sci_receive_chars':
include/linux/tty.h:69:23: note: destination object 'data' of size 0
69 | unsigned long data[0];
| ^~~~
vim +/flags +88 arch/arm64/include/asm/irqflags.h
fb9bd7d6df81dd Marc Zyngier 2012-03-05 82
fb9bd7d6df81dd Marc Zyngier 2012-03-05 83 /*
fb9bd7d6df81dd Marc Zyngier 2012-03-05 84 * restore saved IRQ state
fb9bd7d6df81dd Marc Zyngier 2012-03-05 85 */
fb9bd7d6df81dd Marc Zyngier 2012-03-05 86 static inline void arch_local_irq_restore(unsigned long flags)
fb9bd7d6df81dd Marc Zyngier 2012-03-05 87 {
fb9bd7d6df81dd Marc Zyngier 2012-03-05 @88 asm volatile(
fb9bd7d6df81dd Marc Zyngier 2012-03-05 89 "msr daif, %0 // arch_local_irq_restore"
fb9bd7d6df81dd Marc Zyngier 2012-03-05 90 :
fb9bd7d6df81dd Marc Zyngier 2012-03-05 91 : "r" (flags)
fb9bd7d6df81dd Marc Zyngier 2012-03-05 92 : "memory");
fb9bd7d6df81dd Marc Zyngier 2012-03-05 93 }
fb9bd7d6df81dd Marc Zyngier 2012-03-05 94
:::::: The code at line 88 was first introduced by commit
:::::: fb9bd7d6df81ddf1e7ab6648ac89ddbe0625b26b arm64: IRQ handling
:::::: TO: Marc Zyngier <marc.zyngier(a)arm.com>
:::::: CC: Catalin Marinas <catalin.marinas(a)arm.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
From: Ming Lei <ming.lei(a)redhat.com>
mainline inclusion
from mainline-v6.12-rc1
commit c9ea57c91f03bcad415e1a20113bdb2077bcf990
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYQRD
CVE: CVE-2024-49855
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?…
--------------------------------
If request timetout is handled by nbd_requeue_cmd(), normal completion
has to be stopped for avoiding to complete this requeued request, other
use-after-free can be triggered.
Fix the race by clearing NBD_CMD_INFLIGHT in nbd_requeue_cmd(), meantime
make sure that cmd->lock is grabbed for clearing the flag and the
requeue.
Cc: Josef Bacik <josef(a)toxicpanda.com>
Cc: Yu Kuai <yukuai3(a)huawei.com>
Fixes: 2895f1831e91 ("nbd: don't clear 'NBD_CMD_INFLIGHT' flag if request is not completed")
Signed-off-by: Ming Lei <ming.lei(a)redhat.com>
Reviewed-by: Yu Kuai <yukuai3(a)huawei.com>
Link: https://lore.kernel.org/r/20240830034145.1827742-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe(a)kernel.dk>
Signed-off-by: Zheng Qixing <zhengqixing(a)huawei.com>
---
drivers/block/nbd.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index fae0846d9409..9d413c4fd64c 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -169,6 +169,17 @@ static void nbd_requeue_cmd(struct nbd_cmd *cmd)
{
struct request *req = blk_mq_rq_from_pdu(cmd);
+ lockdep_assert_held(&cmd->lock);
+
+ /*
+ * Clear INFLIGHT flag so that this cmd won't be completed in
+ * normal completion path
+ *
+ * INFLIGHT flag will be set when the cmd is queued to nbd next
+ * time.
+ */
+ __clear_bit(NBD_CMD_INFLIGHT, &cmd->flags);
+
if (!test_and_set_bit(NBD_CMD_REQUEUED, &cmd->flags))
blk_mq_requeue_request(req, true);
}
@@ -434,8 +445,8 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
nbd_mark_nsock_dead(nbd, nsock, 1);
mutex_unlock(&nsock->tx_lock);
}
- mutex_unlock(&cmd->lock);
nbd_requeue_cmd(cmd);
+ mutex_unlock(&cmd->lock);
nbd_config_put(nbd);
return BLK_EH_DONE;
}
--
2.39.2
From: Ming Lei <ming.lei(a)redhat.com>
mainline inclusion
from mainline-v6.12-rc1
commit c9ea57c91f03bcad415e1a20113bdb2077bcf990
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYQRD
CVE: CVE-2024-49855
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?…
--------------------------------
If request timetout is handled by nbd_requeue_cmd(), normal completion
has to be stopped for avoiding to complete this requeued request, other
use-after-free can be triggered.
Fix the race by clearing NBD_CMD_INFLIGHT in nbd_requeue_cmd(), meantime
make sure that cmd->lock is grabbed for clearing the flag and the
requeue.
Cc: Josef Bacik <josef(a)toxicpanda.com>
Cc: Yu Kuai <yukuai3(a)huawei.com>
Fixes: 2895f1831e91 ("nbd: don't clear 'NBD_CMD_INFLIGHT' flag if request is not completed")
Signed-off-by: Ming Lei <ming.lei(a)redhat.com>
Reviewed-by: Yu Kuai <yukuai3(a)huawei.com>
Link: https://lore.kernel.org/r/20240830034145.1827742-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe(a)kernel.dk>
Signed-off-by: Zheng Qixing <zhengqixing(a)huawei.com>
---
drivers/block/nbd.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 6a9e8fd84f03..9dbd7cb3df13 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -172,6 +172,17 @@ static void nbd_requeue_cmd(struct nbd_cmd *cmd)
{
struct request *req = blk_mq_rq_from_pdu(cmd);
+ lockdep_assert_held(&cmd->lock);
+
+ /*
+ * Clear INFLIGHT flag so that this cmd won't be completed in
+ * normal completion path
+ *
+ * INFLIGHT flag will be set when the cmd is queued to nbd next
+ * time.
+ */
+ __clear_bit(NBD_CMD_INFLIGHT, &cmd->flags);
+
if (!test_and_set_bit(NBD_CMD_REQUEUED, &cmd->flags))
blk_mq_requeue_request(req, true);
}
@@ -453,8 +464,8 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
nbd_mark_nsock_dead(nbd, nsock, 1);
mutex_unlock(&nsock->tx_lock);
}
- mutex_unlock(&cmd->lock);
nbd_requeue_cmd(cmd);
+ mutex_unlock(&cmd->lock);
nbd_config_put(nbd);
return BLK_EH_DONE;
}
--
2.39.2
From: Ming Lei <ming.lei(a)redhat.com>
mainline inclusion
from mainline-v6.12-rc1
commit c9ea57c91f03bcad415e1a20113bdb2077bcf990
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYQRD
CVE: CVE-2024-49855
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?…
--------------------------------
If request timetout is handled by nbd_requeue_cmd(), normal completion
has to be stopped for avoiding to complete this requeued request, other
use-after-free can be triggered.
Fix the race by clearing NBD_CMD_INFLIGHT in nbd_requeue_cmd(), meantime
make sure that cmd->lock is grabbed for clearing the flag and the
requeue.
Cc: Josef Bacik <josef(a)toxicpanda.com>
Cc: Yu Kuai <yukuai3(a)huawei.com>
Fixes: 2895f1831e91 ("nbd: don't clear 'NBD_CMD_INFLIGHT' flag if request is not completed")
Signed-off-by: Ming Lei <ming.lei(a)redhat.com>
Reviewed-by: Yu Kuai <yukuai3(a)huawei.com>
Link: https://lore.kernel.org/r/20240830034145.1827742-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe(a)kernel.dk>
Signed-off-by: Zheng Qixing <zhengqixing(a)huawei.com>
---
drivers/block/nbd.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 6a9e8fd84f03..9dbd7cb3df13 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -172,6 +172,17 @@ static void nbd_requeue_cmd(struct nbd_cmd *cmd)
{
struct request *req = blk_mq_rq_from_pdu(cmd);
+ lockdep_assert_held(&cmd->lock);
+
+ /*
+ * Clear INFLIGHT flag so that this cmd won't be completed in
+ * normal completion path
+ *
+ * INFLIGHT flag will be set when the cmd is queued to nbd next
+ * time.
+ */
+ __clear_bit(NBD_CMD_INFLIGHT, &cmd->flags);
+
if (!test_and_set_bit(NBD_CMD_REQUEUED, &cmd->flags))
blk_mq_requeue_request(req, true);
}
@@ -453,8 +464,8 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
nbd_mark_nsock_dead(nbd, nsock, 1);
mutex_unlock(&nsock->tx_lock);
}
- mutex_unlock(&cmd->lock);
nbd_requeue_cmd(cmd);
+ mutex_unlock(&cmd->lock);
nbd_config_put(nbd);
return BLK_EH_DONE;
}
--
2.39.2
From: Ming Lei <ming.lei(a)redhat.com>
stable inclusion
from stable-v6.6.54
commit 6e73b946a379a1dfbb62626af93843bdfb53753d
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYQRD
CVE: CVE-2024-49855
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
[ Upstream commit c9ea57c91f03bcad415e1a20113bdb2077bcf990 ]
If request timetout is handled by nbd_requeue_cmd(), normal completion
has to be stopped for avoiding to complete this requeued request, other
use-after-free can be triggered.
Fix the race by clearing NBD_CMD_INFLIGHT in nbd_requeue_cmd(), meantime
make sure that cmd->lock is grabbed for clearing the flag and the
requeue.
Cc: Josef Bacik <josef(a)toxicpanda.com>
Cc: Yu Kuai <yukuai3(a)huawei.com>
Fixes: 2895f1831e91 ("nbd: don't clear 'NBD_CMD_INFLIGHT' flag if request is not completed")
Signed-off-by: Ming Lei <ming.lei(a)redhat.com>
Reviewed-by: Yu Kuai <yukuai3(a)huawei.com>
Link: https://lore.kernel.org/r/20240830034145.1827742-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe(a)kernel.dk>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
Signed-off-by: ZhangPeng <zhangpeng362(a)huawei.com>
Signed-off-by: Zheng Qixing <zhengqixing(a)huawei.com>
---
drivers/block/nbd.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 8bb5972284b5..74d1f9c26ecc 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -181,6 +181,17 @@ static void nbd_requeue_cmd(struct nbd_cmd *cmd)
{
struct request *req = blk_mq_rq_from_pdu(cmd);
+ lockdep_assert_held(&cmd->lock);
+
+ /*
+ * Clear INFLIGHT flag so that this cmd won't be completed in
+ * normal completion path
+ *
+ * INFLIGHT flag will be set when the cmd is queued to nbd next
+ * time.
+ */
+ __clear_bit(NBD_CMD_INFLIGHT, &cmd->flags);
+
if (!test_and_set_bit(NBD_CMD_REQUEUED, &cmd->flags))
blk_mq_requeue_request(req, true);
}
@@ -461,8 +472,8 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req)
nbd_mark_nsock_dead(nbd, nsock, 1);
mutex_unlock(&nsock->tx_lock);
}
- mutex_unlock(&cmd->lock);
nbd_requeue_cmd(cmd);
+ mutex_unlock(&cmd->lock);
nbd_config_put(nbd);
return BLK_EH_DONE;
}
--
2.39.2
Hi chenjiajun,
FYI, the error/warning still remains.
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: d2a40c79ddef4b96b8a7a396bd7273121b1b4a5c
commit: b94fc31d4e16ff65dc2141f0a1a3af6a3aac5bb2 [14594/23859] kvm: debugfs: aarch64 export cpu time related items to debugfs
config: arm64-randconfig-003-20241026 (https://download.01.org/0day-ci/archive/20241026/202410260758.Qe33nEsp-lkp@…)
compiler: aarch64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241026/202410260758.Qe33nEsp-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/202410260758.Qe33nEsp-lkp@intel.com/
All errors (new ones prefixed by >>):
arch/arm64/kvm/../../../virt/kvm/arm/arm.c: In function 'update_steal_time':
>> arch/arm64/kvm/../../../virt/kvm/arm/arm.c:411:36: error: 'struct sched_info' has no member named 'run_delay'
411 | delta = current->sched_info.run_delay - vcpu->stat.steal;
| ^
arch/arm64/kvm/../../../virt/kvm/arm/arm.c:412:47: error: 'struct sched_info' has no member named 'run_delay'
412 | vcpu->stat.steal = current->sched_info.run_delay;
| ^
vim +411 arch/arm64/kvm/../../../virt/kvm/arm/arm.c
406
407 static void update_steal_time(struct kvm_vcpu *vcpu)
408 {
409 u64 delta;
410
> 411 delta = current->sched_info.run_delay - vcpu->stat.steal;
412 vcpu->stat.steal = current->sched_info.run_delay;
413 vcpu->stat.st_max = max(vcpu->stat.st_max, delta);
414 }
415
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki