Skip to content

Commit f75268c

Browse files
ralfbaechledavem330
authored andcommitted
[AX25]: Make ax2asc thread-proof
Ax2asc was still using a static buffer for all invocations which isn't exactly SMP-safe. Change ax2asc to take an additional result buffer as the argument. Change all callers to provide such a buffer. Signed-off-by: Ralf Baechle DL5RB <ralf@linux-mips.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f2c3839 commit f75268c

10 files changed

Lines changed: 39 additions & 24 deletions

File tree

‎include/net/ax25.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ extern struct sock *ax25_make_new(struct sock *, struct ax25_dev *);
257257

258258
/* ax25_addr.c */
259259
extern ax25_address null_ax25_address;
260-
extern char *ax2asc(ax25_address *);
260+
extern char *ax2asc(char *buf, ax25_address *);
261261
extern ax25_address *asc2ax(char *);
262262
extern int ax25cmp(ax25_address *, ax25_address *);
263263
extern int ax25digicmp(ax25_digi *, ax25_digi *);

‎net/ax25/af_ax25.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,7 @@ static void ax25_info_stop(struct seq_file *seq, void *v)
18741874
static int ax25_info_show(struct seq_file *seq, void *v)
18751875
{
18761876
ax25_cb *ax25 = v;
1877+
char buf[11];
18771878
int k;
18781879

18791880

@@ -1885,13 +1886,13 @@ static int ax25_info_show(struct seq_file *seq, void *v)
18851886
seq_printf(seq, "%8.8lx %s %s%s ",
18861887
(long) ax25,
18871888
ax25->ax25_dev == NULL? "???" : ax25->ax25_dev->dev->name,
1888-
ax2asc(&ax25->source_addr),
1889+
ax2asc(buf, &ax25->source_addr),
18891890
ax25->iamdigi? "*":"");
1890-
seq_printf(seq, "%s", ax2asc(&ax25->dest_addr));
1891+
seq_printf(seq, "%s", ax2asc(buf, &ax25->dest_addr));
18911892

18921893
for (k=0; (ax25->digipeat != NULL) && (k < ax25->digipeat->ndigi); k++) {
18931894
seq_printf(seq, ",%s%s",
1894-
ax2asc(&ax25->digipeat->calls[k]),
1895+
ax2asc(buf, &ax25->digipeat->calls[k]),
18951896
ax25->digipeat->repeated[k]? "*":"");
18961897
}
18971898

‎net/ax25/ax25_addr.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ ax25_address null_ax25_address = {{0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00}};
3636
/*
3737
* ax25 -> ascii conversion
3838
*/
39-
char *ax2asc(ax25_address *a)
39+
char *ax2asc(char *buf, ax25_address *a)
4040
{
41-
static char buf[11];
4241
char c, *s;
4342
int n;
4443

‎net/ax25/ax25_route.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ static void ax25_rt_seq_stop(struct seq_file *seq, void *v)
298298

299299
static int ax25_rt_seq_show(struct seq_file *seq, void *v)
300300
{
301+
char buf[11];
302+
301303
if (v == SEQ_START_TOKEN)
302304
seq_puts(seq, "callsign dev mode digipeaters\n");
303305
else {
@@ -308,7 +310,7 @@ static int ax25_rt_seq_show(struct seq_file *seq, void *v)
308310
if (ax25cmp(&ax25_rt->callsign, &null_ax25_address) == 0)
309311
callsign = "default";
310312
else
311-
callsign = ax2asc(&ax25_rt->callsign);
313+
callsign = ax2asc(buf, &ax25_rt->callsign);
312314

313315
seq_printf(seq, "%-9s %-4s",
314316
callsign,
@@ -328,7 +330,8 @@ static int ax25_rt_seq_show(struct seq_file *seq, void *v)
328330

329331
if (ax25_rt->digipeat != NULL)
330332
for (i = 0; i < ax25_rt->digipeat->ndigi; i++)
331-
seq_printf(seq, " %s", ax2asc(&ax25_rt->digipeat->calls[i]));
333+
seq_printf(seq, " %s",
334+
ax2asc(buf, &ax25_rt->digipeat->calls[i]));
332335

333336
seq_puts(seq, "\n");
334337
}

‎net/ax25/ax25_uid.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,14 @@ static void ax25_uid_seq_stop(struct seq_file *seq, void *v)
168168

169169
static int ax25_uid_seq_show(struct seq_file *seq, void *v)
170170
{
171+
char buf[11];
172+
171173
if (v == SEQ_START_TOKEN)
172174
seq_printf(seq, "Policy: %d\n", ax25_uid_policy);
173175
else {
174176
struct ax25_uid_assoc *pt = v;
175177

176-
seq_printf(seq, "%6d %s\n", pt->uid, ax2asc(&pt->call));
178+
seq_printf(seq, "%6d %s\n", pt->uid, ax2asc(buf, &pt->call));
177179
}
178180
return 0;
179181
}

‎net/netrom/af_netrom.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,7 @@ static int nr_info_show(struct seq_file *seq, void *v)
12611261
struct net_device *dev;
12621262
struct nr_sock *nr;
12631263
const char *devname;
1264+
char buf[11];
12641265

12651266
if (v == SEQ_START_TOKEN)
12661267
seq_puts(seq,
@@ -1276,11 +1277,11 @@ static int nr_info_show(struct seq_file *seq, void *v)
12761277
else
12771278
devname = dev->name;
12781279

1279-
seq_printf(seq, "%-9s ", ax2asc(&nr->user_addr));
1280-
seq_printf(seq, "%-9s ", ax2asc(&nr->dest_addr));
1280+
seq_printf(seq, "%-9s ", ax2asc(buf, &nr->user_addr));
1281+
seq_printf(seq, "%-9s ", ax2asc(buf, &nr->dest_addr));
12811282
seq_printf(seq,
12821283
"%-9s %-3s %02X/%02X %02X/%02X %2d %3d %3d %3d %3lu/%03lu %2lu/%02lu %3lu/%03lu %3lu/%03lu %2d/%02d %3d %5d %5d %ld\n",
1283-
ax2asc(&nr->source_addr),
1284+
ax2asc(buf, &nr->source_addr),
12841285
devname,
12851286
nr->my_index,
12861287
nr->my_id,

‎net/netrom/nr_route.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ static void nr_node_stop(struct seq_file *seq, void *v)
881881

882882
static int nr_node_show(struct seq_file *seq, void *v)
883883
{
884+
char buf[11];
884885
int i;
885886

886887
if (v == SEQ_START_TOKEN)
@@ -890,7 +891,7 @@ static int nr_node_show(struct seq_file *seq, void *v)
890891
struct nr_node *nr_node = v;
891892
nr_node_lock(nr_node);
892893
seq_printf(seq, "%-9s %-7s %d %d",
893-
ax2asc(&nr_node->callsign),
894+
ax2asc(buf, &nr_node->callsign),
894895
(nr_node->mnemonic[0] == '\0') ? "*" : nr_node->mnemonic,
895896
nr_node->which + 1,
896897
nr_node->count);
@@ -964,6 +965,7 @@ static void nr_neigh_stop(struct seq_file *seq, void *v)
964965

965966
static int nr_neigh_show(struct seq_file *seq, void *v)
966967
{
968+
char buf[11];
967969
int i;
968970

969971
if (v == SEQ_START_TOKEN)
@@ -973,7 +975,7 @@ static int nr_neigh_show(struct seq_file *seq, void *v)
973975

974976
seq_printf(seq, "%05d %-9s %-4s %3d %d %3d %3d",
975977
nr_neigh->number,
976-
ax2asc(&nr_neigh->callsign),
978+
ax2asc(buf, &nr_neigh->callsign),
977979
nr_neigh->dev ? nr_neigh->dev->name : "???",
978980
nr_neigh->quality,
979981
nr_neigh->locked,
@@ -983,7 +985,7 @@ static int nr_neigh_show(struct seq_file *seq, void *v)
983985
if (nr_neigh->digipeat != NULL) {
984986
for (i = 0; i < nr_neigh->digipeat->ndigi; i++)
985987
seq_printf(seq, " %s",
986-
ax2asc(&nr_neigh->digipeat->calls[i]));
988+
ax2asc(buf, &nr_neigh->digipeat->calls[i]));
987989
}
988990

989991
seq_puts(seq, "\n");

‎net/rose/af_rose.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,8 @@ static void rose_info_stop(struct seq_file *seq, void *v)
13631363

13641364
static int rose_info_show(struct seq_file *seq, void *v)
13651365
{
1366+
char buf[11];
1367+
13661368
if (v == SEQ_START_TOKEN)
13671369
seq_puts(seq,
13681370
"dest_addr dest_call src_addr src_call dev lci neigh st vs vr va t t1 t2 t3 hb idle Snd-Q Rcv-Q inode\n");
@@ -1380,12 +1382,12 @@ static int rose_info_show(struct seq_file *seq, void *v)
13801382

13811383
seq_printf(seq, "%-10s %-9s ",
13821384
rose2asc(&rose->dest_addr),
1383-
ax2asc(&rose->dest_call));
1385+
ax2asc(buf, &rose->dest_call));
13841386

13851387
if (ax25cmp(&rose->source_call, &null_ax25_address) == 0)
13861388
callsign = "??????-?";
13871389
else
1388-
callsign = ax2asc(&rose->source_call);
1390+
callsign = ax2asc(buf, &rose->source_call);
13891391

13901392
seq_printf(seq,
13911393
"%-10s %-9s %-5s %3.3X %05d %d %d %d %d %3lu %3lu %3lu %3lu %3lu %3lu/%03lu %5d %5d %ld\n",

‎net/rose/rose_route.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
851851
unsigned char cause, diagnostic;
852852
struct net_device *dev;
853853
int len, res = 0;
854+
char buf[11];
854855

855856
#if 0
856857
if (call_in_firewall(PF_ROSE, skb->dev, skb->data, NULL, &skb) != FW_ACCEPT)
@@ -876,7 +877,7 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
876877

877878
if (rose_neigh == NULL) {
878879
printk("rose_route : unknown neighbour or device %s\n",
879-
ax2asc(&ax25->dest_addr));
880+
ax2asc(buf, &ax25->dest_addr));
880881
goto out;
881882
}
882883

@@ -1178,6 +1179,7 @@ static void rose_neigh_stop(struct seq_file *seq, void *v)
11781179

11791180
static int rose_neigh_show(struct seq_file *seq, void *v)
11801181
{
1182+
char buf[11];
11811183
int i;
11821184

11831185
if (v == SEQ_START_TOKEN)
@@ -1189,7 +1191,7 @@ static int rose_neigh_show(struct seq_file *seq, void *v)
11891191
/* if (!rose_neigh->loopback) { */
11901192
seq_printf(seq, "%05d %-9s %-4s %3d %3d %3s %3s %3lu %3lu",
11911193
rose_neigh->number,
1192-
(rose_neigh->loopback) ? "RSLOOP-0" : ax2asc(&rose_neigh->callsign),
1194+
(rose_neigh->loopback) ? "RSLOOP-0" : ax2asc(buf, &rose_neigh->callsign),
11931195
rose_neigh->dev ? rose_neigh->dev->name : "???",
11941196
rose_neigh->count,
11951197
rose_neigh->use,
@@ -1200,7 +1202,7 @@ static int rose_neigh_show(struct seq_file *seq, void *v)
12001202

12011203
if (rose_neigh->digipeat != NULL) {
12021204
for (i = 0; i < rose_neigh->digipeat->ndigi; i++)
1203-
seq_printf(seq, " %s", ax2asc(&rose_neigh->digipeat->calls[i]));
1205+
seq_printf(seq, " %s", ax2asc(buf, &rose_neigh->digipeat->calls[i]));
12041206
}
12051207

12061208
seq_puts(seq, "\n");
@@ -1260,6 +1262,8 @@ static void rose_route_stop(struct seq_file *seq, void *v)
12601262

12611263
static int rose_route_show(struct seq_file *seq, void *v)
12621264
{
1265+
char buf[11];
1266+
12631267
if (v == SEQ_START_TOKEN)
12641268
seq_puts(seq,
12651269
"lci address callsign neigh <-> lci address callsign neigh\n");
@@ -1271,7 +1275,7 @@ static int rose_route_show(struct seq_file *seq, void *v)
12711275
"%3.3X %-10s %-9s %05d ",
12721276
rose_route->lci1,
12731277
rose2asc(&rose_route->src_addr),
1274-
ax2asc(&rose_route->src_call),
1278+
ax2asc(buf, &rose_route->src_call),
12751279
rose_route->neigh1->number);
12761280
else
12771281
seq_puts(seq,
@@ -1282,7 +1286,7 @@ static int rose_route_show(struct seq_file *seq, void *v)
12821286
"%3.3X %-10s %-9s %05d\n",
12831287
rose_route->lci2,
12841288
rose2asc(&rose_route->dest_addr),
1285-
ax2asc(&rose_route->dest_call),
1289+
ax2asc(buf, &rose_route->dest_call),
12861290
rose_route->neigh2->number);
12871291
else
12881292
seq_puts(seq,

‎net/rose/rose_subr.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ static int rose_create_facilities(unsigned char *buffer, struct rose_sock *rose)
400400
{
401401
unsigned char *p = buffer + 1;
402402
char *callsign;
403+
char buf[11];
403404
int len, nb;
404405

405406
/* National Facilities */
@@ -456,7 +457,7 @@ static int rose_create_facilities(unsigned char *buffer, struct rose_sock *rose)
456457

457458
*p++ = FAC_CCITT_DEST_NSAP;
458459

459-
callsign = ax2asc(&rose->dest_call);
460+
callsign = ax2asc(buf, &rose->dest_call);
460461

461462
*p++ = strlen(callsign) + 10;
462463
*p++ = (strlen(callsign) + 9) * 2; /* ??? */
@@ -471,7 +472,7 @@ static int rose_create_facilities(unsigned char *buffer, struct rose_sock *rose)
471472

472473
*p++ = FAC_CCITT_SRC_NSAP;
473474

474-
callsign = ax2asc(&rose->source_call);
475+
callsign = ax2asc(buf, &rose->source_call);
475476

476477
*p++ = strlen(callsign) + 10;
477478
*p++ = (strlen(callsign) + 9) * 2; /* ??? */

0 commit comments

Comments
 (0)