Skip to content

Commit b7c81f8

Browse files
Ychametiwai
authored andcommitted
firewire: fix potential uaf in outbound_phy_packet_callback()
&e->event and e point to the same address, and &e->event could be freed in queue_event. So there is a potential uaf issue if we dereference e after calling queue_event(). Fix this by adding a temporary variable to maintain e->client in advance, this can avoid the potential uaf issue. Cc: <stable@vger.kernel.org> Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20220409041243.603210-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 3123109 commit b7c81f8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/firewire/core-cdev.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,7 @@ static void outbound_phy_packet_callback(struct fw_packet *packet,
15001500
{
15011501
struct outbound_phy_packet_event *e =
15021502
container_of(packet, struct outbound_phy_packet_event, p);
1503+
struct client *e_client;
15031504

15041505
switch (status) {
15051506
/* expected: */
@@ -1516,9 +1517,10 @@ static void outbound_phy_packet_callback(struct fw_packet *packet,
15161517
}
15171518
e->phy_packet.data[0] = packet->timestamp;
15181519

1520+
e_client = e->client;
15191521
queue_event(e->client, &e->event, &e->phy_packet,
15201522
sizeof(e->phy_packet) + e->phy_packet.length, NULL, 0);
1521-
client_put(e->client);
1523+
client_put(e_client);
15221524
}
15231525

15241526
static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg)

0 commit comments

Comments
 (0)