Skip to content

Commit 31185df

Browse files
committed
xen/netfront: don't use gnttab_query_foreign_access() for mapped status
It isn't enough to check whether a grant is still being in use by calling gnttab_query_foreign_access(), as a mapping could be realized by the other side just after having called that function. In case the call was done in preparation of revoking a grant it is better to do so via gnttab_end_foreign_access_ref() and check the success of that operation instead. This is CVE-2022-23037 / part of XSA-396. Reported-by: Demi Marie Obenour <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Jan Beulich <[email protected]> --- V2: - use gnttab_try_end_foreign_access() V3: - don't use gnttab_try_end_foreign_access()
1 parent abf1fd5 commit 31185df

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/net/xen-netfront.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,12 @@ static bool xennet_tx_buf_gc(struct netfront_queue *queue)
424424
queue->tx_link[id] = TX_LINK_NONE;
425425
skb = queue->tx_skbs[id];
426426
queue->tx_skbs[id] = NULL;
427-
if (unlikely(gnttab_query_foreign_access(
428-
queue->grant_tx_ref[id]) != 0)) {
427+
if (unlikely(!gnttab_end_foreign_access_ref(
428+
queue->grant_tx_ref[id], GNTMAP_readonly))) {
429429
dev_alert(dev,
430430
"Grant still in use by backend domain\n");
431431
goto err;
432432
}
433-
gnttab_end_foreign_access_ref(
434-
queue->grant_tx_ref[id], GNTMAP_readonly);
435433
gnttab_release_grant_reference(
436434
&queue->gref_tx_head, queue->grant_tx_ref[id]);
437435
queue->grant_tx_ref[id] = GRANT_INVALID_REF;

0 commit comments

Comments
 (0)