Skip to content

Commit

Permalink
[AX25]: Make ax2asc thread-proof
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ralfbaechle authored and davem330 committed Sep 6, 2005
1 parent f2c3839 commit f75268c
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 24 deletions.
2 changes: 1 addition & 1 deletion include/net/ax25.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ extern struct sock *ax25_make_new(struct sock *, struct ax25_dev *);

/* ax25_addr.c */
extern ax25_address null_ax25_address;
extern char *ax2asc(ax25_address *);
extern char *ax2asc(char *buf, ax25_address *);
extern ax25_address *asc2ax(char *);
extern int ax25cmp(ax25_address *, ax25_address *);
extern int ax25digicmp(ax25_digi *, ax25_digi *);
Expand Down
7 changes: 4 additions & 3 deletions net/ax25/af_ax25.c
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,7 @@ static void ax25_info_stop(struct seq_file *seq, void *v)
static int ax25_info_show(struct seq_file *seq, void *v)
{
ax25_cb *ax25 = v;
char buf[11];
int k;


Expand All @@ -1885,13 +1886,13 @@ static int ax25_info_show(struct seq_file *seq, void *v)
seq_printf(seq, "%8.8lx %s %s%s ",
(long) ax25,
ax25->ax25_dev == NULL? "???" : ax25->ax25_dev->dev->name,
ax2asc(&ax25->source_addr),
ax2asc(buf, &ax25->source_addr),
ax25->iamdigi? "*":"");
seq_printf(seq, "%s", ax2asc(&ax25->dest_addr));
seq_printf(seq, "%s", ax2asc(buf, &ax25->dest_addr));

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

Expand Down
3 changes: 1 addition & 2 deletions net/ax25/ax25_addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ ax25_address null_ax25_address = {{0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00}};
/*
* ax25 -> ascii conversion
*/
char *ax2asc(ax25_address *a)
char *ax2asc(char *buf, ax25_address *a)
{
static char buf[11];
char c, *s;
int n;

Expand Down
7 changes: 5 additions & 2 deletions net/ax25/ax25_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ static void ax25_rt_seq_stop(struct seq_file *seq, void *v)

static int ax25_rt_seq_show(struct seq_file *seq, void *v)
{
char buf[11];

if (v == SEQ_START_TOKEN)
seq_puts(seq, "callsign dev mode digipeaters\n");
else {
Expand All @@ -308,7 +310,7 @@ static int ax25_rt_seq_show(struct seq_file *seq, void *v)
if (ax25cmp(&ax25_rt->callsign, &null_ax25_address) == 0)
callsign = "default";
else
callsign = ax2asc(&ax25_rt->callsign);
callsign = ax2asc(buf, &ax25_rt->callsign);

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

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

seq_puts(seq, "\n");
}
Expand Down
4 changes: 3 additions & 1 deletion net/ax25/ax25_uid.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ static void ax25_uid_seq_stop(struct seq_file *seq, void *v)

static int ax25_uid_seq_show(struct seq_file *seq, void *v)
{
char buf[11];

if (v == SEQ_START_TOKEN)
seq_printf(seq, "Policy: %d\n", ax25_uid_policy);
else {
struct ax25_uid_assoc *pt = v;

seq_printf(seq, "%6d %s\n", pt->uid, ax2asc(&pt->call));
seq_printf(seq, "%6d %s\n", pt->uid, ax2asc(buf, &pt->call));
}
return 0;
}
Expand Down
7 changes: 4 additions & 3 deletions net/netrom/af_netrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@ static int nr_info_show(struct seq_file *seq, void *v)
struct net_device *dev;
struct nr_sock *nr;
const char *devname;
char buf[11];

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

seq_printf(seq, "%-9s ", ax2asc(&nr->user_addr));
seq_printf(seq, "%-9s ", ax2asc(&nr->dest_addr));
seq_printf(seq, "%-9s ", ax2asc(buf, &nr->user_addr));
seq_printf(seq, "%-9s ", ax2asc(buf, &nr->dest_addr));
seq_printf(seq,
"%-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",
ax2asc(&nr->source_addr),
ax2asc(buf, &nr->source_addr),
devname,
nr->my_index,
nr->my_id,
Expand Down
8 changes: 5 additions & 3 deletions net/netrom/nr_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ static void nr_node_stop(struct seq_file *seq, void *v)

static int nr_node_show(struct seq_file *seq, void *v)
{
char buf[11];
int i;

if (v == SEQ_START_TOKEN)
Expand All @@ -890,7 +891,7 @@ static int nr_node_show(struct seq_file *seq, void *v)
struct nr_node *nr_node = v;
nr_node_lock(nr_node);
seq_printf(seq, "%-9s %-7s %d %d",
ax2asc(&nr_node->callsign),
ax2asc(buf, &nr_node->callsign),
(nr_node->mnemonic[0] == '\0') ? "*" : nr_node->mnemonic,
nr_node->which + 1,
nr_node->count);
Expand Down Expand Up @@ -964,6 +965,7 @@ static void nr_neigh_stop(struct seq_file *seq, void *v)

static int nr_neigh_show(struct seq_file *seq, void *v)
{
char buf[11];
int i;

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

seq_printf(seq, "%05d %-9s %-4s %3d %d %3d %3d",
nr_neigh->number,
ax2asc(&nr_neigh->callsign),
ax2asc(buf, &nr_neigh->callsign),
nr_neigh->dev ? nr_neigh->dev->name : "???",
nr_neigh->quality,
nr_neigh->locked,
Expand All @@ -983,7 +985,7 @@ static int nr_neigh_show(struct seq_file *seq, void *v)
if (nr_neigh->digipeat != NULL) {
for (i = 0; i < nr_neigh->digipeat->ndigi; i++)
seq_printf(seq, " %s",
ax2asc(&nr_neigh->digipeat->calls[i]));
ax2asc(buf, &nr_neigh->digipeat->calls[i]));
}

seq_puts(seq, "\n");
Expand Down
6 changes: 4 additions & 2 deletions net/rose/af_rose.c
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,8 @@ static void rose_info_stop(struct seq_file *seq, void *v)

static int rose_info_show(struct seq_file *seq, void *v)
{
char buf[11];

if (v == SEQ_START_TOKEN)
seq_puts(seq,
"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");
Expand All @@ -1380,12 +1382,12 @@ static int rose_info_show(struct seq_file *seq, void *v)

seq_printf(seq, "%-10s %-9s ",
rose2asc(&rose->dest_addr),
ax2asc(&rose->dest_call));
ax2asc(buf, &rose->dest_call));

if (ax25cmp(&rose->source_call, &null_ax25_address) == 0)
callsign = "??????-?";
else
callsign = ax2asc(&rose->source_call);
callsign = ax2asc(buf, &rose->source_call);

seq_printf(seq,
"%-10s %-9s %-5s %3.3X %05d %d %d %d %d %3lu %3lu %3lu %3lu %3lu %3lu/%03lu %5d %5d %ld\n",
Expand Down
14 changes: 9 additions & 5 deletions net/rose/rose_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
unsigned char cause, diagnostic;
struct net_device *dev;
int len, res = 0;
char buf[11];

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

if (rose_neigh == NULL) {
printk("rose_route : unknown neighbour or device %s\n",
ax2asc(&ax25->dest_addr));
ax2asc(buf, &ax25->dest_addr));
goto out;
}

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

static int rose_neigh_show(struct seq_file *seq, void *v)
{
char buf[11];
int i;

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

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

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

static int rose_route_show(struct seq_file *seq, void *v)
{
char buf[11];

if (v == SEQ_START_TOKEN)
seq_puts(seq,
"lci address callsign neigh <-> lci address callsign neigh\n");
Expand All @@ -1271,7 +1275,7 @@ static int rose_route_show(struct seq_file *seq, void *v)
"%3.3X %-10s %-9s %05d ",
rose_route->lci1,
rose2asc(&rose_route->src_addr),
ax2asc(&rose_route->src_call),
ax2asc(buf, &rose_route->src_call),
rose_route->neigh1->number);
else
seq_puts(seq,
Expand All @@ -1282,7 +1286,7 @@ static int rose_route_show(struct seq_file *seq, void *v)
"%3.3X %-10s %-9s %05d\n",
rose_route->lci2,
rose2asc(&rose_route->dest_addr),
ax2asc(&rose_route->dest_call),
ax2asc(buf, &rose_route->dest_call),
rose_route->neigh2->number);
else
seq_puts(seq,
Expand Down
5 changes: 3 additions & 2 deletions net/rose/rose_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ static int rose_create_facilities(unsigned char *buffer, struct rose_sock *rose)
{
unsigned char *p = buffer + 1;
char *callsign;
char buf[11];
int len, nb;

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

*p++ = FAC_CCITT_DEST_NSAP;

callsign = ax2asc(&rose->dest_call);
callsign = ax2asc(buf, &rose->dest_call);

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

*p++ = FAC_CCITT_SRC_NSAP;

callsign = ax2asc(&rose->source_call);
callsign = ax2asc(buf, &rose->source_call);

*p++ = strlen(callsign) + 10;
*p++ = (strlen(callsign) + 9) * 2; /* ??? */
Expand Down

0 comments on commit f75268c

Please sign in to comment.