Skip to content

Commit 1e626fd

Browse files
author
Stefan Richter
committed
firewire: core: use more outbound tlabels
Tlabel is a 6 bits wide datum. Wrap it after 63 rather than 31 for more safety against transaction label exhaustion and potential responders' transaction layer bugs. (As noted by Guus Sliepen, this change requires an expansion of tlabel_mask to 64 bits.) Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
1 parent 837ec78 commit 1e626fd

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

‎drivers/firewire/core-transaction.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int close_transaction(struct fw_transaction *transaction,
8282
list_for_each_entry(t, &card->transaction_list, link) {
8383
if (t == transaction) {
8484
list_del(&t->link);
85-
card->tlabel_mask &= ~(1 << t->tlabel);
85+
card->tlabel_mask &= ~(1ULL << t->tlabel);
8686
break;
8787
}
8888
}
@@ -288,14 +288,14 @@ void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode,
288288
spin_lock_irqsave(&card->lock, flags);
289289

290290
tlabel = card->current_tlabel;
291-
if (card->tlabel_mask & (1 << tlabel)) {
291+
if (card->tlabel_mask & (1ULL << tlabel)) {
292292
spin_unlock_irqrestore(&card->lock, flags);
293293
callback(card, RCODE_SEND_ERROR, NULL, 0, callback_data);
294294
return;
295295
}
296296

297-
card->current_tlabel = (card->current_tlabel + 1) & 0x1f;
298-
card->tlabel_mask |= (1 << tlabel);
297+
card->current_tlabel = (card->current_tlabel + 1) & 0x3f;
298+
card->tlabel_mask |= (1ULL << tlabel);
299299

300300
t->node_id = destination_id;
301301
t->tlabel = tlabel;

‎include/linux/firewire.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ struct fw_card {
9898

9999
int node_id;
100100
int generation;
101-
int current_tlabel, tlabel_mask;
101+
int current_tlabel;
102+
u64 tlabel_mask;
102103
struct list_head transaction_list;
103104
struct timer_list flush_timer;
104105
unsigned long reset_jiffies;

0 commit comments

Comments
 (0)