Skip to content

Commit 05519f2

Browse files
committed
Merge tag 'for-linus-6.0-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from Juergen Gross: - two minor cleanups - a fix of the xen/privcmd driver avoiding a possible NULL dereference in an error case * tag 'for-linus-6.0-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/privcmd: fix error exit of privcmd_ioctl_dm_op() xen: move from strlcpy with unused retval to strscpy xen: x86: remove setting the obsolete config XEN_MAX_DOMAIN_MEMORY
2 parents 17b28d4 + c5deb27 commit 05519f2

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

arch/x86/configs/xen.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ CONFIG_CPU_FREQ=y
1414

1515
# x86 xen specific config options
1616
CONFIG_XEN_PVH=y
17-
CONFIG_XEN_MAX_DOMAIN_MEMORY=500
1817
CONFIG_XEN_SAVE_RESTORE=y
1918
# CONFIG_XEN_DEBUG_FS is not set
2019
CONFIG_XEN_MCE_LOG=y

drivers/xen/privcmd.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -581,27 +581,30 @@ static int lock_pages(
581581
struct privcmd_dm_op_buf kbufs[], unsigned int num,
582582
struct page *pages[], unsigned int nr_pages, unsigned int *pinned)
583583
{
584-
unsigned int i;
584+
unsigned int i, off = 0;
585585

586-
for (i = 0; i < num; i++) {
586+
for (i = 0; i < num; ) {
587587
unsigned int requested;
588588
int page_count;
589589

590590
requested = DIV_ROUND_UP(
591591
offset_in_page(kbufs[i].uptr) + kbufs[i].size,
592-
PAGE_SIZE);
592+
PAGE_SIZE) - off;
593593
if (requested > nr_pages)
594594
return -ENOSPC;
595595

596596
page_count = pin_user_pages_fast(
597-
(unsigned long) kbufs[i].uptr,
597+
(unsigned long)kbufs[i].uptr + off * PAGE_SIZE,
598598
requested, FOLL_WRITE, pages);
599-
if (page_count < 0)
600-
return page_count;
599+
if (page_count <= 0)
600+
return page_count ? : -EFAULT;
601601

602602
*pinned += page_count;
603603
nr_pages -= page_count;
604604
pages += page_count;
605+
606+
off = (requested == page_count) ? 0 : off + page_count;
607+
i += !off;
605608
}
606609

607610
return 0;
@@ -677,10 +680,8 @@ static long privcmd_ioctl_dm_op(struct file *file, void __user *udata)
677680
}
678681

679682
rc = lock_pages(kbufs, kdata.num, pages, nr_pages, &pinned);
680-
if (rc < 0) {
681-
nr_pages = pinned;
683+
if (rc < 0)
682684
goto out;
683-
}
684685

685686
for (i = 0; i < kdata.num; i++) {
686687
set_xen_guest_handle(xbufs[i].h, kbufs[i].uptr);
@@ -692,7 +693,7 @@ static long privcmd_ioctl_dm_op(struct file *file, void __user *udata)
692693
xen_preemptible_hcall_end();
693694

694695
out:
695-
unlock_pages(pages, nr_pages);
696+
unlock_pages(pages, pinned);
696697
kfree(xbufs);
697698
kfree(pages);
698699
kfree(kbufs);

drivers/xen/xen-scsiback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
11211121
"%s: writing %s", __func__, state);
11221122
return;
11231123
}
1124-
strlcpy(phy, val, VSCSI_NAMELEN);
1124+
strscpy(phy, val, VSCSI_NAMELEN);
11251125
kfree(val);
11261126

11271127
/* virtual SCSI device */

drivers/xen/xenbus/xenbus_probe_frontend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static int frontend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename)
4040
return -EINVAL;
4141
}
4242

43-
strlcpy(bus_id, nodename + 1, XEN_BUS_ID_SIZE);
43+
strscpy(bus_id, nodename + 1, XEN_BUS_ID_SIZE);
4444
if (!strchr(bus_id, '/')) {
4545
pr_warn("bus_id %s no slash\n", bus_id);
4646
return -EINVAL;

0 commit comments

Comments
 (0)