Skip to content

Commit 5876aa0

Browse files
committed
Merge tag 'nfsd-5.8-2' of git://linux-nfs.org/~bfields/linux into master
Pull nfsd fix from Bruce Fields: "Just one fix for a NULL dereference if someone happens to read /proc/fs/nfsd/client/../state at the wrong moment" * tag 'nfsd-5.8-2' of git://linux-nfs.org/~bfields/linux: nfsd4: fix NULL dereference in nfsd/clients display code
2 parents 68845a5 + 9affa43 commit 5876aa0

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

fs/nfsd/nfs4state.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,17 @@ find_any_file(struct nfs4_file *f)
507507
return ret;
508508
}
509509

510+
static struct nfsd_file *find_deleg_file(struct nfs4_file *f)
511+
{
512+
struct nfsd_file *ret = NULL;
513+
514+
spin_lock(&f->fi_lock);
515+
if (f->fi_deleg_file)
516+
ret = nfsd_file_get(f->fi_deleg_file);
517+
spin_unlock(&f->fi_lock);
518+
return ret;
519+
}
520+
510521
static atomic_long_t num_delegations;
511522
unsigned long max_delegations;
512523

@@ -2444,6 +2455,8 @@ static int nfs4_show_open(struct seq_file *s, struct nfs4_stid *st)
24442455
oo = ols->st_stateowner;
24452456
nf = st->sc_file;
24462457
file = find_any_file(nf);
2458+
if (!file)
2459+
return 0;
24472460

24482461
seq_printf(s, "- ");
24492462
nfs4_show_stateid(s, &st->sc_stateid);
@@ -2481,6 +2494,8 @@ static int nfs4_show_lock(struct seq_file *s, struct nfs4_stid *st)
24812494
oo = ols->st_stateowner;
24822495
nf = st->sc_file;
24832496
file = find_any_file(nf);
2497+
if (!file)
2498+
return 0;
24842499

24852500
seq_printf(s, "- ");
24862501
nfs4_show_stateid(s, &st->sc_stateid);
@@ -2513,7 +2528,9 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st)
25132528

25142529
ds = delegstateid(st);
25152530
nf = st->sc_file;
2516-
file = nf->fi_deleg_file;
2531+
file = find_deleg_file(nf);
2532+
if (!file)
2533+
return 0;
25172534

25182535
seq_printf(s, "- ");
25192536
nfs4_show_stateid(s, &st->sc_stateid);
@@ -2529,6 +2546,7 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st)
25292546
seq_printf(s, ", ");
25302547
nfs4_show_fname(s, file);
25312548
seq_printf(s, " }\n");
2549+
nfsd_file_put(file);
25322550

25332551
return 0;
25342552
}

0 commit comments

Comments
 (0)