Attention is currently required from: Nico Huber.
Jack Rosenthal has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/52215 )
Change subject: linux_mtd: prevent corruption of flash when stdout/stderr is closed
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
> Generally, as this seems to be a problem of the CLI (flashrom_print_cb() using stdout/stderr I guess), I'd prefer a patch for the CLI, e.g. check if fstat() works on them or something like
that. Other programmers might suffer the same.
Are you aware of any other programmers that will write file contents directly to the flash like Linux MTD? Would be useful to add the same to them...
Patching just the CLI would not protect libflashrom users, unfortunately.
--
To view, visit https://review.coreboot.org/c/flashrom/+/52215
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I751c9dd88ad1d30283b94bd2185b4f8f25569c8f
Gerrit-Change-Number: 52215
Gerrit-PatchSet: 1
Gerrit-Owner: Jack Rosenthal <jrosenth(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Comment-Date: Mon, 12 Apr 2021 21:44:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Edward O'Callaghan, Angel Pons.
Anastasia Klimchuk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/51487 )
Change subject: Add unit test to run init/shutdown for enabled drivers
......................................................................
Patch Set 2:
(1 comment)
Patchset:
PS2:
Hello my reviewers and cc! What do people think of the latest version that has mocks in a separate compilation units? I can say it works, tests are working, which is really good.
I thought to split this into 3 smaller patches, but on the other hand if you think this can go together in one patch, also fine.
Thank you!
--
To view, visit https://review.coreboot.org/c/flashrom/+/51487
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I3af612defe1af3850dfc1626a208d873e3a3eddc
Gerrit-Change-Number: 51487
Gerrit-PatchSet: 2
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-CC: Nico Huber <nico.h(a)gmx.de>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Comment-Date: Mon, 12 Apr 2021 21:42:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber.
Jack Rosenthal has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/52215 )
Change subject: linux_mtd: prevent corruption of flash when stdout/stderr is closed
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
The issue we saw here was in the cgpt utility, for editing the RW_GPT region on some devices. For years (since 2015 when this code landed) it had this ugly code in attempt to squelch the stdout of flashrom:
int fd_flags = fcntl(1, F_GETFD);
// Close stdout on exec so that flashrom does not muck up cgpt's output.
if (0 != fcntl(1, F_SETFD, FD_CLOEXEC))
Warning("Can't stop flashrom from mucking up our output\n");
if (ForkExecL(temp_dir_template, FLASHROM_PATH, "-i", "RW_GPT:rw_gpt", "-r",
NULL) != 0) {
For years, this code was actually sending the output to a lock file that got opened before /dev/mtd0 (see https://chromium.googlesource.com/chromiumos/third_party/flashrom/+/HEAD/bi… in our fork of flashrom). But upon switching from Makefile to meson build systems, we dropped our config option for the lock file, and this was now being written to /dev/mtd0.
Quite honestly, this is one of the more fascinating bugs I've seen in my career... I would have never expected the kernel to re-use fd 0, 1, 2 for another random file if those got closed, but I guess it does.
> Or maybe there's even something to fix in your libc.
Fixing this in glibc would probably break something :P
I actually doubt glibc would even want a "fix" which checks stdin, stdout, stderr are open before main. Sure, the library assumes it, but that's because POSIX says it can ;)
Anyway, this is a lot of a story to dump into the commit message. I think what I have there is detailed enough for the commit already ... if you think some detail here could be added to it, LMK.
--
To view, visit https://review.coreboot.org/c/flashrom/+/52215
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I751c9dd88ad1d30283b94bd2185b4f8f25569c8f
Gerrit-Change-Number: 52215
Gerrit-PatchSet: 1
Gerrit-Owner: Jack Rosenthal <jrosenth(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Comment-Date: Mon, 12 Apr 2021 21:41:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: comment
Attention is currently required from: Edward O'Callaghan, Angel Pons.
Anastasia Klimchuk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/52256 )
Change subject: ft2232_spi.c: Refactor singleton states into reentrant pattern
......................................................................
Patch Set 3:
(4 comments)
Patchset:
PS3:
thank you for review!
File ft2232_spi.c:
https://review.coreboot.org/c/flashrom/+/52256/comment/813ce735_4a12d818
PS2, Line 614: spi_data = calloc(1, sizeof(struct ft2232_data));
> Can calloc() fail?
yes of course, this is my miss
https://review.coreboot.org/c/flashrom/+/52256/comment/a9517581_a9871abd
PS2, Line 614: sizeof(struct ft2232_data)
> Using type names in sizeof() is discouraged. […]
Thank you! This now looks even better.
I will remember this for future.
https://review.coreboot.org/c/flashrom/+/52256/comment/f9181a13_21d05198
PS2, Line 617: memcpy(&spi_data->ftdic_context, &ftdic, sizeof(struct ftdi_context));
> It should be possible to do a direct assignment: […]
Direct assignment seems to work.
--
To view, visit https://review.coreboot.org/c/flashrom/+/52256
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I67518a58b4f35e0edaf06ac09c9374bdf06db0df
Gerrit-Change-Number: 52256
Gerrit-PatchSet: 3
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Comment-Date: Mon, 12 Apr 2021 21:23:38 +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, Anastasia Klimchuk.
Hello build bot (Jenkins), Edward O'Callaghan, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/52256
to look at the new patch set (#3).
Change subject: ft2232_spi.c: Refactor singleton states into reentrant pattern
......................................................................
ft2232_spi.c: Refactor singleton states into reentrant pattern
Move global singleton states into a struct and store within
the spi_master data field for the life-time of the driver.
This is one of the steps on the way to move spi_master data
memory management behind the initialisation API, for more
context see other patches under the same topic "register_master_api".
TEST=builds
BUG=b:140394053
Change-Id: I67518a58b4f35e0edaf06ac09c9374bdf06db0df
Signed-off-by: Anastasia Klimchuk <aklm(a)chromium.org>
---
M ft2232_spi.c
1 file changed, 57 insertions(+), 34 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/56/52256/3
--
To view, visit https://review.coreboot.org/c/flashrom/+/52256
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I67518a58b4f35e0edaf06ac09c9374bdf06db0df
Gerrit-Change-Number: 52256
Gerrit-PatchSet: 3
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: newpatchset
Attention is currently required from: Jack Rosenthal.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/52215 )
Change subject: linux_mtd: prevent corruption of flash when stdout/stderr is closed
......................................................................
Patch Set 1:
(1 comment)
File linux_mtd.c:
https://review.coreboot.org/c/flashrom/+/52215/comment/bf7a01c5_8ac7cc44
PS1, Line 357: * least try.
Note: This message would probably get printed properly when using the `-o` command-line option (if available).
(No action required here)
--
To view, visit https://review.coreboot.org/c/flashrom/+/52215
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I751c9dd88ad1d30283b94bd2185b4f8f25569c8f
Gerrit-Change-Number: 52215
Gerrit-PatchSet: 1
Gerrit-Owner: Jack Rosenthal <jrosenth(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Jack Rosenthal <jrosenth(a)chromium.org>
Gerrit-Comment-Date: Mon, 12 Apr 2021 18:16:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Jack Rosenthal.
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/52215 )
Change subject: linux_mtd: prevent corruption of flash when stdout/stderr is closed
......................................................................
Patch Set 1: Code-Review+1
(1 comment)
Patchset:
PS1:
I don't know about POSIX, but if `stdout`/`stderr` from `stdio.h`
are not what they are supposed to be, it's not C :)
Can you add some more details what actually led to the situation?
Maybe other people can learn from it ;) Or maybe there's even
something to fix in your libc.
Generally, as this seems to be a problem of the CLI (flashrom_
print_cb() using stdout/stderr I guess), I'd prefer a patch for
the CLI, e.g. check if fstat() works on them or something like
that. Other programmers might suffer the same.
--
To view, visit https://review.coreboot.org/c/flashrom/+/52215
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I751c9dd88ad1d30283b94bd2185b4f8f25569c8f
Gerrit-Change-Number: 52215
Gerrit-PatchSet: 1
Gerrit-Owner: Jack Rosenthal <jrosenth(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Jack Rosenthal <jrosenth(a)chromium.org>
Gerrit-Comment-Date: Mon, 12 Apr 2021 18:11:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: Edward O'Callaghan, Anastasia Klimchuk.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/52256 )
Change subject: ft2232_spi.c: Refactor singleton states into reentrant pattern
......................................................................
Patch Set 2: Code-Review+1
(3 comments)
File ft2232_spi.c:
https://review.coreboot.org/c/flashrom/+/52256/comment/b07653d7_87d2ccf3
PS2, Line 614: spi_data = calloc(1, sizeof(struct ft2232_data));
Can calloc() fail?
https://review.coreboot.org/c/flashrom/+/52256/comment/4d550236_40623ecf
PS2, Line 614: sizeof(struct ft2232_data)
Using type names in sizeof() is discouraged. If someone retypes `spi_data`, this sizeof() would also need to be updated to avoid problems, but it's easy to miss it because this sizeof() is almost 300 lines away from the `spi_data` definition.
Instead, one can apply sizeof() to variables. In this case, since `spi_data` is a pointer, `sizeof(spi_data)` would return the size of a pointer. It is possible to "dereference" it in order to obtain the size of the data it points to. This works even if the pointer is NULL, as sizeof() only cares about the type.
TL;DR: You can and should use this as the size argument for calloc():
sizeof(*spi_data)
https://review.coreboot.org/c/flashrom/+/52256/comment/5fe77ebf_de3696ee
PS2, Line 617: memcpy(&spi_data->ftdic_context, &ftdic, sizeof(struct ftdi_context));
It should be possible to do a direct assignment:
spi_data->ftdic_context = ftdic;
If it doesn't work, I'm fine with keeping the memcpy(). However, please use `sizeof(ftdic)` for the length argument (see comment above).
--
To view, visit https://review.coreboot.org/c/flashrom/+/52256
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I67518a58b4f35e0edaf06ac09c9374bdf06db0df
Gerrit-Change-Number: 52256
Gerrit-PatchSet: 2
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Mon, 12 Apr 2021 08:28:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment