Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Chengfeng Ye and committed by
Takashi Iwai
b7c81f80 31231092

+3 -1
+3 -1
drivers/firewire/core-cdev.c
··· 1500 1500 { 1501 1501 struct outbound_phy_packet_event *e = 1502 1502 container_of(packet, struct outbound_phy_packet_event, p); 1503 + struct client *e_client; 1503 1504 1504 1505 switch (status) { 1505 1506 /* expected: */ ··· 1517 1516 } 1518 1517 e->phy_packet.data[0] = packet->timestamp; 1519 1518 1519 + e_client = e->client; 1520 1520 queue_event(e->client, &e->event, &e->phy_packet, 1521 1521 sizeof(e->phy_packet) + e->phy_packet.length, NULL, 0); 1522 - client_put(e->client); 1522 + client_put(e_client); 1523 1523 } 1524 1524 1525 1525 static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg)