mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
bcachefs: Fix null ptr deref in twf from BCH_IOCTL_FSCK_OFFLINE
We need to initialize the stdio redirects before they're used. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
ad29cf999a
commit
02bed83d59
@ -232,13 +232,15 @@ static long bch2_ioctl_fsck_offline(struct bch_ioctl_fsck_offline __user *user_a
|
||||
/* We need request_key() to be called before we punt to kthread: */
|
||||
opt_set(thr->opts, nostart, true);
|
||||
|
||||
bch2_thread_with_stdio_init(&thr->thr, &bch2_offline_fsck_ops);
|
||||
|
||||
thr->c = bch2_fs_open(devs.data, arg.nr_devs, thr->opts);
|
||||
|
||||
if (!IS_ERR(thr->c) &&
|
||||
thr->c->opts.errors == BCH_ON_ERROR_panic)
|
||||
thr->c->opts.errors = BCH_ON_ERROR_ro;
|
||||
|
||||
ret = bch2_run_thread_with_stdio(&thr->thr, &bch2_offline_fsck_ops);
|
||||
ret = __bch2_run_thread_with_stdio(&thr->thr);
|
||||
out:
|
||||
darray_for_each(devs, i)
|
||||
kfree(*i);
|
||||
|
@ -294,16 +294,27 @@ static int thread_with_stdio_fn(void *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bch2_run_thread_with_stdio(struct thread_with_stdio *thr,
|
||||
const struct thread_with_stdio_ops *ops)
|
||||
void bch2_thread_with_stdio_init(struct thread_with_stdio *thr,
|
||||
const struct thread_with_stdio_ops *ops)
|
||||
{
|
||||
stdio_buf_init(&thr->stdio.input);
|
||||
stdio_buf_init(&thr->stdio.output);
|
||||
thr->ops = ops;
|
||||
}
|
||||
|
||||
int __bch2_run_thread_with_stdio(struct thread_with_stdio *thr)
|
||||
{
|
||||
return bch2_run_thread_with_file(&thr->thr, &thread_with_stdio_fops, thread_with_stdio_fn);
|
||||
}
|
||||
|
||||
int bch2_run_thread_with_stdio(struct thread_with_stdio *thr,
|
||||
const struct thread_with_stdio_ops *ops)
|
||||
{
|
||||
bch2_thread_with_stdio_init(thr, ops);
|
||||
|
||||
return __bch2_run_thread_with_stdio(thr);
|
||||
}
|
||||
|
||||
int bch2_run_thread_with_stdout(struct thread_with_stdio *thr,
|
||||
const struct thread_with_stdio_ops *ops)
|
||||
{
|
||||
|
@ -63,6 +63,9 @@ struct thread_with_stdio {
|
||||
const struct thread_with_stdio_ops *ops;
|
||||
};
|
||||
|
||||
void bch2_thread_with_stdio_init(struct thread_with_stdio *,
|
||||
const struct thread_with_stdio_ops *);
|
||||
int __bch2_run_thread_with_stdio(struct thread_with_stdio *);
|
||||
int bch2_run_thread_with_stdio(struct thread_with_stdio *,
|
||||
const struct thread_with_stdio_ops *);
|
||||
int bch2_run_thread_with_stdout(struct thread_with_stdio *,
|
||||
|
Loading…
Reference in New Issue
Block a user