Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from u-root:main #31

Open
wants to merge 336 commits into
base: main
Choose a base branch
from
Open

[pull] main from u-root:main #31

wants to merge 336 commits into from

Conversation

pull[bot]
Copy link

@pull pull bot commented Jun 9, 2024

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

@pull pull bot added the ⤵️ pull label Jun 9, 2024
jensdrenhaus and others added 29 commits July 1, 2024 10:05
Signed-off-by: Jens Drenhaus <[email protected]>
Signed-off-by: Jens Drenhaus <[email protected]>
Signed-off-by: Jens Drenhaus <[email protected]>
Signed-off-by: Jens Drenhaus <[email protected]>
Signed-off-by: Jens Drenhaus <[email protected]>
Signed-off-by: Jens Drenhaus <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
With the recent changes, pox standalone mode was totally broken.

You can now use it again
pox -cvsf date `which date`
sudo ./date

works fine.

While we are at it, we now print a useful message if you do not run a standalone pox as root.
It comes complete with 38% snark.

Also, remove the
len(args) == 0
since there are cases where that is acceptable.

Signed-off-by: Ron Minnich <[email protected]>
exec.Command will do the chroot, then the chdir.
Since a chroot has happened, the Dir must be "/"

Signed-off-by: Ronald G Minnich <[email protected]>
self-embedding got broken in several ways. It is fixed.
The new test should ensure it does not get broken again.

Remove the long flags, they are not needed by the small group
of people using this command.

Add io.Reader and io.Writers to the cmd struct.
This will ease further test writing.

This now works just fine:
rminnich@pop-os:~/go/src/github.com/u-root/u-root/cmds/exp/pox$ ./pox -cvsf pwd.pox `which pwd`
2024/07/03 21:55:04 "/home/rminnich/go/src/github.com/u-root/u-root/cmds/exp/pox/pox": ["/usr/bin/pwd"], {true false true false true pwd.pox  ./pox [/usr/bin/pwd]  0x4a9a80 0xc0000b4000 0xc0000b4008 0xc0000b4010}
2024/07/03 21:55:04 Adding "/lib/x86_64-linux-gnu/libc.so.6"
2024/07/03 21:55:04 Adding "/lib64/ld-linux-x86-64.so.2"
2024/07/03 21:55:04 Adding "/usr/bin/pwd"
2024/07/03 21:55:04 Adding mount "/tmp/pox2599116451/sys", perm -r-xr-xr-x
2024/07/03 21:55:04 Adding mount "/tmp/pox2599116451/proc", perm -r-xr-xr-x
2024/07/03 21:55:04 Adding mount "/tmp/pox2599116451/dev", perm -rwxr-xr-x
2024/07/03 21:55:05 Done, your pox is "pwd.pox"
rminnich@pop-os:~/go/src/github.com/u-root/u-root/cmds/exp/pox$ ./pwd.pox
2024/07/03 21:55:08 this primitive kernel requires root permissions to run pox:permission denied
rminnich@pop-os:~/go/src/github.com/u-root/u-root/cmds/exp/pox$ sudo ./pwd.pox
/

It's just that you have to be root.

Signed-off-by: Ronald G Minnich <[email protected]>
The Ino value is used in archive unpacking to detect
hard links. Ino numbers are used as follows when unpacking:
if the file is 0 length, and Ino has been previously seen,
then a hard link should be created.

If Ino is 0, then hard links can not be
detected and will not be created. Interestingly, this
problem was not detected for 10 years, since our primary use
of cpio was in initramfs.

The Ino value is created in a reproducible way when the
archive is created (i.e. the Ino value from the file system
is not used). If cpio is passed the same set of files, in the
same order, and they exist, the Ino values will be
reproduced.

Signed-off-by: Ronald G. Minnich <[email protected]>
Technically, in a cpio archive, a file is a hard link if
size is 0 and the inumber has been seen already.

GNU seems to further require that NLink be non-zero.

For MakeReproducible, set NLink as follows:
if it is 0 or 1, leave it unchanged.
If it is > 1, set it to math.MaxUint64

Signed-off-by: Ronald G Minnich <[email protected]>
Also remove spurious print from tests

Signed-off-by: Ronald G Minnich <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
This package holds the configuration struct and its default values for the netcat cmd.
It also contains customized UDP-listeners as well as customized reader/writers.

Signed-off-by: Fabian Wienand <[email protected]>
binjip978 and others added 30 commits October 21, 2024 06:41
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
On systems where /dev/fd is a symbolic link traverse of a /dev
directory will be stopped early.

Signed-off-by: Siarhiej Siemianczuk <[email protected]>
According to Universal Payload Specification, "the Payload should be
able to run from any aligned address."

In order to implement this feature, we need to find a available memory
space to place bootloader parameter, temp stack, trampoline code and
Universal Payload image. Once available space is located, bootloader
parameter will be placed at the start of this space. Then temp stack,
which is used to keep no info will be leaked, will be placed with one
page size, and trampoline code will be placed next to temp stack. At
last, Universal Payload Image binary will be placed next to trampoline
code, and data in relocation section will be updated to adapt relocated
address.

In trampoline code, General Purpose Registers 'RCX' will be set with
address of bootloader parameter, 'RSP' will be set with address of
temp stack. Entry point address of Universal Payload Image will be
loaded into 'RAX', and then hand over execution to entry point of
Universal Payload Image by invoking 'JMP RAX' instruction.

Change-Id: I8e0227ea9fd5b324a910258619832f622db3abca
Signed-off-by: Ajan Zhong <[email protected]>
Signed-off-by: Raysmond Lei <[email protected]>
Universal Payload AARCH64 architecture implementation follows same
loading process as X86 architecture, so shares common logic with X86.

To architecture differentation parts, implementation of get Physical
Address Size and Trampoline code reside in architecture specified
source code files.

Change-Id: I2f553c04eb92ec8e9b71861f9f8873e151b624a9
Signed-off-by: Ajan Zhong <[email protected]>
Signed-off-by: Raysmond Lei <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
In this forth, unlike the original, the stack is a stack of any,
not just strings.

the typeof operator will show the type of TOS.

Signed-off-by: Ronald G Minnich <[email protected]>
It was really terrible. Now it is not bad.

msr 0 0x3a rd

works fine.
So does
msr 0 cpu 0x3a reg rd

Internally, the rd and other functions now call functions which to a type switch
and do something decent.

So we might not need to get rid of forth after all.

It is handy: there are and, or, and swap; it handles many cpus via the glob syntax; and you can
chain things:
sudo ./msr "'"* dup 0x3a rd swap 0x13c rd
[[5 5 5 5 5 5 5 5 5 5 5 5] [1 1 1 1 1 1 1 1 1 1 1 1]]
rminnich@pop-os:~/go/src/github.com/u-root/u-root/cmds/core/msr$ sudo ./msr 1 dup 0x3a rd swap 0x13c rd
[[5] [1]]

This kind of "argv scripting" can be nice.

Signed-off-by: Ronald G Minnich <[email protected]>
You can now do this:
msr 0 0x3a rd 1 and

The typeof command is nice for debugging.
sudo ./msr  "'"* dup 0x3a rd 3 and typeof
[* [5 5 5 5 5 5 5 5 5 5 5 5] []uint64]

and for real work:

rminnich@pop-os:~/go/src/github.com/u-root/u-root/cmds/core/msr$ sudo ./msr '[0123]' 0x3a rd dup 0xb and
[[5 5 5 5] [1 1 1 1]]
rminnich@pop-os:~/go/src/github.com/u-root/u-root/cmds/core/msr$ sudo ./msr '[0123]' 0x3a rd dup 0xb or
[[5 5 5 5] [15 15 15 15]]
rminnich@pop-os:~/go/src/github.com/u-root/u-root/cmds/core/msr$ sudo ./msr '[0123]' 0x3a rd 1 and
[1 1 1 1]

Signed-off-by: Ronald G Minnich <[email protected]>
correctly handle panics that do not have a usable error type.

Signed-off-by: Ronald G Minnich <[email protected]>
and and or need to clone the slice in case it is dup'ed
on the stack. Arguably, dup is broken for slices and
once we get to go1.23 we need to clean it up.

cpu and msr, once on the stack, should be left there for
convenience.

Signed-off-by: Ronald G Minnich <[email protected]>
The rd, wr, and other commands now leave
cpu.CPUs and msr.MSR on the stack.
i.e.,
msr [01] 0x3a rd 1 or wr
works fine, we don't need to keep pushing the cpu mask and msr
on the stack.

This is a major step forward in convenience.

Change the docs, and the forth code, to match this reality.

This command is now dramatically easier to use, and much better
about errors.

Whether people will want it to work in the long term in this way,
we shall see.

But the ability to do math on msr reads and writes, in line as part of
argv, is very powerful.

Signed-off-by: Ronald G Minnich <[email protected]>
There is a note that shows how to have a whole stack
you can see.

Signed-off-by: Ronald G Minnich <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.