Skip to content

Commit 33172ab

Browse files
committed
xen/scsifront: 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_try_end_foreign_access() and check the success of that operation instead. This is CVE-2022-23038 / 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()
1 parent 31185df commit 33172ab

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/scsi/xen-scsifront.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,11 @@ static void scsifront_gnttab_done(struct vscsifrnt_info *info,
233233
return;
234234

235235
for (i = 0; i < shadow->nr_grants; i++) {
236-
if (unlikely(gnttab_query_foreign_access(shadow->gref[i]))) {
236+
if (unlikely(!gnttab_try_end_foreign_access(shadow->gref[i]))) {
237237
shost_printk(KERN_ALERT, info->host, KBUILD_MODNAME
238238
"grant still in use by backend\n");
239239
BUG();
240240
}
241-
gnttab_end_foreign_access(shadow->gref[i], 0, 0UL);
242241
}
243242

244243
kfree(shadow->sg);

0 commit comments

Comments
 (0)