News for hackers. Stuff that matters.
Re:Beep security update by Y_Y on Wednesday April 04, 2018 @05:23AM (#16753226)
Can't one just

    sudo echo -e "\7” 
anyway? Or if you're trying to do something fancier there is snd-pcsp which lets use use the piezo as a normal ALSA device (quality may vary). Not that many modern machines even include such a useful device.
Re:Beep security update by DCoder on Wednesday April 04, 2018 @05:38AM (#16753277)
If you're connected to a remote server, `echo` will annoy you and your cat, but `beep` will annoy the server administrator :)
Re:Beep security update by exikyut on Wednesday April 04, 2018 @06:40AM (#16753515)
I have long wished servers had functioning speakers.

And that virtio-beep existed.

I wonder what would happen if I pushed to get the support into KVM and the kernel. Best case scenario, the videos accompanying the too-bemused-to-really-be-angry bug reports would be legendary.

Re:Beep security update by Retr0spectrum on Wednesday April 04, 2018 @05:28AM (#16753245)
Why would that need root? Is it not up to your terminal emulator to interpret the \7 and trigger the actual beep?
Re:Beep security update by rnhmjoj on Wednesday April 04, 2018 @05:37AM (#16753275)
See the "A note about ioctl" section of the README: https://github.com/johnath/beep
Re:Beep security update by DCoder on Wednesday April 04, 2018 @05:41AM (#16753287)
That section says:

> there's only one file opening, and while there is a potential race condition there, it's with /dev/console. If someone can exploit this race by replacing /dev/console, you've got bigger problems. :)

However, by reading the source one can see that you can now tell beep where it should direct its output (-e, which is not documented anywhere), so the note above is no longer accurate.

I would guess that this is the crux of the problem – the patch that fixes the security issue basically changes "open the output device once for each beep" to "open the output device on startup", greatly reducing the number of races. (It also zeroes out the buffer that's being written to certain output devices, but I have no idea if that is also to patch this security hole or to proactively prevent uninitialized bytes from leaking.)

Re:Beep security update by jwilk on Wednesday April 04, 2018 @10:57AM (#16755310)
But echo doesn't do any ioctls. The only thing it does is writing bytes on stdout.
Re:Beep security update by scbrg on Wednesday April 04, 2018 @05:30AM (#16753255)
I guess the whole point of setuid is that no, you can't always "just sudo" :-)
Re:Beep security update by ape4 on Wednesday April 04, 2018 @06:50AM (#16753551)
or

    #include <curses.h>
    main() { beep(); }
In fairness, the beep command does more https://linux.die.net/man/1/beep
Re:Beep security update by dblotsky on Wednesday April 04, 2018 @05:26AM (#16753241)
Nitpick: on my machine, that's:

    sudo echo -e "\07"
Re:Beep security update by FreeFull on Wednesday April 04, 2018 @06:11AM (#16753404)
Simply displaying a character doesn't need sudo at all anyway, so just

    echo -e "\07"
Re:Beep security update by laumars on Wednesday April 04, 2018 @07:25AM (#16753729)
`sudo` isn't there for displaying the character, it's there for ioctl to have permissions to play the beep on remote terminals[1].

I think some terminal emulators (eg Konsole) will just read char 7 and play a system defined WAV or other workaround but your more classic terminals (eg xterm) would potentially have difficulties calling the system bell.

[1] for reference: Xorg terminals are also classed as remote terminals (eg check the TTY column in `w` to see how Linux assigns pseudo-tty's to terminal emulators inside X).

Re:Beep security update by FreeFull on Wednesday April 04, 2018 @09:26AM (#16754433)
Even in that case, you'd have to run the terminal as root. Running echo as root won't do anything. X11 also has beep functionality built in, which is what I'd expect xterm to use.
Re:Beep security update by laumars on Wednesday April 04, 2018 @12:02PM (#16756008)
> Even in that case, you'd have to run the terminal as root. Running echo as root won't do anything.

To be honest that was my assumption as well but I didn't test that theory so was only reporting on the rationale of the GPs post

> X11 also has beep functionality built in, which is what I'd expect xterm to use

X11 runs as root though (that said Xorg may not anymore now as there were talks about patching Linux so it didn't have to be) so Xorg could easily still use the standard ioctl bell (that's possibly all Xorg is doing behind the scenes in fact?)

But as I said earlier, some GUI terminal emulators avoid ioctl entirely and play a WAV tone instead.

Re:Beep security update by jwilk on Wednesday April 04, 2018 @10:56AM (#16755293)
"echo -e" is not portable, and neither are any escape sequences for echo.

The portable way to print ASCII BEL is:

    printf '\a'
Re:Beep security update by gall0ws on Wednesday April 04, 2018 @05:37AM (#16753274)
Yes, it tries to do fancy things with ioctl().