Skip to content

Commit 65eea2c

Browse files
committed
Merge tag 'for-linus-6.0-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from Juergen Gross: - a minor fix for the Xen grant driver - a small series fixing a recently introduced problem in the Xen blkfront/blkback drivers with negotiation of feature usage * tag 'for-linus-6.0-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/grants: prevent integer overflow in gnttab_dma_alloc_pages() xen-blkfront: Cache feature_persistent value before advertisement xen-blkfront: Advertise feature-persistent as user requested xen-blkback: Advertise feature-persistent as user requested
2 parents f0c5f7e + e9ea0b3 commit 65eea2c

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

drivers/block/xen-blkback/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ struct xen_vbd {
226226
sector_t size;
227227
unsigned int flush_support:1;
228228
unsigned int discard_secure:1;
229+
/* Connect-time cached feature_persistent parameter value */
230+
unsigned int feature_gnt_persistent_parm:1;
231+
/* Persistent grants feature negotiation result */
229232
unsigned int feature_gnt_persistent:1;
230233
unsigned int overflow_max_grants:1;
231234
};

drivers/block/xen-blkback/xenbus.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ static void connect(struct backend_info *be)
907907
xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
908908

909909
err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u",
910-
be->blkif->vbd.feature_gnt_persistent);
910+
be->blkif->vbd.feature_gnt_persistent_parm);
911911
if (err) {
912912
xenbus_dev_fatal(dev, err, "writing %s/feature-persistent",
913913
dev->nodename);
@@ -1085,7 +1085,9 @@ static int connect_ring(struct backend_info *be)
10851085
return -ENOSYS;
10861086
}
10871087

1088-
blkif->vbd.feature_gnt_persistent = feature_persistent &&
1088+
blkif->vbd.feature_gnt_persistent_parm = feature_persistent;
1089+
blkif->vbd.feature_gnt_persistent =
1090+
blkif->vbd.feature_gnt_persistent_parm &&
10891091
xenbus_read_unsigned(dev->otherend, "feature-persistent", 0);
10901092

10911093
blkif->vbd.overflow_max_grants = 0;

drivers/block/xen-blkfront.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ struct blkfront_info
213213
unsigned int feature_fua:1;
214214
unsigned int feature_discard:1;
215215
unsigned int feature_secdiscard:1;
216+
/* Connect-time cached feature_persistent parameter */
217+
unsigned int feature_persistent_parm:1;
218+
/* Persistent grants feature negotiation result */
216219
unsigned int feature_persistent:1;
217220
unsigned int bounce:1;
218221
unsigned int discard_granularity;
@@ -1756,6 +1759,12 @@ static int write_per_ring_nodes(struct xenbus_transaction xbt,
17561759
return err;
17571760
}
17581761

1762+
/* Enable the persistent grants feature. */
1763+
static bool feature_persistent = true;
1764+
module_param(feature_persistent, bool, 0644);
1765+
MODULE_PARM_DESC(feature_persistent,
1766+
"Enables the persistent grants feature");
1767+
17591768
/* Common code used when first setting up, and when resuming. */
17601769
static int talk_to_blkback(struct xenbus_device *dev,
17611770
struct blkfront_info *info)
@@ -1847,8 +1856,9 @@ static int talk_to_blkback(struct xenbus_device *dev,
18471856
message = "writing protocol";
18481857
goto abort_transaction;
18491858
}
1859+
info->feature_persistent_parm = feature_persistent;
18501860
err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u",
1851-
info->feature_persistent);
1861+
info->feature_persistent_parm);
18521862
if (err)
18531863
dev_warn(&dev->dev,
18541864
"writing persistent grants feature to xenbus");
@@ -1916,12 +1926,6 @@ static int negotiate_mq(struct blkfront_info *info)
19161926
return 0;
19171927
}
19181928

1919-
/* Enable the persistent grants feature. */
1920-
static bool feature_persistent = true;
1921-
module_param(feature_persistent, bool, 0644);
1922-
MODULE_PARM_DESC(feature_persistent,
1923-
"Enables the persistent grants feature");
1924-
19251929
/*
19261930
* Entry point to this code when a new device is created. Allocate the basic
19271931
* structures and the ring buffer for communication with the backend, and
@@ -2281,7 +2285,7 @@ static void blkfront_gather_backend_features(struct blkfront_info *info)
22812285
if (xenbus_read_unsigned(info->xbdev->otherend, "feature-discard", 0))
22822286
blkfront_setup_discard(info);
22832287

2284-
if (feature_persistent)
2288+
if (info->feature_persistent_parm)
22852289
info->feature_persistent =
22862290
!!xenbus_read_unsigned(info->xbdev->otherend,
22872291
"feature-persistent", 0);

drivers/xen/grant-table.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,9 @@ int gnttab_dma_alloc_pages(struct gnttab_dma_alloc_args *args)
10471047
size_t size;
10481048
int i, ret;
10491049

1050+
if (args->nr_pages < 0 || args->nr_pages > (INT_MAX >> PAGE_SHIFT))
1051+
return -ENOMEM;
1052+
10501053
size = args->nr_pages << PAGE_SHIFT;
10511054
if (args->coherent)
10521055
args->vaddr = dma_alloc_coherent(args->dev, size,

0 commit comments

Comments
 (0)