History

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

Linus Torvalds committed 4 years ago

Commit 65eea2c2 parents f0c5f7e e9ea0b34 files · +22 −10Browse files

Unified · Split

4 files
  1. drivers/block/xen-blkback/common.h +3 −0
  2. drivers/block/xen-blkback/xenbus.c +4 −2
  3. drivers/block/xen-blkfront.c +12 −8
  4. drivers/xen/grant-table.c +3 −0
drivers/block/xen-blkback/common.h+3−0
@@ -226,6 +226,9 @@ struct xen_vbd { · 225 unmodified lines
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+4−2
@@ -907,7 +907,7 @@ again: · 906 unmodified lines
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) · 171 unmodified lines
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+12−8
@@ -213,6 +213,9 @@ struct blkfront_info · 212 unmodified lines
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 @@ abort_transaction: · 1537 unmodified lines
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 @@ again: · 85 unmodified lines
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) · 61 unmodified lines
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) · 353 unmodified lines
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+3−0
@@ -1047,6 +1047,9 @@ int gnttab_dma_alloc_pages(struct gnttab_dma_alloc_args *args) · 1046 unmodified lines
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,