Skip to content

Commit e919b07

Browse files
vaverinJ. Bruce Fields
authored andcommitted
lockd: remove net pointer from messages
Publishing of net pointer is not safe, use net->ns.inum as net ID in debug messages [ 171.757678] lockd_up_net: per-net data created; net=f00001e7 [ 171.767188] NFSD: starting 90-second grace period (net f00001e7) [ 300.653313] lockd: nuking all hosts in net f00001e7... [ 300.653641] lockd: host garbage collection for net f00001e7 [ 300.653968] lockd: nlmsvc_mark_resources for net f00001e7 [ 300.711483] lockd_down_net: per-net data destroyed; net=f00001e7 [ 300.711847] lockd: nuking all hosts in net 0... [ 300.711847] lockd: host garbage collection for net 0 [ 300.711848] lockd: nlmsvc_mark_resources for net 0 Signed-off-by: Vasily Averin <vvs@virtuozzo.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent ba58952 commit e919b07

4 files changed

Lines changed: 21 additions & 14 deletions

File tree

‎fs/lockd/host.c‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,10 @@ static void nlm_complain_hosts(struct net *net)
578578

579579
if (ln->nrhosts == 0)
580580
return;
581-
printk(KERN_WARNING "lockd: couldn't shutdown host module for net %p!\n", net);
582-
dprintk("lockd: %lu hosts left in net %p:\n", ln->nrhosts, net);
581+
pr_warn("lockd: couldn't shutdown host module for net %x!\n",
582+
net->ns.inum);
583+
dprintk("lockd: %lu hosts left in net %x:\n", ln->nrhosts,
584+
net->ns.inum);
583585
} else {
584586
if (nrhosts == 0)
585587
return;
@@ -590,9 +592,9 @@ static void nlm_complain_hosts(struct net *net)
590592
for_each_host(host, chain, nlm_server_hosts) {
591593
if (net && host->net != net)
592594
continue;
593-
dprintk(" %s (cnt %d use %d exp %ld net %p)\n",
595+
dprintk(" %s (cnt %d use %d exp %ld net %x)\n",
594596
host->h_name, atomic_read(&host->h_count),
595-
host->h_inuse, host->h_expires, host->net);
597+
host->h_inuse, host->h_expires, host->net->ns.inum);
596598
}
597599
}
598600

@@ -605,7 +607,8 @@ nlm_shutdown_hosts_net(struct net *net)
605607
mutex_lock(&nlm_host_mutex);
606608

607609
/* First, make all hosts eligible for gc */
608-
dprintk("lockd: nuking all hosts in net %p...\n", net);
610+
dprintk("lockd: nuking all hosts in net %x...\n",
611+
net ? net->ns.inum : 0);
609612
for_each_host(host, chain, nlm_server_hosts) {
610613
if (net && host->net != net)
611614
continue;
@@ -646,7 +649,8 @@ nlm_gc_hosts(struct net *net)
646649
struct hlist_node *next;
647650
struct nlm_host *host;
648651

649-
dprintk("lockd: host garbage collection for net %p\n", net);
652+
dprintk("lockd: host garbage collection for net %x\n",
653+
net ? net->ns.inum : 0);
650654
for_each_host(host, chain, nlm_server_hosts) {
651655
if (net && host->net != net)
652656
continue;
@@ -662,9 +666,10 @@ nlm_gc_hosts(struct net *net)
662666
if (atomic_read(&host->h_count) || host->h_inuse
663667
|| time_before(jiffies, host->h_expires)) {
664668
dprintk("nlm_gc_hosts skipping %s "
665-
"(cnt %d use %d exp %ld net %p)\n",
669+
"(cnt %d use %d exp %ld net %x)\n",
666670
host->h_name, atomic_read(&host->h_count),
667-
host->h_inuse, host->h_expires, host->net);
671+
host->h_inuse, host->h_expires,
672+
host->net->ns.inum);
668673
continue;
669674
}
670675
nlm_destroy_host_locked(host);

‎fs/lockd/mon.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ static int nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res,
110110
clnt = nsm_create(host->net, host->nodename);
111111
if (IS_ERR(clnt)) {
112112
dprintk("lockd: failed to create NSM upcall transport, "
113-
"status=%ld, net=%p\n", PTR_ERR(clnt), host->net);
113+
"status=%ld, net=%x\n", PTR_ERR(clnt),
114+
host->net->ns.inum);
114115
return PTR_ERR(clnt);
115116
}
116117

‎fs/lockd/svc.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static int lockd_up_net(struct svc_serv *serv, struct net *net)
259259
if (error < 0)
260260
goto err_bind;
261261
set_grace_period(net);
262-
dprintk("lockd_up_net: per-net data created; net=%p\n", net);
262+
dprintk("%s: per-net data created; net=%x\n", __func__, net->ns.inum);
263263
return 0;
264264

265265
err_bind:
@@ -275,11 +275,12 @@ static void lockd_down_net(struct svc_serv *serv, struct net *net)
275275
if (--ln->nlmsvc_users == 0) {
276276
nlm_shutdown_hosts_net(net);
277277
svc_shutdown_net(serv, net);
278-
dprintk("lockd_down_net: per-net data destroyed; net=%p\n", net);
278+
dprintk("%s: per-net data destroyed; net=%x\n",
279+
__func__, net->ns.inum);
279280
}
280281
} else {
281-
printk(KERN_ERR "lockd_down_net: no users! task=%p, net=%p\n",
282-
nlmsvc_task, net);
282+
pr_err("%s: no users! task=%p, net=%x\n",
283+
__func__, nlmsvc_task, net->ns.inum);
283284
BUG();
284285
}
285286
}

‎fs/lockd/svcsubs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ nlmsvc_mark_resources(struct net *net)
370370
{
371371
struct nlm_host hint;
372372

373-
dprintk("lockd: nlmsvc_mark_resources for net %p\n", net);
373+
dprintk("lockd: %s for net %x\n", __func__, net ? net->ns.inum : 0);
374374
hint.net = net;
375375
nlm_traverse_files(&hint, nlmsvc_mark_host, NULL);
376376
}

0 commit comments

Comments
 (0)