Attention is currently required from: Edward O'Callaghan, Angel Pons, Jonathon Hall, Anastasia Klimchuk.
Thomas Heijligen has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67619 )
Change subject: flashrom.c: Don't crash when programmer parameter string is NULL
......................................................................
Patch Set 1:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/67619/comment/cf6cebdf_176b5729
PS1, Line 9: commit 3b8b93e
> Or would you like me to put up a change to revert it? (I'm a bit new to the process!)
The revert is CB:67621
--
To view, visit https://review.coreboot.org/c/flashrom/+/67619
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie13bdcf63c23d912dc9b774ae279f1ae5883e287
Gerrit-Change-Number: 67619
Gerrit-PatchSet: 1
Gerrit-Owner: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-CC: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Tue, 13 Sep 2022 17:37:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Comment-In-Reply-To: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-MessageType: comment
Thomas Heijligen has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/67621 )
Change subject: Revert "flashrom.c: Remove programmer_param global state"
......................................................................
Revert "flashrom.c: Remove programmer_param global state"
This reverts commit 3b8b93e17f6ad861acb2a0810ae1dcf03285fb10.
Invoking flashrom with no parameters crashes when calling strdup(NULL)
in programmer_init().
Change-Id: I3b689ad4bdd0c9c3b11f30becafc878c78630f0b
Signed-off-by: Thomas Heijligen <thomas.heijligen(a)secunet.com>
---
M flashrom.c
1 file changed, 40 insertions(+), 27 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/21/67621/1
diff --git a/flashrom.c b/flashrom.c
index ec16d04..b68ba55 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -38,6 +38,7 @@
const char *chip_to_probe = NULL;
static const struct programmer_entry *programmer = NULL;
+static const char *programmer_param = NULL;
/*
* Programmers supporting multiple buses can have differing size limits on
@@ -125,28 +126,10 @@
return rc;
}
-static int get_param_residue(const char *prog_params, int ret)
-{
- if (prog_params && strlen(prog_params)) {
- if (ret != 0) {
- /* It is quite possible that any unhandled programmer parameter would have been valid,
- * but an error in actual programmer init happened before the parameter was evaluated.
- */
- msg_pwarn("Unhandled programmer parameters (possibly due to another failure): %s\n", prog_params);
- } else {
- /* Actual programmer init was successful, but the user specified an invalid or unusable
- * (for the current programmer configuration) parameter.
- */
- msg_perr("Unhandled programmer parameters: %s\n", prog_params);
- msg_perr("Aborting.\n");
- ret = ERROR_FATAL;
- }
- }
- return ret;
-}
-
int programmer_init(const struct programmer_entry *prog, const char *param)
{
+ int ret;
+
if (prog == NULL) {
msg_perr("Invalid programmer specified!\n");
return -1;
@@ -167,11 +150,25 @@
/* Default to allowing writes. Broken programmers set this to 0. */
programmer_may_write = true;
- msg_pdbg("Initializing %s programmer\n", prog->name);
- const struct programmer_cfg cfg = { .params = strdup(param) };
- int ret = prog->init(&cfg);
- ret = get_param_residue(cfg.params, ret);
- free(cfg.params);
+ programmer_param = param;
+ msg_pdbg("Initializing %s programmer\n", programmer->name);
+ ret = programmer->init(NULL);
+ if (programmer_param && strlen(programmer_param)) {
+ if (ret != 0) {
+ /* It is quite possible that any unhandled programmer parameter would have been valid,
+ * but an error in actual programmer init happened before the parameter was evaluated.
+ */
+ msg_pwarn("Unhandled programmer parameters (possibly due to another failure): %s\n",
+ programmer_param);
+ } else {
+ /* Actual programmer init was successful, but the user specified an invalid or unusable
+ * (for the current programmer configuration) parameter.
+ */
+ msg_perr("Unhandled programmer parameters: %s\n", programmer_param);
+ msg_perr("Aborting.\n");
+ ret = ERROR_FATAL;
+ }
+ }
return ret;
}
@@ -191,6 +188,7 @@
ret |= shutdown_fn[i].func(shutdown_fn[i].data);
}
+ programmer_param = NULL;
registered_master_count = 0;
return ret;
@@ -229,7 +227,7 @@
* needle and remove everything from the first occurrence of needle to the next
* delimiter from haystack.
*/
-static char *extract_param(char *const *haystack, const char *needle, const char *delim)
+static char *extract_param(const char *const *haystack, const char *needle, const char *delim)
{
char *param_pos, *opt_pos, *rest;
char *opt = NULL;
@@ -287,7 +285,7 @@
char *extract_programmer_param_str(const struct programmer_cfg *cfg, const char *param_name)
{
- return extract_param(&cfg->params, param_name, ",");
+ return extract_param(&programmer_param, param_name, ",");
}
static int check_block_eraser(const struct flashctx *flash, int k, int log)
--
To view, visit https://review.coreboot.org/c/flashrom/+/67621
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I3b689ad4bdd0c9c3b11f30becafc878c78630f0b
Gerrit-Change-Number: 67621
Gerrit-PatchSet: 1
Gerrit-Owner: Thomas Heijligen <src(a)posteo.de>
Gerrit-MessageType: newchange
Attention is currently required from: Edward O'Callaghan, Angel Pons, Anastasia Klimchuk.
Jonathon Hall has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67619 )
Change subject: flashrom.c: Don't crash when programmer parameter string is NULL
......................................................................
Patch Set 1:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/67619/comment/72faf025_401a80dd
PS1, Line 9: commit 3b8b93e
> That works too, I'll close this if that commit is reverted
Or would you like me to put up a change to revert it? (I'm a bit new to the process!)
--
To view, visit https://review.coreboot.org/c/flashrom/+/67619
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie13bdcf63c23d912dc9b774ae279f1ae5883e287
Gerrit-Change-Number: 67619
Gerrit-PatchSet: 1
Gerrit-Owner: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Tue, 13 Sep 2022 15:55:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Comment-In-Reply-To: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-MessageType: comment
Attention is currently required from: Edward O'Callaghan, Angel Pons, Anastasia Klimchuk.
Jonathon Hall has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67619 )
Change subject: flashrom.c: Don't crash when programmer parameter string is NULL
......................................................................
Patch Set 1:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/67619/comment/ab92d31d_4b43e7d5
PS1, Line 9: commit 3b8b93e
> I think that commit should just be reverted. There's too much wrong with it.
That works too, I'll close this if that commit is reverted
--
To view, visit https://review.coreboot.org/c/flashrom/+/67619
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie13bdcf63c23d912dc9b774ae279f1ae5883e287
Gerrit-Change-Number: 67619
Gerrit-PatchSet: 1
Gerrit-Owner: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Tue, 13 Sep 2022 15:53:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: comment
Attention is currently required from: Edward O'Callaghan, Jonathon Hall, Anastasia Klimchuk.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67619 )
Change subject: flashrom.c: Don't crash when programmer parameter string is NULL
......................................................................
Patch Set 1:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/67619/comment/0e8f82a4_decd6a82
PS1, Line 9: commit 3b8b93e
I think that commit should just be reverted. There's too much wrong with it.
--
To view, visit https://review.coreboot.org/c/flashrom/+/67619
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie13bdcf63c23d912dc9b774ae279f1ae5883e287
Gerrit-Change-Number: 67619
Gerrit-PatchSet: 1
Gerrit-Owner: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Tue, 13 Sep 2022 15:26:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Edward O'Callaghan.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/66659 )
Change subject: flashrom.c: Remove programmer_param global state
......................................................................
Patch Set 15:
(2 comments)
File flashrom.c:
https://review.coreboot.org/c/flashrom/+/66659/comment/279da419_3fa3693b
PS15, Line 171: const struct programmer_cfg cfg = { .params = strdup(param) };
Where did the NULL check for `param` go? Why is strdup() needed now? And what if `strdup()` returns NULL?
https://review.coreboot.org/c/flashrom/+/66659/comment/f17d12ce_eedaee6e
PS15, Line 174: free(cfg.params);
Doesn't this result in use-after-free problems?
--
To view, visit https://review.coreboot.org/c/flashrom/+/66659
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I778609e370e44ad2b63b8baa4984ac03ff4124d8
Gerrit-Change-Number: 66659
Gerrit-PatchSet: 15
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Comment-Date: Tue, 13 Sep 2022 15:24:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Angel Pons, Nikolai Artemiev.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67391 )
Change subject: drivers/: Make 'internal_delay' the default unless defined
......................................................................
Patch Set 3:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/67391/comment/cda50cce_99a179c7
PS3, Line 13: and paves way
: to remove the 'programmer' global handle.
> Hmmmmm, I'm not sure if I understand you, probably because I'm not awake enough yet. […]
Exactly what you are saying is dealt with in a subsequent patch in the series, CB:67393, that deals with exactly the unique issues surrounding those two programmer cases.
--
To view, visit https://review.coreboot.org/c/flashrom/+/67391
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I17460bc2c0aebcbb48c8dfa052b260991525cc49
Gerrit-Change-Number: 67391
Gerrit-PatchSet: 3
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Comment-Date: Tue, 13 Sep 2022 08:00:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nico Huber <nico.h(a)gmx.de>
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Edward O'Callaghan, Nikolai Artemiev.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67391 )
Change subject: drivers/: Make 'internal_delay' the default unless defined
......................................................................
Patch Set 3:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/67391/comment/ff6eee24_612743f9
PS3, Line 13: and paves way
: to remove the 'programmer' global handle.
> Because 42 programmers had to dispatch `internal_delay()` via deference though `programmer->delay()` […]
Hmmmmm, I'm not sure if I understand you, probably because I'm not awake enough yet. Even if 42 programmers use `internal_delay()`, you still need to account for the two programmers (ch341a_spi, serprog) using a different function. So, unless you need to change things regarding `struct programmer_entry` to get rid of the `programmer` global handle, this change shouldn't make the removal easier.
TL;DR: I'm OK with this change, I just don't understand how it would have an effect on the removal of the `programmer` global handle.
--
To view, visit https://review.coreboot.org/c/flashrom/+/67391
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I17460bc2c0aebcbb48c8dfa052b260991525cc49
Gerrit-Change-Number: 67391
Gerrit-PatchSet: 3
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Comment-Date: Tue, 13 Sep 2022 07:19:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nico Huber <nico.h(a)gmx.de>
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: comment