summaryrefslogtreecommitdiff
path: root/arch/sparc/kernel/ds.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2025-10-04 10:59:06 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2025-10-04 10:59:06 -0700
commitc4c8bcab18821e0c2852c38dece918512c60c732 (patch)
tree51256349df0b33592d248847a982aaccbfa99b5e /arch/sparc/kernel/ds.c
parent86bcf7be1e26f2d7277df90857d93ce0ebc11370 (diff)
parentfe0126702a40b2f3d315bc943ef10dc2f707e29d (diff)
Merge tag 'sparc-for-6.18-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/alarsson/linux-sparc
Pull sparc updates from Andreas Larsson: - Add relocation handling for R_SPARC_UA64 for sparc64 that is generated by llvm and clarify printout on missing relocation handler - Fix missing hugetlb tte initialization for sun4u - Code cleanup for redundant use of __GPF_NOWARN for sparc64 - Fix prototypes of reads[bwl]() for sparc64 by adding missing const and volatile pointer qualifiers - Fix bugs in accurate exception reporting in multiple machine specific sparc64 variants of copy_{from,to}_user() for sparc64 - Fix memory leak in error handling for sparc32 - Drop -ansi from asflags and replace __ASSEMBLY__ with __ASSEMBLER__ in headers for all arch/sparc - Replace strcpy() with strscpy() for all arch/sparc * tag 'sparc-for-6.18-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/alarsson/linux-sparc: (22 commits) sparc: Replace deprecated strcpy() with strscpy() in handle_nextprop_quirks() sparc64: Replace deprecated strcpy() with strscpy() in build_path_component() sparc: Replace deprecated strcpy() with strscpy() in prom_32.c sparc: Replace deprecated strcpy() with strscpy() in domain services driver sparc64: Replace deprecated strcpy() with strscpy() in prom_nextprop() sparc: floppy: Replace deprecated strcpy() with strscpy() in sun_floppy_init() sparc: parport: Replace deprecated strcpy() with strscpy() in ecpp_probe() sparc: PCI: Replace deprecated strcpy() with strscpy() sparc: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers sparc: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers sparc: Drop the "-ansi" from the asflags sparc: fix error handling in scan_one_device() sparc: fix accurate exception reporting in copy_{from,to}_user for M7 sparc: fix accurate exception reporting in copy_to_user for Niagara 4 sparc: fix accurate exception reporting in copy_{from_to}_user for Niagara sparc: fix accurate exception reporting in copy_{from_to}_user for UltraSPARC III sparc: fix accurate exception reporting in copy_{from_to}_user for UltraSPARC sparc64: fix prototypes of reads[bwl]() sparc64: Remove redundant __GFP_NOWARN sparc64: fix hugetlb for sun4u ...
Diffstat (limited to 'arch/sparc/kernel/ds.c')
-rw-r--r--arch/sparc/kernel/ds.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
index ffdc15588ac2..f7fc6f2af2f2 100644
--- a/arch/sparc/kernel/ds.c
+++ b/arch/sparc/kernel/ds.c
@@ -781,14 +781,17 @@ void ldom_set_var(const char *var, const char *value)
} pkt;
char *base, *p;
int msg_len, loops;
+ size_t var_len, value_len;
- if (strlen(var) + strlen(value) + 2 >
- sizeof(pkt) - sizeof(pkt.header)) {
- printk(KERN_ERR PFX
- "contents length: %zu, which more than max: %lu,"
- "so could not set (%s) variable to (%s).\n",
- strlen(var) + strlen(value) + 2,
- sizeof(pkt) - sizeof(pkt.header), var, value);
+ var_len = strlen(var) + 1;
+ value_len = strlen(value) + 1;
+
+ if (var_len + value_len > sizeof(pkt) - sizeof(pkt.header)) {
+ pr_err(PFX
+ "contents length: %zu, which more than max: %lu,"
+ "so could not set (%s) variable to (%s).\n",
+ var_len + value_len,
+ sizeof(pkt) - sizeof(pkt.header), var, value);
return;
}
@@ -797,10 +800,10 @@ void ldom_set_var(const char *var, const char *value)
pkt.header.data.handle = cp->handle;
pkt.header.msg.hdr.type = DS_VAR_SET_REQ;
base = p = &pkt.header.msg.name_and_value[0];
- strcpy(p, var);
- p += strlen(var) + 1;
- strcpy(p, value);
- p += strlen(value) + 1;
+ strscpy(p, var, var_len);
+ p += var_len;
+ strscpy(p, value, value_len);
+ p += value_len;
msg_len = (sizeof(struct ds_data) +
sizeof(struct ds_var_set_msg) +
@@ -910,7 +913,7 @@ static int register_services(struct ds_info *dp)
pbuf.req.handle = cp->handle;
pbuf.req.major = 1;
pbuf.req.minor = 0;
- strcpy(pbuf.id_buf, cp->service_id);
+ strscpy(pbuf.id_buf, cp->service_id);
err = __ds_send(lp, &pbuf, msg_len);
if (err > 0)