Better HN
topnewbestaskshowjobs
Log inSign up

Hello71

1,909 karma · joined Sep 24, 2012 (14y ago) · 1,011 submissions

Submissions

comment 6y ago · link · parent

none, but the USB controller is expensive

comment 6y ago · link · parent

unfortunately, that wastes a good deal of power in the modern age of USB keyboards...

comment 6y ago · link · parent

isn't that what I said

comment 6y ago · link · parent

I googled "cloudflare dns import" and "cloudflare dns export" and the first result both times was an apparently official support article giving step-by-step instructions on how to do so. I myself have used this function about six years ago, so this is not new or untested functionality.

comment 6y ago · link · parent

Allegedly, some platforms have pointer trap representations, where a certain pointer can be created, but may not be used in any operations of that type. No modern systems have such trap representations for pointer types, but the C standard inherits their legacy, and, more importantly, C compilers use it as justification for certain types of optimizations. Since it's not a hardware limitation, Rust can perfectly well take the opposite path and say that the compiler may not use it for those optimizations.

https://stackoverflow.com/questions/6725809/trap-representat...

comment 6y ago · link · parent

you can probably bodge it by running a bunch of copies with limited workers, then run your main copy, then kill the starters. or, you could fiddle with the CPU affinity.

comment 6y ago · link · parent

while it's technically possible to hear above 20 kHz, outside of a laboratory it's far more likely that you're hearing intermodulation distortion, or simply background noise: at least on Linux, the audio output can be disabled completely when not in use. therefore, there is background noise only when the audio output is activated.

comment 6y ago · link · parent

'for x in $y; do printf "$a%s$b" "$x"; done' is used in the code already. I am proposing that it be changed to 'printf "$a%s$b" $y', which is also POSIX compliant, shorter (even including a comment), and faster. I included the part about brace expansion as a side note, not proposing that it be used.

comment 6y ago · link · parent

that doesn't sound like an accurate portrayal of the article at all. "Kernel Read-Only Primitive" and "Kernel Write-Only Primitive" are vague, but as far as I can tell, "SWAPGS", "BadIRET", "SysRet", and "Pop SS" are in core kernel code which cannot be configured out with Kconfig. CVE-2017-5123 is in waitid, which I believe cannot be configured out, and CVE-2017-1000112 is in TCP, which can be disabled, but is virtually never done. I don't think anything in this article talks about exploits from kernel modules. In fact, according to the article, LKRG can be trivially disabled from root by simply running "rmmod p_lkrg".

comment 6y ago · link · parent

what the fuck? I specified POSIX alternatives to non-POSIX uses in the code. only one feature, brace expansion, is not POSIX, so I specifically did not recommend its use.

comment 6y ago · link · parent

also, the vbox drivers are considered to be "crap": https://www.phoronix.com/scan.php?page=news_item&px=OTk5Mw

comment 6y ago · link · parent

eh, common.sh is a lot more complicated than it could be. example:

    write_hex() {
     hex="$1"
     echo "$hex" | sed -e 's/../&\n/' | while read -r hexbyte; do
      printf "\\x$hexbyte"
     done
    }
you can imagine other shenanigans with xargs or something, but I think this strikes the best balance between performance and readability (as far as shell script goes).

read_int16 and read_int32 don't work on big-endian systems, or if int is 16 bits instead of 32. the latter issue can be easily fixed by explicitly specifying -td2/-td4, but the former issue is not so easy. I think it requires either figuring out the endianness beforehand, or better, something like this:

    od -An -tx1 -j"$offs" -N4 "$path" | while read a b c d; do
     echo $(((0x$a << 24) | (0x$b << 16) | (0x$c << 8) | 0x$d))
    done
oddly, this is used in ls-files already. and yes, I checked: 0x$a is POSIX, and the arithmetic evaluation size must be at least a signed long, which is at least 32 bits.

'for x in $y; do printf "$a%s$b" "$x"; done' is equivalent to 'printf "$a%s$b" $y' (assuming neither a nor b contain format specifiers). similarly, 'for i in {1..100}; do printf "$a"; done' is equivalent to 'printf "$a%s.0" {1..100}'. unfortunately, brace expansion is not POSIX, but these are both significantly more efficient (both in code size and execution time) than the loop methods.

sha1sum is not POSIX. I think shell arithmetic provides you enough tools to implement https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode directly, although it may be slightly slower than a C implementation. awk is probably faster than shell.

comment 6y ago · link · parent

I've seen that thread before but just read it through in its entirety. All I got from it was "OpenBSD people are assholes, and not in the Torvalds 'constructive asshole' way, just in the 'being an asshole for the sake of being an asshole' way".

comment 6y ago · link · parent

as usual, popular science reporting is based in fact, but misstates it. there are many flavors, but only five basic tastes. the spicy sensations you refer to are touch senses: it is well known that capsaicin spiciness can be felt on most skin, not just in the mouth. therefore, it is better classified as a pain or thermal sensation, not a taste.

comment 6y ago · link · parent

or maybe even cid=$(pgrep -P $(pgrep -f "unshare.*$1")).

comment 6y ago · link · parent

you'd get worse results, because 1) most of those instructions are slower on modern hardware anyways, and 2) assembly is an optimization barrier on modern compilers, so even if you make one function 0.1% faster, it's not worth it if you've slowed down the rest of the program by 1%.

comment 6y ago · link · parent

this is utter nonsense. in C, since before C89, all non-zero values are considered true in conditional contexts (if, for, while, ?:). http://port70.net/~nsz/c/c89/c89-draft.html#3.6.4.1. false must therefore be exactly zero. !1 is also always 0, as it must be. http://port70.net/~nsz/c/c89/c89-draft.html#3.3.3.3.

comment 6y ago · link · parent

that just seems to being us back to the problem of not wanting to re-evaluate the functions...

comment 6y ago · link · parent

it could be faster with a hardware chacha20 implementation. if wireguard gets really popular, we might see that eventually. I'd wager a guess that we would get hardware wireguard first though, with fast path acceleration, similar to hardware TLS.

comment 6y ago · link · parent

the PoC can be optimized: after way too much googling, I finally found a way to consume an arbitrary number of non-empty lines without using any special characters. ironically, it uses perl.

    perl -00 -ne exit
unfortunately, the first line afterwards is also eaten. this is easily remedied by inserting one junk line though instead of a slide.

comment 6y ago · link · parent

official link: https://www.justice.gov/opa/pr/department-justice-files-acti...

comment 6y ago · link · parent

IIRC, some init implementations have this capability. I'm not saying that it's good in general, but just that it facilitates this particular case.

comment 6y ago · link · parent

this article is oddly really knowledgeable and also really unknowledgeable at the same time. despite its length, it doesn't explain what an initramfs is or how it's created until basically the end (excluding the appendix). an initramfs is simply a cpio archive with a minimum of one file, an executable "/init", then compressed with a standard compressor. currently gzip, xz, and lz4 are the useful ones.

this means that an optimized initramfs creator ought to take as long as a tar file creator, because it basically is a glorified tar file creator. on my system, with a full cache, mkinitcpio takes about 1.5 seconds to run. my custom initramfs generator (not released yet) takes 0.03 seconds to run using "cat" as compressor. it is written entirely in POSIX shell and uses only the external commands ldd, gen_init_cpio, and the compressor. however, if gzip -9 is used for the compressor, then compressing the 12 MB takes 1.8 seconds. so, we can see that compression can significantly inflate (pun intended) the time consumed. as a matter of fact, looking at https://github.com/distr1/distri/blob/master/cmd/distri/init..., it appears to pass no options to gzip, so I assume the default is used, probably -6. http://man7.org/linux/man-pages/man8/dracut.8.html indicates that dracut uses gzip -9 by default, which would increase the time required. if dracut is configured in a non-default manner (e.g. lz4 -12) that would further increase the time.

the author credits Go, concurrency, no external dependencies, and threads (?!) for the improved performance. this is manifestly unnecessary: no threads are needed to improve the performance of "tar", firstly because it is I/O bound, and secondly because the compressor is usually the slowest part anyways. it might be possible to slightly improve the performance by using native code, but there is no substantial difference between running mkinitcpio in 1.0 vs 1.5 seconds, and there's definitely no difference between 10.0 and 11.5 seconds (lz4 -12 takes about 10 seconds to run, and I assume the remaining 1.5 seconds can be fully optimized to require 0 seconds).

regarding the rest of the post, it's... a little weird. I don't understand why anyone would manually trudge through modules.dep files when that is the main objective of the "modprobe" command, as opposed to "insmod", which does no dependency resolution. (modprobe also supports config files, aliases, and some other things, but the main and original objective is dependency resolution.) it's also a bad idea to reimplement libblkid: it supports a ton of filesystems, many of which one might actually want to use as a root filesystem, but are not supported by this basic implementation, including xfs, btrfs, or zfs. it also doesn't appear to support LUKS2. libblkid isn't even necessary: busybox findfs works perfectly well for most common filesystems, and runs very quickly (0.02 seconds on my machine). but, again, the main cost when booting with a necessarily cold cache is likely to be I/O, not spawning a process. I don't understand why someone would faff about with manually parsing ELF files when ldd works just fine with simple text parsing and handles interpreter, rpath, and transitive dependencies built-in.

this all just seems overly complicated to me. my initramfs generator is 77 lines of code, including automatic ldd dependency generation, and init is 37 lines, including LUKS decryption, dropbear for remote password entry, and e2fsck with automatic reboot if requested by e2fsck, for a total of about 110 lines. I didn't count the lines of code for minitrd, but adding together the two files linked is already about 1000 lines of code. mkinitcpio has far more flexibility and is only about 1500 lines for the core code.

comment 6y ago · link · parent

BIOS I/O calls are extremely slow. EFI boot-time services are significantly faster.

comment 6y ago · link · parent

systemd makes it the most easy. all you need is systemctl switch-root ROOT. on other inits, you usually need to replace /sbin/init, then use some non-portable (sysvinit is not the only competitor) method of telling init to re-exec itself. sometimes that method doesn't even stop the running services, so you need to either manually stop them, or kill them.

comment 6y ago · link · parent

> a REST API where you can store and share your custom postgresql.conf configuration files

isn't that just a pastebin?

comment 6y ago · link · parent

It is not only guaranteed by the POSIX standard, as pointed out by the siblings, it is necessary for standard shell scripting idioms to work, e.g. "command1 2>&1 | command2".

comment 6y ago · link · parent

This argument confuses and saddens me. If I give away free food which I and others know to be contaminated with foodborne pathogens, is it wrong for them to criticize it? What if I don't know, but I obtain it from a supplier which is known to persistently sell contaminated food? What if I put up a sign in very small print saying that the food comes with no warranty whatsoever and all consumers eat it at their own risk? What if I put up a large sign? What if instead of pathogens, I intentionally add lead-based decorations on the basis that they look and taste good, even if they may be slightly carcinogenic if consumed? What if I clearly state that the decorations must be removed before eating? At what point do I acquire moral culpability for the harms suffered by my customers? These sorts of comments seem to imply that there is no problem with me doing any of this, as long as the food is provided for free and consumers have the choice to not take the food. I would vehemently disagree with that claim. Uninformed choice is not a true choice, and even informed choice cannot excuse certain foreseeable harms.

comment 6y ago · link · parent

oh, and of course if you count the vdso as "making a syscall", then three: page fault, polling, and reverse polling.

comment 6y ago · link · parent

actually, Linux uses at least two of these:

for security reasons (ASLR), the vsyscall page is implemented on modern kernels by unmapping the page, trapping the page fault, and emulating the system call.

the recently introduced io_uring interface provides an interface to set up a buffer ring which is asynchronously polled by the kernel for system calls to execute.

1
121314
34