[PATCH] common: move safe_copy_string_from_guest() to lib/

Jan Beulich posted 1 patch 2 days, 13 hours ago
Failed in applying to current master (apply log)
xen/common/Makefile                            | 1 -
xen/lib/Makefile                               | 1 +
xen/{common/guestcopy.c => lib/guest-strcpy.c} | 0
3 files changed, 1 insertion(+), 1 deletion(-)
rename xen/{common/guestcopy.c => lib/guest-strcpy.c} (100%)
[PATCH] common: move safe_copy_string_from_guest() to lib/
Posted by Jan Beulich 2 days, 13 hours ago
This function is unreachable on x86 when XSM_FLASK=n, and it is another
good candidate to put in an archive.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
I question its behavior: If the guest supplied string isn't nul-
terminated, imo the input shouldn't be treated as valid, i.e. no nul
should be silently appended. This would then also eliminate the order-1
allocations which will result here if exactly PAGE_SIZE input is provided
by a guest (all callers passing PAGE_SIZE for max_size).
---
 xen/common/Makefile                            | 1 -
 xen/lib/Makefile                               | 1 +
 xen/{common/guestcopy.c => lib/guest-strcpy.c} | 0
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename xen/{common/guestcopy.c => lib/guest-strcpy.c} (100%)

diff --git a/xen/common/Makefile b/xen/common/Makefile
index dac8b711cdd3..6018e256147f 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -16,7 +16,6 @@ obj-y += event_2l.o
 obj-y += event_channel.o
 obj-$(CONFIG_EVTCHN_FIFO) += event_fifo.o
 obj-$(CONFIG_GRANT_TABLE) += grant_table.o
-obj-y += guestcopy.o
 obj-y += gzip/
 obj-$(CONFIG_HYPFS) += hypfs.o
 obj-$(CONFIG_IOREQ_SERVER) += ioreq.o
diff --git a/xen/lib/Makefile b/xen/lib/Makefile
index dcef1610b2a3..933f6d96fbb8 100644
--- a/xen/lib/Makefile
+++ b/xen/lib/Makefile
@@ -6,6 +6,7 @@ lib-y += find-next-bit.o
 lib-y += generic-ffsl.o
 lib-y += generic-flsl.o
 lib-y += generic-hweightl.o
+lib-y += guest-strcpy.o
 lib-y += list-sort.o
 lib-y += memchr.o
 lib-y += memchr_inv.o
diff --git a/xen/common/guestcopy.c b/xen/lib/guest-strcpy.c
similarity index 100%
rename from xen/common/guestcopy.c
rename to xen/lib/guest-strcpy.c
Re: [PATCH] common: move safe_copy_string_from_guest() to lib/
Posted by Orzel, Michal 1 day, 17 hours ago

On 30/03/2026 13:34, Jan Beulich wrote:
> This function is unreachable on x86 when XSM_FLASK=n, and it is another
> good candidate to put in an archive.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>

~Michal