From: Wang Wensheng wangwensheng4@huawei.com
hulk inclusion category: bugfix bugzilla: 46847 CVE: NA
-----------------------------------------------
This reverts commit bd34c7e237442f10576363ea3515da4aca39baf1.
This series of patches could raise an issue on module built.
When we build a module that contains .cpp source file, we could only build the corresponding object file by calling gcc emplicitly instead of using the kbuild framework supplied by kernel. As a consequence, the .cmd file that records the build command for the object file goes missing.
This patches series treat that missing .cmd file as a fatal error and break the module build. Although linking a object file supplied by user into a module is informal, the user has already done that and we'd better not break it for compatibility.
Signed-off-by: Wang Wensheng wangwensheng4@huawei.com Reviewed-by: Jian Cheng cj.chengjian@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- scripts/mod/modpost.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a6f25b67b1cf1..ed5e38df9a7dc 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -166,7 +166,6 @@ char *get_line(char **stringp) if (!orig || *orig == '\0') return NULL;
- /* don't use strsep here, it is not available everywhere */ next = strchr(orig, '\n'); if (next) *next++ = '\0';
From: Wang Wensheng wangwensheng4@huawei.com
hulk inclusion category: bugfix bugzilla: 46847 CVE: NA
-----------------------------------------------
This reverts commit adcfc4574d9860c4a5d3f855438f0767bfaee7f7.
This series of patches could raise an issue on module built.
Signed-off-by: Wang Wensheng wangwensheng4@huawei.com Reviewed-by: Jian Cheng cj.chengjian@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- scripts/mod/modpost.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index ed5e38df9a7dc..97d81f6396219 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -160,19 +160,11 @@ char *read_text_file(const char *filename)
char *get_line(char **stringp) { - char *orig = *stringp, *next; - /* do not return the unwanted extra line at EOF */ - if (!orig || *orig == '\0') + if (*stringp && **stringp == '\0') return NULL;
- next = strchr(orig, '\n'); - if (next) - *next++ = '\0'; - - *stringp = next; - - return orig; + return strsep(stringp, "\n"); }
/* A list of all modules we processed */
From: Wang Wensheng wangwensheng4@huawei.com
hulk inclusion category: bugfix bugzilla: 46847 CVE: NA
-----------------------------------------------
This reverts commit 0294076e7271eb007c1f9c48733a4ebba55d0064.
This series of patches could raise an issue on module built.
Signed-off-by: Wang Wensheng wangwensheng4@huawei.com Reviewed-by: Jian Cheng cj.chengjian@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- scripts/mod/sumversion.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index b7b52350d08e4..0f6dcb4011a85 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -304,8 +304,9 @@ static int is_static_library(const char *objfile) * to figure out source files. */ static int parse_source_files(const char *objfile, struct md4_ctx *md) { - char *cmd, *file, *line, *dir, *pos; + char *cmd, *file, *line, *dir; const char *base; + unsigned long flen, pos = 0; int dirlen, ret = 0, check_files = 0;
cmd = NOFAIL(malloc(strlen(objfile) + sizeof("..cmd"))); @@ -323,12 +324,14 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) strncpy(dir, objfile, dirlen); dir[dirlen] = '\0';
- file = read_text_file(cmd); - - pos = file; + file = grab_file(cmd, &flen); + if (!file) { + warn("could not find %s for %s\n", cmd, objfile); + goto out; + }
/* Sum all files in the same dir or subdirs. */ - while ((line = get_line(&pos))) { + while ((line = get_next_line(&pos, file, flen)) != NULL) { char* p = line;
if (strncmp(line, "source_", sizeof("source_")-1) == 0) { @@ -379,7 +382,8 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) /* Everyone parsed OK */ ret = 1; out_file: - free(file); + release_file(file, flen); +out: free(dir); free(cmd); return ret;
From: Wang Wensheng wangwensheng4@huawei.com
hulk inclusion category: bugfix bugzilla: 46847 CVE: NA
-----------------------------------------------
This reverts commit 18aa51a2f1e0a47bd959af44140bd6a6c06c90d8.
This series of patches could raise an issue on module built.
Signed-off-by: Wang Wensheng wangwensheng4@huawei.com Reviewed-by: Jian Cheng cj.chengjian@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- scripts/mod/modpost.c | 49 ------------------------------------------- scripts/mod/modpost.h | 2 -- 2 files changed, 51 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 97d81f6396219..7c693bd775c1b 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -118,55 +118,6 @@ void *do_nofail(void *ptr, const char *expr) return ptr; }
-char *read_text_file(const char *filename) -{ - struct stat st; - size_t nbytes; - int fd; - char *buf; - - fd = open(filename, O_RDONLY); - if (fd < 0) { - perror(filename); - exit(1); - } - - if (fstat(fd, &st) < 0) { - perror(filename); - exit(1); - } - - buf = NOFAIL(malloc(st.st_size + 1)); - - nbytes = st.st_size; - - while (nbytes) { - ssize_t bytes_read; - - bytes_read = read(fd, buf, nbytes); - if (bytes_read < 0) { - perror(filename); - exit(1); - } - - nbytes -= bytes_read; - } - buf[st.st_size] = '\0'; - - close(fd); - - return buf; -} - -char *get_line(char **stringp) -{ - /* do not return the unwanted extra line at EOF */ - if (*stringp && **stringp == '\0') - return NULL; - - return strsep(stringp, "\n"); -} - /* A list of all modules we processed */ static struct module *modules;
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index ff809119f82bb..8453d6ac2f77e 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -185,8 +185,6 @@ void maybe_frob_rcs_version(const char *modfilename, void get_src_version(const char *modname, char sum[], unsigned sumlen);
/* from modpost.c */ -char *read_text_file(const char *filename); -char *get_line(char **stringp); void *grab_file(const char *filename, unsigned long *size); char* get_next_line(unsigned long *pos, void *file, unsigned long size); void release_file(void *file, unsigned long size);
From: "Paul E. McKenney" paulmck@kernel.org
mainline inclusion from mainline-v5.11-rc1 commit 50edb988534c621a56ca103c0c16ac59e7399f01 category: bugfix bugzilla: NA CVE: NA
-------------------------------------------------------------------------
It turns out that init_srcu_struct() can be invoked from usermode tasks, and that fatal signals received by these tasks can cause memory-allocation failures. These failures are not handled well by init_srcu_struct(), so much so that NULL pointer dereferences can result. This commit therefore causes init_srcu_struct() to take an early exit upon detection of memory-allocation failure.
Link: https://lore.kernel.org/lkml/20200908144306.33355-1-aik@ozlabs.ru/ Reported-by: Alexey Kardashevskiy aik@ozlabs.ru Tested-by: Alexey Kardashevskiy aik@ozlabs.ru Signed-off-by: Paul E. McKenney paulmck@kernel.org Signed-off-by: Zhen Lei thunder.leizhen@huawei.com Reviewed-by: Jian Cheng cj.chengjian@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- kernel/rcu/srcutree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 7bd02047b63ef..a276bbe90ee34 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -184,11 +184,13 @@ static int init_srcu_struct_fields(struct srcu_struct *sp, bool is_static) INIT_DELAYED_WORK(&sp->work, process_srcu); if (!is_static) sp->sda = alloc_percpu(struct srcu_data); + if (!sp->sda) + return -ENOMEM; init_srcu_struct_nodes(sp, is_static); sp->srcu_gp_seq_needed_exp = 0; sp->srcu_last_gp_end = ktime_get_mono_fast_ns(); smp_store_release(&sp->srcu_gp_seq_needed, 0); /* Init done. */ - return sp->sda ? 0 : -ENOMEM; + return 0; }
#ifdef CONFIG_DEBUG_LOCK_ALLOC