[tip:x86/microcode] x86/microcode: Use kmemdup() rather than duplicating its implementation
Commit-ID: 9cc6f743c7724eb9abaf27904194c169db85dd31 Gitweb: http://git.kernel.org/tip/9cc6f743c7724eb9abaf27904194c169db85dd31 Author: Andrzej HajdaAuthorDate: Tue, 16 Feb 2016 09:43:20 +0100 Committer: Ingo Molnar CommitDate: Wed, 17 Feb 2016 08:46:08 +0100 x86/microcode: Use kmemdup() rather than duplicating its implementation The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci. Signed-off-by: Andrzej Hajda Signed-off-by: Borislav Petkov Cc: Bartlomiej Zolnierkiewicz Cc: Linus Torvalds Cc: Marek Szyprowski Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1455612202-14414-3-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/cpu/microcode/amd.c | 4 +--- arch/x86/kernel/cpu/microcode/intel.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index f66cbfe..e397fc1 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -788,15 +788,13 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover) return -EINVAL; } - patch->data = kzalloc(patch_size, GFP_KERNEL); + patch->data = kmemdup(fw + SECTION_HDR_SIZE, patch_size, GFP_KERNEL); if (!patch->data) { pr_err("Patch data allocation failure.\n"); kfree(patch); return -EINVAL; } - /* All looks ok, copy patch... */ - memcpy(patch->data, fw + SECTION_HDR_SIZE, patch_size); INIT_LIST_HEAD(>plist); patch->patch_id = mc_hdr->patch_id; patch->equiv_cpu = proc_id; diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index cb397947..cbb3cf0 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -210,13 +210,11 @@ save_microcode(struct mc_saved_data *mcs, mc_hdr = >hdr; size = get_totalsize(mc_hdr); - saved_ptr[i] = kmalloc(size, GFP_KERNEL); + saved_ptr[i] = kmemdup(mc, size, GFP_KERNEL); if (!saved_ptr[i]) { ret = -ENOMEM; goto err; } - - memcpy(saved_ptr[i], mc, size); } /*
[tip:x86/microcode] x86/microcode: Use kmemdup() rather than duplicating its implementation
Commit-ID: 9cc6f743c7724eb9abaf27904194c169db85dd31 Gitweb: http://git.kernel.org/tip/9cc6f743c7724eb9abaf27904194c169db85dd31 Author: Andrzej Hajda AuthorDate: Tue, 16 Feb 2016 09:43:20 +0100 Committer: Ingo Molnar CommitDate: Wed, 17 Feb 2016 08:46:08 +0100 x86/microcode: Use kmemdup() rather than duplicating its implementation The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci. Signed-off-by: Andrzej Hajda Signed-off-by: Borislav Petkov Cc: Bartlomiej Zolnierkiewicz Cc: Linus Torvalds Cc: Marek Szyprowski Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1455612202-14414-3-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/cpu/microcode/amd.c | 4 +--- arch/x86/kernel/cpu/microcode/intel.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index f66cbfe..e397fc1 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -788,15 +788,13 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover) return -EINVAL; } - patch->data = kzalloc(patch_size, GFP_KERNEL); + patch->data = kmemdup(fw + SECTION_HDR_SIZE, patch_size, GFP_KERNEL); if (!patch->data) { pr_err("Patch data allocation failure.\n"); kfree(patch); return -EINVAL; } - /* All looks ok, copy patch... */ - memcpy(patch->data, fw + SECTION_HDR_SIZE, patch_size); INIT_LIST_HEAD(>plist); patch->patch_id = mc_hdr->patch_id; patch->equiv_cpu = proc_id; diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index cb397947..cbb3cf0 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -210,13 +210,11 @@ save_microcode(struct mc_saved_data *mcs, mc_hdr = >hdr; size = get_totalsize(mc_hdr); - saved_ptr[i] = kmalloc(size, GFP_KERNEL); + saved_ptr[i] = kmemdup(mc, size, GFP_KERNEL); if (!saved_ptr[i]) { ret = -ENOMEM; goto err; } - - memcpy(saved_ptr[i], mc, size); } /*
[tip:perf/core] perf tools: Fix handling read result using a signed variable
Commit-ID: 38349665388fb079fb2bc8c46db9446dd976802a Gitweb: http://git.kernel.org/tip/38349665388fb079fb2bc8c46db9446dd976802a Author: Andrzej Hajda AuthorDate: Tue, 6 Oct 2015 11:00:17 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 6 Oct 2015 18:04:59 -0300 perf tools: Fix handling read result using a signed variable The function can return negative value, assigning it to unsigned variable can cause memory corruption. The problem has been detected using proposed semantic patch scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2038576 Signed-off-by: Andrzej Hajda Cc: Bartlomiej Zolnierkiewicz Cc: Marek Szyprowski Cc: Peter Zijlstra Cc: kernel-janit...@vger.kernel.org Link: http://lkml.kernel.org/r/1444122017-16856-1-git-send-email-a.ha...@samsung.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index cb98b5a..8b10621 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -67,7 +67,8 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, char filename[PATH_MAX]; char bf[4096]; int fd; - size_t size = 0, n; + size_t size = 0; + ssize_t n; char *nl, *name, *tgids, *ppids; *tgid = -1; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf tools: Fix handling read result using a signed variable
Commit-ID: 38349665388fb079fb2bc8c46db9446dd976802a Gitweb: http://git.kernel.org/tip/38349665388fb079fb2bc8c46db9446dd976802a Author: Andrzej HajdaAuthorDate: Tue, 6 Oct 2015 11:00:17 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 6 Oct 2015 18:04:59 -0300 perf tools: Fix handling read result using a signed variable The function can return negative value, assigning it to unsigned variable can cause memory corruption. The problem has been detected using proposed semantic patch scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2038576 Signed-off-by: Andrzej Hajda Cc: Bartlomiej Zolnierkiewicz Cc: Marek Szyprowski Cc: Peter Zijlstra Cc: kernel-janit...@vger.kernel.org Link: http://lkml.kernel.org/r/1444122017-16856-1-git-send-email-a.ha...@samsung.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index cb98b5a..8b10621 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -67,7 +67,8 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, char filename[PATH_MAX]; char bf[4096]; int fd; - size_t size = 0, n; + size_t size = 0; + ssize_t n; char *nl, *name, *tgids, *ppids; *tgid = -1; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/platform] arch/x86/intel-mid: Use kmemdup rather than duplicating its implementation
Commit-ID: c9e69c8c58eb8671e9f6cee728088e4c5abc9115 Gitweb: http://git.kernel.org/tip/c9e69c8c58eb8671e9f6cee728088e4c5abc9115 Author: Andrzej Hajda AuthorDate: Fri, 7 Aug 2015 09:59:14 +0200 Committer: Thomas Gleixner CommitDate: Thu, 17 Sep 2015 23:38:59 +0200 arch/x86/intel-mid: Use kmemdup rather than duplicating its implementation The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320 Signed-off-by: Andrzej Hajda Cc: Bartlomiej Zolnierkiewicz Cc: Marek Szyprowski Cc: Julia Lawall Link: http://lkml.kernel.org/r/1438934377-4922-9-git-send-email-a.ha...@samsung.com Signed-off-by: Thomas Gleixner --- arch/x86/platform/intel-mid/sfi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c index ce992e8..5ee360a 100644 --- a/arch/x86/platform/intel-mid/sfi.c +++ b/arch/x86/platform/intel-mid/sfi.c @@ -197,10 +197,9 @@ static int __init sfi_parse_gpio(struct sfi_table_header *table) num = SFI_GET_NUM_ENTRIES(sb, struct sfi_gpio_table_entry); pentry = (struct sfi_gpio_table_entry *)sb->pentry; - gpio_table = kmalloc(num * sizeof(*pentry), GFP_KERNEL); + gpio_table = kmemdup(pentry, num * sizeof(*pentry), GFP_KERNEL); if (!gpio_table) return -1; - memcpy(gpio_table, pentry, num * sizeof(*pentry)); gpio_num_entry = num; pr_debug("GPIO pin info:\n"); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/platform] arch/x86/intel-mid: Use kmemdup rather than duplicating its implementation
Commit-ID: c9e69c8c58eb8671e9f6cee728088e4c5abc9115 Gitweb: http://git.kernel.org/tip/c9e69c8c58eb8671e9f6cee728088e4c5abc9115 Author: Andrzej HajdaAuthorDate: Fri, 7 Aug 2015 09:59:14 +0200 Committer: Thomas Gleixner CommitDate: Thu, 17 Sep 2015 23:38:59 +0200 arch/x86/intel-mid: Use kmemdup rather than duplicating its implementation The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320 Signed-off-by: Andrzej Hajda Cc: Bartlomiej Zolnierkiewicz Cc: Marek Szyprowski Cc: Julia Lawall Link: http://lkml.kernel.org/r/1438934377-4922-9-git-send-email-a.ha...@samsung.com Signed-off-by: Thomas Gleixner --- arch/x86/platform/intel-mid/sfi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c index ce992e8..5ee360a 100644 --- a/arch/x86/platform/intel-mid/sfi.c +++ b/arch/x86/platform/intel-mid/sfi.c @@ -197,10 +197,9 @@ static int __init sfi_parse_gpio(struct sfi_table_header *table) num = SFI_GET_NUM_ENTRIES(sb, struct sfi_gpio_table_entry); pentry = (struct sfi_gpio_table_entry *)sb->pentry; - gpio_table = kmalloc(num * sizeof(*pentry), GFP_KERNEL); + gpio_table = kmemdup(pentry, num * sizeof(*pentry), GFP_KERNEL); if (!gpio_table) return -1; - memcpy(gpio_table, pentry, num * sizeof(*pentry)); gpio_num_entry = num; pr_debug("GPIO pin info:\n"); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/microcode] x86/microcode: Use kmemdup() rather than duplicating its implementation
Commit-ID: d4e963644768b33aa3db7f470c35d74ed78d8354 Gitweb: http://git.kernel.org/tip/d4e963644768b33aa3db7f470c35d74ed78d8354 Author: Andrzej Hajda AuthorDate: Mon, 10 Aug 2015 12:19:52 +0200 Committer: Ingo Molnar CommitDate: Sat, 22 Aug 2015 14:49:35 +0200 x86/microcode: Use kmemdup() rather than duplicating its implementation The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci. Signed-off-by: Andrzej Hajda Signed-off-by: Borislav Petkov Cc: Bartlomiej Zolnierkiewicz Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Marek Szyprowski Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1439201994-28067-2-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/cpu/microcode/amd.c | 4 +--- arch/x86/kernel/cpu/microcode/intel_early.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index c7d2415..be37f10 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -366,15 +366,13 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover) return -EINVAL; } - patch->data = kzalloc(patch_size, GFP_KERNEL); + patch->data = kmemdup(fw + SECTION_HDR_SIZE, patch_size, GFP_KERNEL); if (!patch->data) { pr_err("Patch data allocation failure.\n"); kfree(patch); return -EINVAL; } - /* All looks ok, copy patch... */ - memcpy(patch->data, fw + SECTION_HDR_SIZE, patch_size); INIT_LIST_HEAD(>plist); patch->patch_id = mc_hdr->patch_id; patch->equiv_cpu = proc_id; diff --git a/arch/x86/kernel/cpu/microcode/intel_early.c b/arch/x86/kernel/cpu/microcode/intel_early.c index 8187b72..101f0ac 100644 --- a/arch/x86/kernel/cpu/microcode/intel_early.c +++ b/arch/x86/kernel/cpu/microcode/intel_early.c @@ -207,13 +207,11 @@ save_microcode(struct mc_saved_data *mc_saved_data, mc_hdr = >hdr; size = get_totalsize(mc_hdr); - saved_ptr[i] = kmalloc(size, GFP_KERNEL); + saved_ptr[i] = kmemdup(mc, size, GFP_KERNEL); if (!saved_ptr[i]) { ret = -ENOMEM; goto err; } - - memcpy(saved_ptr[i], mc, size); } /* -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/microcode] x86/microcode: Use kmemdup() rather than duplicating its implementation
Commit-ID: d4e963644768b33aa3db7f470c35d74ed78d8354 Gitweb: http://git.kernel.org/tip/d4e963644768b33aa3db7f470c35d74ed78d8354 Author: Andrzej Hajda a.ha...@samsung.com AuthorDate: Mon, 10 Aug 2015 12:19:52 +0200 Committer: Ingo Molnar mi...@kernel.org CommitDate: Sat, 22 Aug 2015 14:49:35 +0200 x86/microcode: Use kmemdup() rather than duplicating its implementation The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci. Signed-off-by: Andrzej Hajda a.ha...@samsung.com Signed-off-by: Borislav Petkov b...@suse.de Cc: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com Cc: H. Peter Anvin h...@zytor.com Cc: Linus Torvalds torva...@linux-foundation.org Cc: Marek Szyprowski m.szyprow...@samsung.com Cc: Peter Zijlstra pet...@infradead.org Cc: Thomas Gleixner t...@linutronix.de Link: http://lkml.kernel.org/r/1439201994-28067-2-git-send-email...@alien8.de Signed-off-by: Ingo Molnar mi...@kernel.org --- arch/x86/kernel/cpu/microcode/amd.c | 4 +--- arch/x86/kernel/cpu/microcode/intel_early.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index c7d2415..be37f10 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -366,15 +366,13 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover) return -EINVAL; } - patch-data = kzalloc(patch_size, GFP_KERNEL); + patch-data = kmemdup(fw + SECTION_HDR_SIZE, patch_size, GFP_KERNEL); if (!patch-data) { pr_err(Patch data allocation failure.\n); kfree(patch); return -EINVAL; } - /* All looks ok, copy patch... */ - memcpy(patch-data, fw + SECTION_HDR_SIZE, patch_size); INIT_LIST_HEAD(patch-plist); patch-patch_id = mc_hdr-patch_id; patch-equiv_cpu = proc_id; diff --git a/arch/x86/kernel/cpu/microcode/intel_early.c b/arch/x86/kernel/cpu/microcode/intel_early.c index 8187b72..101f0ac 100644 --- a/arch/x86/kernel/cpu/microcode/intel_early.c +++ b/arch/x86/kernel/cpu/microcode/intel_early.c @@ -207,13 +207,11 @@ save_microcode(struct mc_saved_data *mc_saved_data, mc_hdr = mc-hdr; size = get_totalsize(mc_hdr); - saved_ptr[i] = kmalloc(size, GFP_KERNEL); + saved_ptr[i] = kmemdup(mc, size, GFP_KERNEL); if (!saved_ptr[i]) { ret = -ENOMEM; goto err; } - - memcpy(saved_ptr[i], mc, size); } /* -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/