mirror of
https://github.com/torvalds/linux.git
synced 2025-11-03 01:59:51 +02:00
bcachefs: Fix possible console lock involved deadlock
Link: https://lore.kernel.org/all/6822ab02.050a0220.f2294.00cb.GAE@google.com/T/ Reported-by: syzbot+2c3ef91c9523c3d1a25c@syzkaller.appspotmail.com Signed-off-by: Alan Huang <mmpgouride@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
3315113af1
commit
0acb385ec1
6 changed files with 8 additions and 20 deletions
|
|
@ -296,7 +296,6 @@ do { \
|
||||||
#define bch2_fmt(_c, fmt) bch2_log_msg(_c, fmt "\n")
|
#define bch2_fmt(_c, fmt) bch2_log_msg(_c, fmt "\n")
|
||||||
|
|
||||||
void bch2_print_str(struct bch_fs *, const char *, const char *);
|
void bch2_print_str(struct bch_fs *, const char *, const char *);
|
||||||
void bch2_print_str_nonblocking(struct bch_fs *, const char *, const char *);
|
|
||||||
|
|
||||||
__printf(2, 3)
|
__printf(2, 3)
|
||||||
void bch2_print_opts(struct bch_opts *, const char *, ...);
|
void bch2_print_opts(struct bch_opts *, const char *, ...);
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ static noinline __noreturn void break_cycle_fail(struct lock_graph *g)
|
||||||
prt_newline(&buf);
|
prt_newline(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bch2_print_str_nonblocking(g->g->trans->c, KERN_ERR, buf.buf);
|
bch2_print_str(g->g->trans->c, KERN_ERR, buf.buf);
|
||||||
printbuf_exit(&buf);
|
printbuf_exit(&buf);
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ static bool bch2_fs_trans_inconsistent(struct bch_fs *c, struct btree_trans *tra
|
||||||
if (trans)
|
if (trans)
|
||||||
bch2_trans_updates_to_text(&buf, trans);
|
bch2_trans_updates_to_text(&buf, trans);
|
||||||
bool ret = __bch2_inconsistent_error(c, &buf);
|
bool ret = __bch2_inconsistent_error(c, &buf);
|
||||||
bch2_print_str_nonblocking(c, KERN_ERR, buf.buf);
|
bch2_print_str(c, KERN_ERR, buf.buf);
|
||||||
|
|
||||||
printbuf_exit(&buf);
|
printbuf_exit(&buf);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ const char * const bch2_dev_write_refs[] = {
|
||||||
#undef x
|
#undef x
|
||||||
|
|
||||||
static void __bch2_print_str(struct bch_fs *c, const char *prefix,
|
static void __bch2_print_str(struct bch_fs *c, const char *prefix,
|
||||||
const char *str, bool nonblocking)
|
const char *str)
|
||||||
{
|
{
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
struct stdio_redirect *stdio = bch2_fs_stdio_redirect(c);
|
struct stdio_redirect *stdio = bch2_fs_stdio_redirect(c);
|
||||||
|
|
@ -114,17 +114,12 @@ static void __bch2_print_str(struct bch_fs *c, const char *prefix,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
bch2_print_string_as_lines(KERN_ERR, str, nonblocking);
|
bch2_print_string_as_lines(KERN_ERR, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bch2_print_str(struct bch_fs *c, const char *prefix, const char *str)
|
void bch2_print_str(struct bch_fs *c, const char *prefix, const char *str)
|
||||||
{
|
{
|
||||||
__bch2_print_str(c, prefix, str, false);
|
__bch2_print_str(c, prefix, str);
|
||||||
}
|
|
||||||
|
|
||||||
void bch2_print_str_nonblocking(struct bch_fs *c, const char *prefix, const char *str)
|
|
||||||
{
|
|
||||||
__bch2_print_str(c, prefix, str, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__printf(2, 0)
|
__printf(2, 0)
|
||||||
|
|
|
||||||
|
|
@ -262,8 +262,7 @@ static bool string_is_spaces(const char *str)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bch2_print_string_as_lines(const char *prefix, const char *lines,
|
void bch2_print_string_as_lines(const char *prefix, const char *lines)
|
||||||
bool nonblocking)
|
|
||||||
{
|
{
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
@ -273,12 +272,7 @@ void bch2_print_string_as_lines(const char *prefix, const char *lines,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nonblocking) {
|
locked = console_trylock();
|
||||||
console_lock();
|
|
||||||
locked = true;
|
|
||||||
} else {
|
|
||||||
locked = console_trylock();
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*lines) {
|
while (*lines) {
|
||||||
p = strchrnul(lines, '\n');
|
p = strchrnul(lines, '\n');
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ u64 bch2_read_flag_list(const char *, const char * const[]);
|
||||||
void bch2_prt_u64_base2_nbits(struct printbuf *, u64, unsigned);
|
void bch2_prt_u64_base2_nbits(struct printbuf *, u64, unsigned);
|
||||||
void bch2_prt_u64_base2(struct printbuf *, u64);
|
void bch2_prt_u64_base2(struct printbuf *, u64);
|
||||||
|
|
||||||
void bch2_print_string_as_lines(const char *, const char *, bool);
|
void bch2_print_string_as_lines(const char *, const char *);
|
||||||
|
|
||||||
typedef DARRAY(unsigned long) bch_stacktrace;
|
typedef DARRAY(unsigned long) bch_stacktrace;
|
||||||
int bch2_save_backtrace(bch_stacktrace *stack, struct task_struct *, unsigned, gfp_t);
|
int bch2_save_backtrace(bch_stacktrace *stack, struct task_struct *, unsigned, gfp_t);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue