New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 647786 link

Starred by 2 users

Issue metadata

Status: Verified
Owner:
Last visit > 30 days ago
Closed: Nov 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 1
Type: Bug-Regression



Sign in to add a comment

normal->dev mode transition dies

Project Member Reported by shchen@chromium.org, Sep 16 2016

Issue description

Normal to dev mode transition takes less than 10 seconds because the dd process is killed.

in /mnt/stateful_partition/unencrypted/clobber-state.log
/sbin/clobber-state: 1: cannot create /dev/tty1: Input/output error

The pipe isn't created properly and pv kills the dd command as a result.
 
Cc: hungte@chromium.org vapier@chromium.org
Components: OS>Systems
Labels: -Type-Bug -Pri-3 M-55 Security_Severity-Low Pri-1 Type-Bug-Regression
Owner: shchen@chromium.org
Let's bump priority a bit since this is a (slight) security issue. It would be nice to get this fixed within M-55.

Can you own this or do we need to find somebody else?

We should fix whatever causes the tty to fail (and presumably prevents us from displaying the progress bar), but ultimately we should also rewrite the code such that any sort of problem with pv or stty won't cause the dd to abort. Adding Mike who maybe has a good idea how to do this in bash. Relevant code snippet for reference:

    # Opening a TTY device with no one else attached will allocate and reset     
    # terminal attributes. To prevent user input echo and ctrl-breaks, we need   
    # to allocate and configure the terminal before using tty for output.        
    # Note &2 is currently used for debug messages dumping so we can't redirect  
    # subshell by 2>"${TTY}".                                                    
    ( stty -F "${TTY}" raw -echo -cread                                          
      pv -etp -s $((4 * 1024 * 1024 * ${FULL_BLKS})) /dev/zero 2>"${TTY}" |      
        dd of=${DEV} bs=4M count=${FULL_BLKS} iflag=fullblock oflag=sync         
    ) >"${TTY}"                                   

Comment 2 by vapier@chromium.org, Sep 19 2016

Summary: normal->dev mode transition dies (was: jerry: normal->dev mode transition dies)
TTY currently defaults to /dev/tty1 which requires the VT to exist -- on a non-freon based build, the kernel does it before userspace starts, but for freon builds, frecon creates them on the fly.  looking at our boot scripts, there's a race here:
- pre-startup stops
- startup (run chromeos_startup) & udev run
- chromeos_startup executes clobber-state
- udev-trigger-early runs once udev finishes startup
- boot-splash runs once udev-trigger-early finishes executing (including waiting for many classes of devices)
- boot-splash runs frecon which handles vt creation
(iiuc the VT interaction correctly)

should be able to reproduce on any device by putting a sleep 60 in boot-splash at the start of its script code.

for terminal signals, we could ignore things by doing:
  trap '' INT QUIT KILL TSTP TERM
  stty ... || :

the redirect could be split out into a sep phase so failures can be skipped:
  exec >& ${TTY} || :
we could send the output to /dev/null in case it failed, but seems like it'd be better to just let the output go to the log so we know we won't miss anything weird ?

alternatively, if the shell is getting too dicey, we could always hack together our own little C program that'd do everything for us.

Comment 3 by shchen@chromium.org, Sep 26 2016

Hi Mike,

I uploaded a CL with your suggestions above:
https://chromium-review.googlesource.com/#/c/389871/

I am unfortunately not seeing the output of pv on the screen for any DUT that I've tried (although the dd operation is indeed finishing now).  Did I do something wrong?

Comment 4 by shchen@chromium.org, Sep 28 2016

Hi Mike,

Thanks for the code review.  I tried your suggestion of putting exec before the pv command (CL above has been updated to reflect this), but seems like the output to pv is still not being outputted to /dev/tty1.  I'm currently testing on a chell, where I know that the progress bar was printing to screen before my changes were implemented.

I also tried adding in the pipe from pv directly (although I know that this would have caused an early abort on the jerry) and that also didn't output the progress bar:

( trap '' INT QUIT KILL TSTP TERM
  stty -F "${TTY}" raw -echo -cread || :
  exec &> "${TTY}" || :
  pv -etp -s $((4 * 1024 * 1024 * ${FULL_BLKS})) /dev/zero 2> "{$TTY}" |
    dd of=${DEV} bs=4M count=${FULL_BLKS} iflag=fullblock oflag=sync
)

Comment 5 by vapier@chromium.org, Sep 28 2016

the redirect after the pv is incorrect (has a typo) and unneeded.  so delete this part:
  2> "{$TTY}"

Comment 6 by shchen@chromium.org, Sep 28 2016

Hi Mike, 

Sorry, I should've copied the code instead of putting it in the CL to make it more clear.  My original attempt was (which did not result in the progress bar being outputted to screen):

( trap '' INT QUIT KILL TSTP TERM
  stty -F "${TTY}" raw -echo -cread || :
  exec &> "${TTY}" || :
  pv -etp -s $((4 * 1024 * 1024 * ${FULL_BLKS})) /dev/zero |
    dd of=${DEV} bs=4M count=${FULL_BLKS} iflag=fullblock oflag=sync
)

Comment 7 by vapier@chromium.org, Sep 28 2016

w/out debugging the code myself, i don't know offhand why it isn't working.  you can try writing some debug code that writes to somewhere stable like /var/log/ or /usr/local/ to see what's going on.  like check the exit code of each command and see if $TTY even exists.

if the existing code works, then try changing only one part at a time until it stops working to narrow down.
Project Member

Comment 8 by bugdroid1@chromium.org, Oct 22 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform2/+/23e0916a8042189552abe8ce48db68799b7ccf34

commit 23e0916a8042189552abe8ce48db68799b7ccf34
Author: Shelley Chen <shchen@chromium.org>
Date: Wed Oct 12 21:49:28 2016

init: clobber-state: Add wait loop for TTY to get set up

Currently, the normal->dev transition on veyron_jerry
errors out with when pv tries to redirect output to an
invalid tty.  Adding polling before the call to make sure
that the tty is valid before trying to redirect to it.

BUG= chromium:647786 
BRANCH=None
TEST=run normal->dev transition on veyron_jerry,chell

Change-Id: If5003d76f0c035f86144203d6795c8ea1db73387
Signed-off-by: Shelley Chen <shchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/398539
Reviewed-by: Mike Frysinger <vapier@chromium.org>

[modify] https://crrev.com/23e0916a8042189552abe8ce48db68799b7ccf34/init/clobber-state

Labels: Merge-Request-54 Merge-Request-55

Comment 10 by dimu@chromium.org, Nov 9 2016

Labels: -Merge-Request-54 Merge-Review-54 Hotlist-Merge-Review
[Automated comment] Request affecting a post-stable build (M54), manual review required.

Comment 11 by dimu@chromium.org, Nov 9 2016

Labels: -Merge-Request-55 Merge-Approved-55 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M55 (branch: 2883)

Comment 12 by dimu@chromium.org, Nov 9 2016

Labels: -Merge-Request-54 Merge-Review-54 Hotlist-Merge-Review
[Automated comment] Request affecting a post-stable build (M54), manual review required.
Project Member

Comment 13 by bugdroid1@chromium.org, Nov 10 2016

Labels: merge-merged-release-R55-8872.B
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform2/+/16ca9bdcc3989947b92d6bed2c89c2baf32e636f

commit 16ca9bdcc3989947b92d6bed2c89c2baf32e636f
Author: Shelley Chen <shchen@chromium.org>
Date: Wed Oct 12 21:49:28 2016

init: clobber-state: Add wait loop for TTY to get set up

Currently, the normal->dev transition on veyron_jerry
errors out with when pv tries to redirect output to an
invalid tty.  Adding polling before the call to make sure
that the tty is valid before trying to redirect to it.

BUG= chromium:647786 
BRANCH=None
TEST=run normal->dev transition on veyron_jerry,chell

Change-Id: If5003d76f0c035f86144203d6795c8ea1db73387
Signed-off-by: Shelley Chen <shchen@chromium.org>
Previous-Reviewed-on: https://chromium-review.googlesource.com/398539
(cherry picked from commit afea330875699e36d55782e1744e034db49c743e)
Reviewed-on: https://chromium-review.googlesource.com/407824
Reviewed-by: Mike Frysinger <vapier@chromium.org>

[modify] https://crrev.com/16ca9bdcc3989947b92d6bed2c89c2baf32e636f/init/clobber-state

Labels: -Hotlist-Merge-Review -Merge-Review-54 Merge-Rejected-54
R54 is expired already, if this is fixed we can probably close it. 
Project Member

Comment 15 by sheriffbot@chromium.org, Nov 30 2016

This issue has been approved for a merge. Please merge the fix to any appropriate branches as soon as possible!

If all merges have been completed, please remove any remaining Merge-Approved labels from this issue.

Thanks for your time! To disable nags, add the Disable-Nags label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: Fixed (was: Untriaged)
Has been merged into 55
Project Member

Comment 17 by sheriffbot@chromium.org, Dec 4 2016

This issue has been approved for a merge. Please merge the fix to any appropriate branches as soon as possible!

If all merges have been completed, please remove any remaining Merge-Approved labels from this issue.

Thanks for your time! To disable nags, add the Disable-Nags label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 18 by dchan@google.com, Apr 17 2017

Labels: VerifyIn-59

Comment 19 by dchan@google.com, May 30 2017

Labels: VerifyIn-60
Labels: VerifyIn-61
Status: Verified (was: Fixed)
Verified in 9765.7.0/61.0.3163.13.

Sign in to add a comment