* [PATCH master 1/7] sandbox: hostfile: error out if file couldn't be opened @ 2020-09-14 10:05 Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 2/7] sandbox: add_image: support mmaping block devices on 32-bit hosts Ahmad Fatoum ` (5 more replies) 0 siblings, 6 replies; 8+ messages in thread From: Ahmad Fatoum @ 2020-09-14 10:05 UTC (permalink / raw) To: barebox; +Cc: Ahmad Fatoum The file descriptor is mandatory for doing anything useful. Error out if we don't have one. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- arch/sandbox/board/hostfile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c index 5f0d7e0a4b28..56023b4ad45d 100644 --- a/arch/sandbox/board/hostfile.c +++ b/arch/sandbox/board/hostfile.c @@ -91,6 +91,9 @@ static int hf_probe(struct device_d *dev) if (!priv->fd) priv->fd = linux_open(priv->filename, true); + if (priv->fd < 0) + return priv->fd; + priv->cdev.name = dev->device_node->name; priv->cdev.dev = dev; priv->cdev.ops = &hf_fops; -- 2.28.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH master 2/7] sandbox: add_image: support mmaping block devices on 32-bit hosts 2020-09-14 10:05 [PATCH master 1/7] sandbox: hostfile: error out if file couldn't be opened Ahmad Fatoum @ 2020-09-14 10:05 ` Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 3/7] sandbox: support escaping commas in --image filenames Ahmad Fatoum ` (4 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Ahmad Fatoum @ 2020-09-14 10:05 UTC (permalink / raw) To: barebox; +Cc: Ahmad Fatoum BLKGETSIZE64 writes 64-bit to the address pointed at by the ioctl argument. As hf->size is a 32-bit size_t on 32-bit systems, on such systems, the adjacent member might be corrupted. Fix this. Fixes: 8d6da6462b12 ("sandbox: add_image: mmap block devices") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- arch/sandbox/board/dtb.c | 2 +- arch/sandbox/board/hostfile.c | 1 + arch/sandbox/dts/sandbox-state-example.dtsi | 2 +- arch/sandbox/dts/skeleton.dtsi | 4 ++-- arch/sandbox/mach-sandbox/include/mach/hostfile.h | 2 +- arch/sandbox/os/common.c | 10 +++++++--- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/sandbox/board/dtb.c b/arch/sandbox/board/dtb.c index 74ecbadf4217..d11bde0249bd 100644 --- a/arch/sandbox/board/dtb.c +++ b/arch/sandbox/board/dtb.c @@ -46,7 +46,7 @@ static int of_sandbox_init(void) if (ret) return ret; - ret = of_property_write_u32(root, "#size-cells", 1); + ret = of_property_write_u32(root, "#size-cells", 2); if (ret) return ret; } diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c index 56023b4ad45d..07287fc0b4a1 100644 --- a/arch/sandbox/board/hostfile.c +++ b/arch/sandbox/board/hostfile.c @@ -134,6 +134,7 @@ static int of_hostfile_fixup(struct device_node *root, void *ctx) uint32_t reg[] = { hf->base >> 32, hf->base, + hf->size >> 32, hf->size }; int ret; diff --git a/arch/sandbox/dts/sandbox-state-example.dtsi b/arch/sandbox/dts/sandbox-state-example.dtsi index fc17bd078899..98640f6677cf 100644 --- a/arch/sandbox/dts/sandbox-state-example.dtsi +++ b/arch/sandbox/dts/sandbox-state-example.dtsi @@ -6,7 +6,7 @@ disk { compatible = "barebox,hostfile"; barebox,filename = "disk"; - reg = <0x0 0x0 0x100000>; + reg = <0x0 0x0 0x0 0x100000>; partitions { compatible = "fixed-partitions"; diff --git a/arch/sandbox/dts/skeleton.dtsi b/arch/sandbox/dts/skeleton.dtsi index 38ead821bb42..8ba7663eb5c0 100644 --- a/arch/sandbox/dts/skeleton.dtsi +++ b/arch/sandbox/dts/skeleton.dtsi @@ -6,8 +6,8 @@ / { #address-cells = <2>; - #size-cells = <1>; + #size-cells = <2>; chosen { }; aliases { }; - memory { device_type = "memory"; reg = <0 0 0>; }; + memory { device_type = "memory"; reg = <0 0 0 0>; }; }; diff --git a/arch/sandbox/mach-sandbox/include/mach/hostfile.h b/arch/sandbox/mach-sandbox/include/mach/hostfile.h index 54f690be5f7f..e2f44c4f7b0c 100644 --- a/arch/sandbox/mach-sandbox/include/mach/hostfile.h +++ b/arch/sandbox/mach-sandbox/include/mach/hostfile.h @@ -4,7 +4,7 @@ struct hf_info { int fd; unsigned long long base; - size_t size; + unsigned long long size; const char *devname; const char *filename; }; diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 69fadb3b47a4..9f26f8fa6e9a 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -267,9 +267,13 @@ static int add_image(char *str, char *devname_template, int *devname_number) goto err_out; } } - hf->base = (unsigned long)mmap(NULL, hf->size, - PROT_READ | (readonly ? 0 : PROT_WRITE), - MAP_SHARED, fd, 0); + if (hf->size <= SIZE_MAX) + hf->base = (unsigned long)mmap(NULL, hf->size, + PROT_READ | (readonly ? 0 : PROT_WRITE), + MAP_SHARED, fd, 0); + else + printf("warning: %s: contiguous map failed\n", filename); + if (hf->base == (unsigned long)MAP_FAILED) printf("warning: mmapping %s failed: %s\n", filename, strerror(errno)); -- 2.28.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH master 3/7] sandbox: support escaping commas in --image filenames 2020-09-14 10:05 [PATCH master 1/7] sandbox: hostfile: error out if file couldn't be opened Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 2/7] sandbox: add_image: support mmaping block devices on 32-bit hosts Ahmad Fatoum @ 2020-09-14 10:05 ` Ahmad Fatoum 2020-09-14 13:42 ` Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 4/7] readkey: fix buffer overflow handling longer escape sequences Ahmad Fatoum ` (3 subsequent siblings) 5 siblings, 1 reply; 8+ messages in thread From: Ahmad Fatoum @ 2020-09-14 10:05 UTC (permalink / raw) To: barebox; +Cc: Ahmad Fatoum Some tools like afl-fuzz generate file names containing commas. Allow escaping the commas in the file names, so they can be passed to barebox. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- arch/sandbox/os/common.c | 10 ++++++---- include/linux/string.h | 1 + lib/string.c | 43 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 9f26f8fa6e9a..437fe3ecdff8 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -212,6 +212,8 @@ int linux_execve(const char * filename, char *const argv[], char *const envp[]) extern void start_barebox(void); extern void mem_malloc_init(void *start, void *end); +extern char * strsep_unescaped(char **s, const char *ct); + static int add_image(char *str, char *devname_template, int *devname_number) { struct hf_info *hf = malloc(sizeof(struct hf_info)); @@ -225,15 +227,15 @@ static int add_image(char *str, char *devname_template, int *devname_number) if (!hf) return -1; - filename = strtok(str, ","); - while ((opt = strtok(NULL, ","))) { + filename = strsep_unescaped(&str, ","); + while ((opt = strsep_unescaped(&str, ","))) { if (!strcmp(opt, "ro")) readonly = 1; } /* parses: "devname=filename" */ - devname = strtok(filename, "="); - filename = strtok(NULL, "="); + devname = strsep_unescaped(&filename, "="); + filename = strsep_unescaped(&filename, "="); if (!filename) { filename = devname; snprintf(tmp, sizeof(tmp), diff --git a/include/linux/string.h b/include/linux/string.h index fd42f5020a07..763ef500e574 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -12,6 +12,7 @@ extern char * ___strtok; extern char * strpbrk(const char *,const char *); extern char * strtok(char *,const char *); extern char * strsep(char **,const char *); +extern char * strsep_unescaped(char **,const char *); extern __kernel_size_t strspn(const char *,const char *); diff --git a/lib/string.c b/lib/string.c index 7548fd35810b..50f8e2f87c9f 100644 --- a/lib/string.c +++ b/lib/string.c @@ -455,6 +455,49 @@ char * strsep(char **s, const char *ct) #endif EXPORT_SYMBOL(strsep); +/** + * strsep_unescaped - Split a string into tokens, while ignoring escaped delimiters + * @s: The string to be searched + * @ct: The delimiter characters to search for + * + * strsep_unescaped() behaves like strsep unless it meets an escaped delimiter. + * In that case, it shifts the string back in memory to overwrite the escape's + * backslash then continues the search until an unescaped delimiter is found. + */ +char *strsep_unescaped(char **s, const char *ct) +{ + char *sbegin = *s, *hay; + const char *needle; + size_t shift = 0; + + if (sbegin == NULL) + return NULL; + + for (hay = sbegin; *hay != '\0'; ++hay) { + *hay = hay[shift]; + + if (*hay == '\\') { + *hay = hay[++shift]; + if (*hay != '\\') + continue; + } + + for (needle = ct; *needle != '\0'; ++needle) { + if (*hay == *needle) + goto match; + } + } + + *s = NULL; + return sbegin; + +match: + *hay = '\0'; + *s = &hay[shift + 1]; + + return sbegin; +} + #ifndef __HAVE_ARCH_STRSWAB /** * strswab - swap adjacent even and odd bytes in %NUL-terminated string -- 2.28.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH master 3/7] sandbox: support escaping commas in --image filenames 2020-09-14 10:05 ` [PATCH master 3/7] sandbox: support escaping commas in --image filenames Ahmad Fatoum @ 2020-09-14 13:42 ` Ahmad Fatoum 0 siblings, 0 replies; 8+ messages in thread From: Ahmad Fatoum @ 2020-09-14 13:42 UTC (permalink / raw) To: Ahmad Fatoum, barebox On 9/14/20 12:05 PM, Ahmad Fatoum wrote: > Some tools like afl-fuzz generate file names containing commas. > Allow escaping the commas in the file names, so they can be passed > to barebox. /* Unit tests for strsep_unescaped */ #include <stdio.h> #include <string.h> #include <assert.h> char *strsep_unescaped(char **s, const char *ct) { char *sbegin = *s, *hay; const char *needle; size_t shift = 0; if (sbegin == NULL) return NULL; for (hay = sbegin; *hay != '\0'; ++hay) { *hay = hay[shift]; if (*hay == '\\') { *hay = hay[++shift]; if (*hay != '\\') continue; } for (needle = ct; *needle != '\0'; ++needle) { if (*hay == *needle) goto match; } } *s = NULL; return sbegin; match: *hay = '\0'; *s = &hay[shift + 1]; return sbegin; } static _Bool streq(const char *a, const char *b) { if (a == NULL || b == NULL) return a == b; return strcmp(a, b) == 0; } #define ensure(_s, d, ...) do { \ char *expected[] = { __VA_ARGS__, NULL }; \ char *tok; \ char *s = strdup(_s); \ int i = 0; \ while ((tok = strsep_unescaped(&s, d))) { \ printf("'%s' <> '%s'?\n", tok, expected[i]); \ assert(streq(tok, expected[i])); \ i++; \ } \ } while (0) int main(int argc, char *argv[]) { setbuf(stdout, NULL); ensure("aaa", ",", /* => */ "aaa", NULL); ensure("bla,bla", ",", /* => */ "bla", "bla"); ensure("bla,bAL", ",", /* => */ "bla", "bAL"); ensure("2e\\,,bAL", ",", /* => */ "2e,", "bAL"); ensure("1\\,2,dol", ",", /* => */ "1,2", "dol"); ensure("1-2,\\,", ",", /* => */ "1-2", ","); ensure("1\\,2,\\,", ",", /* => */ "1,2", ","); ensure("oh,oh,oh", ",", /* => */ "oh", "oh", "oh"); ensure("oh\\,,oh", ",", /* => */ "oh,", "oh"); ensure("oh\\,,,oh", ",", /* => */ "oh,", "", "oh"); ensure("1-2,\\,", ",", /* => */ "1-2", ","); ensure("1280\\,1024.png,ro", ",", /* => */ "1280,1024.png", "ro"); ensure("1280\\1024.png,ro", ",", /* => */ "12801024.png", "ro"); ensure("1280\\\\1024.png,ro", ",", /* => */ "1280\\1024.png", "ro"); ensure("1280.png\\\\ro", "\\", /* => */ "1280.png", "ro"); ensure("1280\\1024.png,ro", "\\", /* => */ "12801024.png,ro", NULL); ensure("1280\\\\1024.png,ro", "\\", /* => */ "1280", "1024.png,ro", NULL); ensure("1280\\\\1024.png\\ro", "\\", /* => */ "1280", "1024.pngro"); ensure("1280\\\\1024.png\\\\ro", "\\", /* => */ "1280", "1024.png", "ro"); ensure("/file/aa\\,b\\,b\\,b,ro,cdev", ",", /* => */ "/file/aa,b,b,b", "ro", "cdev"); printf("\nAll succeeded\n"); } -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH master 4/7] readkey: fix buffer overflow handling longer escape sequences 2020-09-14 10:05 [PATCH master 1/7] sandbox: hostfile: error out if file couldn't be opened Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 2/7] sandbox: add_image: support mmaping block devices on 32-bit hosts Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 3/7] sandbox: support escaping commas in --image filenames Ahmad Fatoum @ 2020-09-14 10:05 ` Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 5/7] sandbox: fix SANDBOX_UNWIND dependency to be KASAN only Ahmad Fatoum ` (2 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Ahmad Fatoum @ 2020-09-14 10:05 UTC (permalink / raw) To: barebox; +Cc: Ahmad Fatoum My terminal emulator uses "\e[5;5~" (six bytes) to represent a Ctrl+PageUp, this overflows the esc buffer, which is only 5 bytes long as both UBSan and ASAN report. We have a check that should've avoided it, but it has an off-by one, which corrupts memory on sizes >= 4. Fix it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- lib/readkey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/readkey.c b/lib/readkey.c index fd7295104694..c26e9d51aba9 100644 --- a/lib/readkey.c +++ b/lib/readkey.c @@ -61,7 +61,7 @@ int read_key(void) esc[i] = getchar(); if (esc[i++] == '~') break; - if (i == ARRAY_SIZE(esc)) + if (i == ARRAY_SIZE(esc) - 1) return -1; } } -- 2.28.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH master 5/7] sandbox: fix SANDBOX_UNWIND dependency to be KASAN only 2020-09-14 10:05 [PATCH master 1/7] sandbox: hostfile: error out if file couldn't be opened Ahmad Fatoum ` (2 preceding siblings ...) 2020-09-14 10:05 ` [PATCH master 4/7] readkey: fix buffer overflow handling longer escape sequences Ahmad Fatoum @ 2020-09-14 10:05 ` Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 6/7] fs: don't free device in remove callback Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 7/7] common: ubsan: replace pr_err with printf Ahmad Fatoum 5 siblings, 0 replies; 8+ messages in thread From: Ahmad Fatoum @ 2020-09-14 10:05 UTC (permalink / raw) To: barebox; +Cc: Ahmad Fatoum gcc v9.3.0's libubsan does not export a __sanitizer_print_stack_trace symbol. Play it safe and avoid possible linker errors by having the optional SANDBOX_UNWIND depend only on CONFIG_KASAN. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- arch/sandbox/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index 40e04919d21e..c4d0ab4dbcde 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -22,7 +22,7 @@ config SANDBOX_UNWIND bool default y select ARCH_HAS_STACK_DUMP - depends on UBSAN || KASAN + depends on KASAN config PHYS_ADDR_T_64BIT bool -- 2.28.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH master 6/7] fs: don't free device in remove callback 2020-09-14 10:05 [PATCH master 1/7] sandbox: hostfile: error out if file couldn't be opened Ahmad Fatoum ` (3 preceding siblings ...) 2020-09-14 10:05 ` [PATCH master 5/7] sandbox: fix SANDBOX_UNWIND dependency to be KASAN only Ahmad Fatoum @ 2020-09-14 10:05 ` Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 7/7] common: ubsan: replace pr_err with printf Ahmad Fatoum 5 siblings, 0 replies; 8+ messages in thread From: Ahmad Fatoum @ 2020-09-14 10:05 UTC (permalink / raw) To: barebox; +Cc: Ahmad Fatoum The probe doesn't allocate the device, so remove shouldn't free it either. This fixes a use-after-free on barebox shutdown: Iterating over the list of devices requires that remove callbacks don't remove the devices. This happened to work so far, because apparently not much new allocations are going on during barebox shutdown, but let's do it right. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- fs/fs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/fs.c b/fs/fs.c index 17f4aee80fd4..303b62ae1718 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -710,7 +710,6 @@ static void fs_remove(struct device_d *dev) mntput(fsdev->vfsmount.parent); free(fsdev->backingstore); - free(fsdev); } struct bus_type fs_bus = { -- 2.28.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH master 7/7] common: ubsan: replace pr_err with printf 2020-09-14 10:05 [PATCH master 1/7] sandbox: hostfile: error out if file couldn't be opened Ahmad Fatoum ` (4 preceding siblings ...) 2020-09-14 10:05 ` [PATCH master 6/7] fs: don't free device in remove callback Ahmad Fatoum @ 2020-09-14 10:05 ` Ahmad Fatoum 5 siblings, 0 replies; 8+ messages in thread From: Ahmad Fatoum @ 2020-09-14 10:05 UTC (permalink / raw) To: barebox; +Cc: Ahmad Fatoum The pr_print family of functions also writes to the barebox log buffer, which we don't require for printing UBSan errors, which is a debugging aid. This also improves UBSan coverage as now undefined behavior within pr_print may be reported as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- lib/ubsan.c | 88 ++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/ubsan.c b/lib/ubsan.c index 41a5731dda66..085d470cf784 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -60,8 +60,8 @@ static bool was_reported(struct source_location *location) static void print_source_location(const char *prefix, struct source_location *loc) { - pr_err("%s %s:%d:%d\n", prefix, loc->file_name, - loc->line & LINE_MASK, loc->column & COLUMN_MASK); + printf("%s %s:%d:%d\n", prefix, loc->file_name, + loc->line & LINE_MASK, loc->column & COLUMN_MASK); } static bool suppress_report(struct source_location *loc) @@ -157,16 +157,16 @@ static void ubsan_prologue(struct source_location *location, { in_ubsan++; - pr_err("========================================" - "========================================\n"); + printf("========================================" + "========================================\n"); print_source_location("UBSAN: Undefined behaviour in", location); } static void ubsan_epilogue(unsigned long *flags) { dump_stack(); - pr_err("========================================" - "========================================\n"); + printf("========================================" + "========================================\n"); in_ubsan--; } @@ -186,13 +186,13 @@ static void handle_overflow(struct overflow_data *data, void *lhs, val_to_string(lhs_val_str, sizeof(lhs_val_str), type, lhs); val_to_string(rhs_val_str, sizeof(rhs_val_str), type, rhs); - pr_err("%s integer overflow:\n", - type_is_signed(type) ? "signed" : "unsigned"); - pr_err("%s %c %s cannot be represented in type %s\n", - lhs_val_str, - op, - rhs_val_str, - type->type_name); + printf("%s integer overflow:\n", + type_is_signed(type) ? "signed" : "unsigned"); + printf("%s %c %s cannot be represented in type %s\n", + lhs_val_str, + op, + rhs_val_str, + type->type_name); ubsan_epilogue(&flags); } @@ -232,8 +232,8 @@ void __ubsan_handle_negate_overflow(struct overflow_data *data, val_to_string(old_val_str, sizeof(old_val_str), data->type, old_val); - pr_err("negation of %s cannot be represented in type %s:\n", - old_val_str, data->type->type_name); + printf("negation of %s cannot be represented in type %s:\n", + old_val_str, data->type->type_name); ubsan_epilogue(&flags); } @@ -254,10 +254,10 @@ void __ubsan_handle_divrem_overflow(struct overflow_data *data, val_to_string(rhs_val_str, sizeof(rhs_val_str), data->type, rhs); if (type_is_signed(data->type) && get_signed_val(data->type, rhs) == -1) - pr_err("division of %s by -1 cannot be represented in type %s\n", - rhs_val_str, data->type->type_name); + printf("division of %s by -1 cannot be represented in type %s\n", + rhs_val_str, data->type->type_name); else - pr_err("division by zero\n"); + printf("division by zero\n"); ubsan_epilogue(&flags); } @@ -272,9 +272,9 @@ static void handle_null_ptr_deref(struct type_mismatch_data_common *data) ubsan_prologue(data->location, &flags); - pr_err("%s null pointer of type %s\n", - type_check_kinds[data->type_check_kind], - data->type->type_name); + printf("%s null pointer of type %s\n", + type_check_kinds[data->type_check_kind], + data->type->type_name); ubsan_epilogue(&flags); } @@ -289,10 +289,10 @@ static void handle_misaligned_access(struct type_mismatch_data_common *data, ubsan_prologue(data->location, &flags); - pr_err("%s misaligned address %p for type %s\n", - type_check_kinds[data->type_check_kind], - (void *)ptr, data->type->type_name); - pr_err("which requires %ld byte alignment\n", data->alignment); + printf("%s misaligned address %p for type %s\n", + type_check_kinds[data->type_check_kind], + (void *)ptr, data->type->type_name); + printf("which requires %ld byte alignment\n", data->alignment); ubsan_epilogue(&flags); } @@ -306,10 +306,10 @@ static void handle_object_size_mismatch(struct type_mismatch_data_common *data, return; ubsan_prologue(data->location, &flags); - pr_err("%s address %p with insufficient space\n", + printf("%s address %p with insufficient space\n", type_check_kinds[data->type_check_kind], (void *) ptr); - pr_err("for an object of type %s\n", data->type->type_name); + printf("for an object of type %s\n", data->type->type_name); ubsan_epilogue(&flags); } @@ -364,8 +364,8 @@ void __ubsan_handle_out_of_bounds(struct out_of_bounds_data *data, void *index) ubsan_prologue(&data->location, &flags); val_to_string(index_str, sizeof(index_str), data->index_type, index); - pr_err("index %s is out of range for type %s\n", index_str, - data->array_type->type_name); + printf("index %s is out of range for type %s\n", index_str, + data->array_type->type_name); ubsan_epilogue(&flags); } EXPORT_SYMBOL(__ubsan_handle_out_of_bounds); @@ -408,22 +408,22 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data, val_to_string(lhs_str, sizeof(lhs_str), lhs_type, lhs); if (val_is_negative(rhs_type, rhs)) - pr_err("shift exponent %s is negative\n", rhs_str); + printf("shift exponent %s is negative\n", rhs_str); else if (get_unsigned_val(rhs_type, rhs) >= - type_bit_width(lhs_type)) - pr_err("shift exponent %s is too large for %u-bit type %s\n", - rhs_str, - type_bit_width(lhs_type), - lhs_type->type_name); + type_bit_width(lhs_type)) + printf("shift exponent %s is too large for %u-bit type %s\n", + rhs_str, + type_bit_width(lhs_type), + lhs_type->type_name); else if (val_is_negative(lhs_type, lhs)) - pr_err("left shift of negative value %s\n", - lhs_str); + printf("left shift of negative value %s\n", + lhs_str); else - pr_err("left shift of %s by %s places cannot be" - " represented in type %s\n", - lhs_str, rhs_str, - lhs_type->type_name); + printf("left shift of %s by %s places cannot be" + " represented in type %s\n", + lhs_str, rhs_str, + lhs_type->type_name); ubsan_epilogue(&flags); } @@ -435,7 +435,7 @@ void __ubsan_handle_builtin_unreachable(struct unreachable_data *data) unsigned long flags; ubsan_prologue(&data->location, &flags); - pr_err("calling __builtin_unreachable()\n"); + printf("calling __builtin_unreachable()\n"); ubsan_epilogue(&flags); panic("can't return from __builtin_unreachable()"); } @@ -454,8 +454,8 @@ void __ubsan_handle_load_invalid_value(struct invalid_value_data *data, val_to_string(val_str, sizeof(val_str), data->type, val); - pr_err("load of value %s is not a valid value for type %s\n", - val_str, data->type->type_name); + printf("load of value %s is not a valid value for type %s\n", + val_str, data->type->type_name); ubsan_epilogue(&flags); } -- 2.28.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-09-14 13:42 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-09-14 10:05 [PATCH master 1/7] sandbox: hostfile: error out if file couldn't be opened Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 2/7] sandbox: add_image: support mmaping block devices on 32-bit hosts Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 3/7] sandbox: support escaping commas in --image filenames Ahmad Fatoum 2020-09-14 13:42 ` Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 4/7] readkey: fix buffer overflow handling longer escape sequences Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 5/7] sandbox: fix SANDBOX_UNWIND dependency to be KASAN only Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 6/7] fs: don't free device in remove callback Ahmad Fatoum 2020-09-14 10:05 ` [PATCH master 7/7] common: ubsan: replace pr_err with printf Ahmad Fatoum
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox