Skip to content

Commit

Permalink
Merge branch 'for-next/kspp' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/kees/linux.git
  • Loading branch information
Stephen Rothwell committed Aug 1, 2023
2 parents 61d1532 + 66d882a commit 38f0880
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 19 deletions.
1 change: 0 additions & 1 deletion arch/um/include/shared/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ static inline int printk(const char *fmt, ...)
#endif

extern int in_aton(char *str);
extern size_t strlcpy(char *, const char *, size_t);
extern size_t strlcat(char *, const char *, size_t);
extern size_t strscpy(char *, const char *, size_t);

Expand Down
6 changes: 3 additions & 3 deletions arch/um/os-Linux/umid.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static int __init make_uml_dir(void)
__func__);
goto err;
}
strlcpy(dir, home, sizeof(dir));
strscpy(dir, home, sizeof(dir));
uml_dir++;
}
strlcat(dir, uml_dir, sizeof(dir));
Expand Down Expand Up @@ -243,7 +243,7 @@ int __init set_umid(char *name)
if (strlen(name) > UMID_LEN - 1)
return -E2BIG;

strlcpy(umid, name, sizeof(umid));
strscpy(umid, name, sizeof(umid));

return 0;
}
Expand All @@ -262,7 +262,7 @@ static int __init make_umid(void)
make_uml_dir();

if (*umid == '\0') {
strlcpy(tmp, uml_dir, sizeof(tmp));
strscpy(tmp, uml_dir, sizeof(tmp));
strlcat(tmp, "XXXXXX", sizeof(tmp));
fd = mkstemp(tmp);
if (fd < 0) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/eisa/eisa-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void __init eisa_name_device(struct eisa_device *edev)
int i;
for (i = 0; i < EISA_INFOS; i++) {
if (!strcmp(edev->id.sig, eisa_table[i].id.sig)) {
strlcpy(edev->pretty_name,
strscpy(edev->pretty_name,
eisa_table[i].name,
sizeof(edev->pretty_name));
return;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/platform/qcom/venus/hfi_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ int pkt_session_unset_buffers(struct hfi_session_release_buffer_pkt *pkt,

pkt->extradata_size = 0;
pkt->shdr.hdr.size =
struct_size((struct hfi_session_set_buffers_pkt *)0,
buffer_info, bd->num_buffers);
struct_size_t(struct hfi_session_set_buffers_pkt,
buffer_info, bd->num_buffers);
}

pkt->response_req = bd->response_required;
Expand Down
4 changes: 2 additions & 2 deletions drivers/soc/fsl/qe/qe.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ int qe_upload_firmware(const struct qe_firmware *firmware)
* saved microcode information and put in the new.
*/
memset(&qe_firmware_info, 0, sizeof(qe_firmware_info));
strlcpy(qe_firmware_info.id, firmware->id, sizeof(qe_firmware_info.id));
strscpy(qe_firmware_info.id, firmware->id, sizeof(qe_firmware_info.id));
qe_firmware_info.extended_modes = be64_to_cpu(firmware->extended_modes);
memcpy(qe_firmware_info.vtraps, firmware->vtraps,
sizeof(firmware->vtraps));
Expand Down Expand Up @@ -599,7 +599,7 @@ struct qe_firmware_info *qe_get_firmware_info(void)
/* Copy the data into qe_firmware_info*/
sprop = of_get_property(fw, "id", NULL);
if (sprop)
strlcpy(qe_firmware_info.id, sprop,
strscpy(qe_firmware_info.id, sprop,
sizeof(qe_firmware_info.id));

of_property_read_u64(fw, "extended-modes",
Expand Down
6 changes: 3 additions & 3 deletions fs/vboxsf/shfl_hostintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ struct shfl_string {

/** UTF-8 or UTF-16 string. Nul terminated. */
union {
u8 utf8[2];
u16 utf16[1];
u16 ucs2[1]; /* misnomer, use utf16. */
u8 legacy_padding[2];
DECLARE_FLEX_ARRAY(u8, utf8);
DECLARE_FLEX_ARRAY(u16, utf16);
} string;
};
VMMDEV_ASSERT_SIZE(shfl_string, 6);
Expand Down
7 changes: 4 additions & 3 deletions include/linux/seq_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,19 @@ static inline void seq_show_option(struct seq_file *m, const char *name,

/**
* seq_show_option_n - display mount options with appropriate escapes
* where @value must be a specific length.
* where @value must be a specific length (i.e.
* not NUL-terminated).
* @m: the seq_file handle
* @name: the mount option name
* @value: the mount option name's value, cannot be NULL
* @length: the length of @value to display
* @length: the exact length of @value to display, must be constant expression
*
* This is a macro since this uses "length" to define the size of the
* stack buffer.
*/
#define seq_show_option_n(m, name, value, length) { \
char val_buf[length + 1]; \
strncpy(val_buf, value, length); \
memcpy(val_buf, value, length); \
val_buf[length] = '\0'; \
seq_show_option(m, name, val_buf); \
}
Expand Down
6 changes: 3 additions & 3 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -8249,7 +8249,7 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)
unsigned int size;

memset(comm, 0, sizeof(comm));
strlcpy(comm, comm_event->task->comm, sizeof(comm));
strscpy(comm, comm_event->task->comm, sizeof(comm));
size = ALIGN(strlen(comm)+1, sizeof(u64));

comm_event->comm = comm;
Expand Down Expand Up @@ -8693,7 +8693,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
}

cpy_name:
strlcpy(tmp, name, sizeof(tmp));
strscpy(tmp, name, sizeof(tmp));
name = tmp;
got_name:
/*
Expand Down Expand Up @@ -9117,7 +9117,7 @@ void perf_event_ksymbol(u16 ksym_type, u64 addr, u32 len, bool unregister,
ksym_type == PERF_RECORD_KSYMBOL_TYPE_UNKNOWN)
goto err;

strlcpy(name, sym, KSYM_NAME_LEN);
strscpy(name, sym, KSYM_NAME_LEN);
name_len = strlen(name) + 1;
while (!IS_ALIGNED(name_len, sizeof(u64)))
name[name_len++] = '\0';
Expand Down
10 changes: 9 additions & 1 deletion lib/Kconfig.ubsan
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ menuconfig UBSAN
if UBSAN

config UBSAN_TRAP
bool "On Sanitizer warnings, abort the running kernel code"
bool "Abort on Sanitizer warnings (smaller kernel but less verbose)"
depends on !COMPILE_TEST
help
Building kernels with Sanitizer features enabled tends to grow
Expand All @@ -26,6 +26,14 @@ config UBSAN_TRAP
the system. For some system builders this is an acceptable
trade-off.

Also note that selecting Y will cause your kernel to Oops
with an "illegal instruction" error with no further details
when a UBSAN violation occurs. (Except on arm64, which will
report which Sanitizer failed.) This may make it hard to
determine whether an Oops was caused by UBSAN or to figure
out the details of a UBSAN violation. It makes the kernel log
output less useful for bug reports.

config CC_HAS_UBSAN_BOUNDS_STRICT
def_bool $(cc-option,-fsanitize=bounds-strict)
help
Expand Down

0 comments on commit 38f0880

Please sign in to comment.