Fix a problem and slightly improve the ENOMEM handling:
Give up the entire bio as soon as we detect a problem. When we detect a problem, give up the bio by contributing the remainder with ENOMEM, rather than kicking the bio back right away. If we failed on a non-first iteration we previously could end up modifying fields in the bio after we delivered it. This could account for memory corruption (none directly reported) on machines with GBDE.
This commit is contained in:
parent
7af330a71c
commit
37f5e4a6c2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=114038
@ -720,18 +720,19 @@ g_bde_start1(struct bio *bp)
|
||||
mtx_lock(&sc->worklist_mutex);
|
||||
for(done = 0; done < bp->bio_length; ) {
|
||||
wp = g_bde_new_work(sc);
|
||||
if (wp == NULL) {
|
||||
g_io_deliver(bp, ENOMEM);
|
||||
mtx_unlock(&sc->worklist_mutex);
|
||||
return;
|
||||
if (wp != NULL) {
|
||||
wp->bp = bp;
|
||||
wp->offset = bp->bio_offset + done;
|
||||
wp->data = bp->bio_data + done;
|
||||
wp->length = bp->bio_length - done;
|
||||
g_bde_map_sector(wp);
|
||||
done += wp->length;
|
||||
g_bde_start2(wp);
|
||||
}
|
||||
if (wp == NULL || bp->bio_error != 0) {
|
||||
g_bde_contribute(bp, bp->bio_length - done, ENOMEM);
|
||||
break;
|
||||
}
|
||||
wp->bp = bp;
|
||||
wp->offset = bp->bio_offset + done;
|
||||
wp->data = bp->bio_data + done;
|
||||
wp->length = bp->bio_length - done;
|
||||
g_bde_map_sector(wp);
|
||||
done += wp->length;
|
||||
g_bde_start2(wp);
|
||||
}
|
||||
mtx_unlock(&sc->worklist_mutex);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user