Commit 17050fe1 authored by Ye Weihua's avatar Ye Weihua
Browse files

printk: fix double unlock issue in logbuf_lock

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I91SQA


CVE: NA

----------------------------------------

The following warning was found while testing the printk:
	pvqspinlock: lock 0xffffffffac56e1ac has corrupted value 0x0!

	[ 3027.446208] WARNING: CPU: 2 PID: 0 at kernel/locking/qspinlock_paravirt.h:498 __pv_queued_spin_unlock_slowpath+0xc0/0xd0
	[ 3027.446283]  ? __pv_queued_spin_unlock_slowpath+0xc0/0xd0
	[ 3027.446285]  __raw_callee_save___pv_queued_spin_unlock_slowpath+0x11/0x24
	[ 3027.446288]  .slowpath+0x9/0x16
	[ 3027.446292]  console_unlock+0x265/0x3e0
	[ 3027.446294]  vprintk_emit+0x12b/0x150
	[ 3027.446298]  printk+0x58/0x73
	[ 3027.446300]  dump_stack_print_info+0x77/0xa0

This problem occurs because logbuf_lock that does not exist in
the later version is not processed when the community patch
793d63aff1ee802d00cf2155182b379570f76c4e ("printk: Drop
console_sem during panic")is adapted. Resolve the problem by
reacquiring the lock before the break.

Fixes: 770a80b00211 ("[Backport] printk: Drop console_sem during panic")
Signed-off-by: default avatarYe Weihua <yeweihua4@huawei.com>
parent afe6e074
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -2495,7 +2495,7 @@ void console_unlock(void)
	static char text[LOG_LINE_MAX + PREFIX_MAX];
	static int panic_console_dropped;
	unsigned long flags;
	bool do_cond_resched, retry;
	bool do_cond_resched, retry, locked = false;
	struct printk_info info;
	struct printk_record r;

@@ -2541,6 +2541,7 @@ void console_unlock(void)

		printk_safe_enter_irqsave(flags);
		raw_spin_lock(&logbuf_lock);
		locked = true;
skip:
		if (!prb_read_valid(prb, console_seq, &r))
			break;
@@ -2588,6 +2589,7 @@ void console_unlock(void)
				console_msg_format & MSG_FORMAT_SYSLOG,
				printk_time);
		console_seq++;
		locked = false;
		raw_spin_unlock(&logbuf_lock);

		/*
@@ -2619,6 +2621,7 @@ void console_unlock(void)

	console_locked = 0;

	if (likely(locked))
		raw_spin_unlock(&logbuf_lock);

	up_console_sem();