[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>
This commit is contained in:
parent
f2c383988d
commit
f75268cd6c
10 changed files with 39 additions and 24 deletions
|
@ -257,7 +257,7 @@ extern struct sock *ax25_make_new(struct sock *, struct ax25_dev *);
|
||||||
|
|
||||||
/* ax25_addr.c */
|
/* ax25_addr.c */
|
||||||
extern ax25_address null_ax25_address;
|
extern ax25_address null_ax25_address;
|
||||||
extern char *ax2asc(ax25_address *);
|
extern char *ax2asc(char *buf, ax25_address *);
|
||||||
extern ax25_address *asc2ax(char *);
|
extern ax25_address *asc2ax(char *);
|
||||||
extern int ax25cmp(ax25_address *, ax25_address *);
|
extern int ax25cmp(ax25_address *, ax25_address *);
|
||||||
extern int ax25digicmp(ax25_digi *, ax25_digi *);
|
extern int ax25digicmp(ax25_digi *, ax25_digi *);
|
||||||
|
|
|
@ -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)
|
static int ax25_info_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
ax25_cb *ax25 = v;
|
ax25_cb *ax25 = v;
|
||||||
|
char buf[11];
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1885,13 +1886,13 @@ static int ax25_info_show(struct seq_file *seq, void *v)
|
||||||
seq_printf(seq, "%8.8lx %s %s%s ",
|
seq_printf(seq, "%8.8lx %s %s%s ",
|
||||||
(long) ax25,
|
(long) ax25,
|
||||||
ax25->ax25_dev == NULL? "???" : ax25->ax25_dev->dev->name,
|
ax25->ax25_dev == NULL? "???" : ax25->ax25_dev->dev->name,
|
||||||
ax2asc(&ax25->source_addr),
|
ax2asc(buf, &ax25->source_addr),
|
||||||
ax25->iamdigi? "*":"");
|
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++) {
|
for (k=0; (ax25->digipeat != NULL) && (k < ax25->digipeat->ndigi); k++) {
|
||||||
seq_printf(seq, ",%s%s",
|
seq_printf(seq, ",%s%s",
|
||||||
ax2asc(&ax25->digipeat->calls[k]),
|
ax2asc(buf, &ax25->digipeat->calls[k]),
|
||||||
ax25->digipeat->repeated[k]? "*":"");
|
ax25->digipeat->repeated[k]? "*":"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,8 @@ ax25_address null_ax25_address = {{0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00}};
|
||||||
/*
|
/*
|
||||||
* ax25 -> ascii conversion
|
* ax25 -> ascii conversion
|
||||||
*/
|
*/
|
||||||
char *ax2asc(ax25_address *a)
|
char *ax2asc(char *buf, ax25_address *a)
|
||||||
{
|
{
|
||||||
static char buf[11];
|
|
||||||
char c, *s;
|
char c, *s;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
|
|
@ -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)
|
static int ax25_rt_seq_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
|
char buf[11];
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN)
|
if (v == SEQ_START_TOKEN)
|
||||||
seq_puts(seq, "callsign dev mode digipeaters\n");
|
seq_puts(seq, "callsign dev mode digipeaters\n");
|
||||||
else {
|
else {
|
||||||
|
@ -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)
|
if (ax25cmp(&ax25_rt->callsign, &null_ax25_address) == 0)
|
||||||
callsign = "default";
|
callsign = "default";
|
||||||
else
|
else
|
||||||
callsign = ax2asc(&ax25_rt->callsign);
|
callsign = ax2asc(buf, &ax25_rt->callsign);
|
||||||
|
|
||||||
seq_printf(seq, "%-9s %-4s",
|
seq_printf(seq, "%-9s %-4s",
|
||||||
callsign,
|
callsign,
|
||||||
|
@ -328,7 +330,8 @@ static int ax25_rt_seq_show(struct seq_file *seq, void *v)
|
||||||
|
|
||||||
if (ax25_rt->digipeat != NULL)
|
if (ax25_rt->digipeat != NULL)
|
||||||
for (i = 0; i < ax25_rt->digipeat->ndigi; i++)
|
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");
|
seq_puts(seq, "\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
static int ax25_uid_seq_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
|
char buf[11];
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN)
|
if (v == SEQ_START_TOKEN)
|
||||||
seq_printf(seq, "Policy: %d\n", ax25_uid_policy);
|
seq_printf(seq, "Policy: %d\n", ax25_uid_policy);
|
||||||
else {
|
else {
|
||||||
struct ax25_uid_assoc *pt = v;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1261,6 +1261,7 @@ static int nr_info_show(struct seq_file *seq, void *v)
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
struct nr_sock *nr;
|
struct nr_sock *nr;
|
||||||
const char *devname;
|
const char *devname;
|
||||||
|
char buf[11];
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN)
|
if (v == SEQ_START_TOKEN)
|
||||||
seq_puts(seq,
|
seq_puts(seq,
|
||||||
|
@ -1276,11 +1277,11 @@ static int nr_info_show(struct seq_file *seq, void *v)
|
||||||
else
|
else
|
||||||
devname = dev->name;
|
devname = dev->name;
|
||||||
|
|
||||||
seq_printf(seq, "%-9s ", ax2asc(&nr->user_addr));
|
seq_printf(seq, "%-9s ", ax2asc(buf, &nr->user_addr));
|
||||||
seq_printf(seq, "%-9s ", ax2asc(&nr->dest_addr));
|
seq_printf(seq, "%-9s ", ax2asc(buf, &nr->dest_addr));
|
||||||
seq_printf(seq,
|
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",
|
"%-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,
|
devname,
|
||||||
nr->my_index,
|
nr->my_index,
|
||||||
nr->my_id,
|
nr->my_id,
|
||||||
|
|
|
@ -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)
|
static int nr_node_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
|
char buf[11];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN)
|
if (v == SEQ_START_TOKEN)
|
||||||
|
@ -890,7 +891,7 @@ static int nr_node_show(struct seq_file *seq, void *v)
|
||||||
struct nr_node *nr_node = v;
|
struct nr_node *nr_node = v;
|
||||||
nr_node_lock(nr_node);
|
nr_node_lock(nr_node);
|
||||||
seq_printf(seq, "%-9s %-7s %d %d",
|
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->mnemonic[0] == '\0') ? "*" : nr_node->mnemonic,
|
||||||
nr_node->which + 1,
|
nr_node->which + 1,
|
||||||
nr_node->count);
|
nr_node->count);
|
||||||
|
@ -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)
|
static int nr_neigh_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
|
char buf[11];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN)
|
if (v == SEQ_START_TOKEN)
|
||||||
|
@ -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",
|
seq_printf(seq, "%05d %-9s %-4s %3d %d %3d %3d",
|
||||||
nr_neigh->number,
|
nr_neigh->number,
|
||||||
ax2asc(&nr_neigh->callsign),
|
ax2asc(buf, &nr_neigh->callsign),
|
||||||
nr_neigh->dev ? nr_neigh->dev->name : "???",
|
nr_neigh->dev ? nr_neigh->dev->name : "???",
|
||||||
nr_neigh->quality,
|
nr_neigh->quality,
|
||||||
nr_neigh->locked,
|
nr_neigh->locked,
|
||||||
|
@ -983,7 +985,7 @@ static int nr_neigh_show(struct seq_file *seq, void *v)
|
||||||
if (nr_neigh->digipeat != NULL) {
|
if (nr_neigh->digipeat != NULL) {
|
||||||
for (i = 0; i < nr_neigh->digipeat->ndigi; i++)
|
for (i = 0; i < nr_neigh->digipeat->ndigi; i++)
|
||||||
seq_printf(seq, " %s",
|
seq_printf(seq, " %s",
|
||||||
ax2asc(&nr_neigh->digipeat->calls[i]));
|
ax2asc(buf, &nr_neigh->digipeat->calls[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
seq_puts(seq, "\n");
|
seq_puts(seq, "\n");
|
||||||
|
|
|
@ -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)
|
static int rose_info_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
|
char buf[11];
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN)
|
if (v == SEQ_START_TOKEN)
|
||||||
seq_puts(seq,
|
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");
|
"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)
|
||||||
|
|
||||||
seq_printf(seq, "%-10s %-9s ",
|
seq_printf(seq, "%-10s %-9s ",
|
||||||
rose2asc(&rose->dest_addr),
|
rose2asc(&rose->dest_addr),
|
||||||
ax2asc(&rose->dest_call));
|
ax2asc(buf, &rose->dest_call));
|
||||||
|
|
||||||
if (ax25cmp(&rose->source_call, &null_ax25_address) == 0)
|
if (ax25cmp(&rose->source_call, &null_ax25_address) == 0)
|
||||||
callsign = "??????-?";
|
callsign = "??????-?";
|
||||||
else
|
else
|
||||||
callsign = ax2asc(&rose->source_call);
|
callsign = ax2asc(buf, &rose->source_call);
|
||||||
|
|
||||||
seq_printf(seq,
|
seq_printf(seq,
|
||||||
"%-10s %-9s %-5s %3.3X %05d %d %d %d %d %3lu %3lu %3lu %3lu %3lu %3lu/%03lu %5d %5d %ld\n",
|
"%-10s %-9s %-5s %3.3X %05d %d %d %d %d %3lu %3lu %3lu %3lu %3lu %3lu/%03lu %5d %5d %ld\n",
|
||||||
|
|
|
@ -851,6 +851,7 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
|
||||||
unsigned char cause, diagnostic;
|
unsigned char cause, diagnostic;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
int len, res = 0;
|
int len, res = 0;
|
||||||
|
char buf[11];
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (call_in_firewall(PF_ROSE, skb->dev, skb->data, NULL, &skb) != FW_ACCEPT)
|
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)
|
||||||
|
|
||||||
if (rose_neigh == NULL) {
|
if (rose_neigh == NULL) {
|
||||||
printk("rose_route : unknown neighbour or device %s\n",
|
printk("rose_route : unknown neighbour or device %s\n",
|
||||||
ax2asc(&ax25->dest_addr));
|
ax2asc(buf, &ax25->dest_addr));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)
|
static int rose_neigh_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
|
char buf[11];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN)
|
if (v == SEQ_START_TOKEN)
|
||||||
|
@ -1189,7 +1191,7 @@ static int rose_neigh_show(struct seq_file *seq, void *v)
|
||||||
/* if (!rose_neigh->loopback) { */
|
/* if (!rose_neigh->loopback) { */
|
||||||
seq_printf(seq, "%05d %-9s %-4s %3d %3d %3s %3s %3lu %3lu",
|
seq_printf(seq, "%05d %-9s %-4s %3d %3d %3s %3s %3lu %3lu",
|
||||||
rose_neigh->number,
|
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->dev ? rose_neigh->dev->name : "???",
|
||||||
rose_neigh->count,
|
rose_neigh->count,
|
||||||
rose_neigh->use,
|
rose_neigh->use,
|
||||||
|
@ -1200,7 +1202,7 @@ static int rose_neigh_show(struct seq_file *seq, void *v)
|
||||||
|
|
||||||
if (rose_neigh->digipeat != NULL) {
|
if (rose_neigh->digipeat != NULL) {
|
||||||
for (i = 0; i < rose_neigh->digipeat->ndigi; i++)
|
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");
|
seq_puts(seq, "\n");
|
||||||
|
@ -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)
|
static int rose_route_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
|
char buf[11];
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN)
|
if (v == SEQ_START_TOKEN)
|
||||||
seq_puts(seq,
|
seq_puts(seq,
|
||||||
"lci address callsign neigh <-> lci address callsign neigh\n");
|
"lci address callsign neigh <-> lci address callsign neigh\n");
|
||||||
|
@ -1271,7 +1275,7 @@ static int rose_route_show(struct seq_file *seq, void *v)
|
||||||
"%3.3X %-10s %-9s %05d ",
|
"%3.3X %-10s %-9s %05d ",
|
||||||
rose_route->lci1,
|
rose_route->lci1,
|
||||||
rose2asc(&rose_route->src_addr),
|
rose2asc(&rose_route->src_addr),
|
||||||
ax2asc(&rose_route->src_call),
|
ax2asc(buf, &rose_route->src_call),
|
||||||
rose_route->neigh1->number);
|
rose_route->neigh1->number);
|
||||||
else
|
else
|
||||||
seq_puts(seq,
|
seq_puts(seq,
|
||||||
|
@ -1282,7 +1286,7 @@ static int rose_route_show(struct seq_file *seq, void *v)
|
||||||
"%3.3X %-10s %-9s %05d\n",
|
"%3.3X %-10s %-9s %05d\n",
|
||||||
rose_route->lci2,
|
rose_route->lci2,
|
||||||
rose2asc(&rose_route->dest_addr),
|
rose2asc(&rose_route->dest_addr),
|
||||||
ax2asc(&rose_route->dest_call),
|
ax2asc(buf, &rose_route->dest_call),
|
||||||
rose_route->neigh2->number);
|
rose_route->neigh2->number);
|
||||||
else
|
else
|
||||||
seq_puts(seq,
|
seq_puts(seq,
|
||||||
|
|
|
@ -400,6 +400,7 @@ static int rose_create_facilities(unsigned char *buffer, struct rose_sock *rose)
|
||||||
{
|
{
|
||||||
unsigned char *p = buffer + 1;
|
unsigned char *p = buffer + 1;
|
||||||
char *callsign;
|
char *callsign;
|
||||||
|
char buf[11];
|
||||||
int len, nb;
|
int len, nb;
|
||||||
|
|
||||||
/* National Facilities */
|
/* National Facilities */
|
||||||
|
@ -456,7 +457,7 @@ static int rose_create_facilities(unsigned char *buffer, struct rose_sock *rose)
|
||||||
|
|
||||||
*p++ = FAC_CCITT_DEST_NSAP;
|
*p++ = FAC_CCITT_DEST_NSAP;
|
||||||
|
|
||||||
callsign = ax2asc(&rose->dest_call);
|
callsign = ax2asc(buf, &rose->dest_call);
|
||||||
|
|
||||||
*p++ = strlen(callsign) + 10;
|
*p++ = strlen(callsign) + 10;
|
||||||
*p++ = (strlen(callsign) + 9) * 2; /* ??? */
|
*p++ = (strlen(callsign) + 9) * 2; /* ??? */
|
||||||
|
@ -471,7 +472,7 @@ static int rose_create_facilities(unsigned char *buffer, struct rose_sock *rose)
|
||||||
|
|
||||||
*p++ = FAC_CCITT_SRC_NSAP;
|
*p++ = FAC_CCITT_SRC_NSAP;
|
||||||
|
|
||||||
callsign = ax2asc(&rose->source_call);
|
callsign = ax2asc(buf, &rose->source_call);
|
||||||
|
|
||||||
*p++ = strlen(callsign) + 10;
|
*p++ = strlen(callsign) + 10;
|
||||||
*p++ = (strlen(callsign) + 9) * 2; /* ??? */
|
*p++ = (strlen(callsign) + 9) * 2; /* ??? */
|
||||||
|
|
Loading…
Reference in a new issue