NetBSD Planet


January 23, 2021

Pullup 9 [pullup-9 #1186] kern/55942: destroyed ena(4) evcnts cause panic
Pullup pkgsrc [pullup-pkgsrc #6411] Security update for "mutt" package

January 22, 2021

Pullup pkgsrc [pullup-pkgsrc #6410] pullup 2020Q4 pkgsrc/net/frr bison build dependency

January 21, 2021

Pullup pkgsrc [pullup-pkgsrc #6409] mozjs78 on Linux fix
Pullup pkgsrc [pullup-pkgsrc #6408] build fix: [[email protected]: CVS commit: pkgsrc/lang/mozjs78]

January 19, 2021

Pullup pkgsrc [pullup-pkgsrc #6407] build fix: firefox: set GCC_REQD

January 16, 2021

Unix Stack Exchange Why Does the NetBSD System Call Manual Mention the Standard C Library?

I'm reviewing man(2) pages on NetBSD 9, and have seen that all of the documents (write(2), open(2), pipe(2)) mention the Standard C Library at the top.

My understanding was that system calls were independent of library functions (such as those in libc). I don't see a similar mention in the Linux System call Manual. Does this mean that invoking these methods is calling some wrapper function included in libc, instead of directly calling a kernel function? Is this generally true, or just a feature of NetBSD?


January 15, 2021

Super User Wait for process to start on linux/(net)bsd

I'm attempting to make a script which tracks how many times you execute a specific process. I want to detect when the process starts and then log it.

The psuedo-code would be something like this:

while (true) if (process started) then log(process)

Is there an easy way to do this (preferably in shell but C is also fine) on either Linux or NetBSD?


January 13, 2021

Pullup 9 [pullup-9 #1185] Fix PR kern/55920

January 09, 2021

DragonFly BSD Digest In Other BSDs for 2021/01/09

This bulked up fast this week.


January 08, 2021

Pullup 9 [pullup-9 #1184] newfs(8) and fsck(8) fixes for rd(4) and some other disks

January 07, 2021

The NetBSD Foundation pkgsrc-2020Q4 released

January 06, 2021

DragonFly BSD Digest timeout(1) in DragonFly

Aaron LI has ported timeout(1) to DragonFly.  It’s a way to run a command with a time limit, and I’m happy to say it is a cross-BSD item, coming from NetBSD by way of FreeBSD.


January 05, 2021

Pullup 8 [pullup-8 #1646] Fix IPF on mips64 (not compat32 friendly)
Pullup 9 [pullup-9 #1183] Fix IPF on mips64 (not compat32 friendly)
Pullup 9 [pullup-9 #1182] You may want to read this

January 04, 2021

Benny Siegert SSD Rochade
My desktop PC has two NVMe drives, one for Windows and one for NetBSD. With Steam game footprints being what they are, the Windows one (256 GB) has been perpetually overfull, so it was time for something bigger. At the same time, I had bought an NVMe daughter board for my Pinebook Pro. My impression with the PBP is that the I/O performance of the eMMC module is holding it back, so I am excited to give it fast storage :)

December 30, 2020

Ruben Schade Things I was thankful for in 2020

This has been a hard year, and today from a personal perspective has been the cherry on top I fully expected (inb4 confirmation bias). But I’m going to let it get away with sending us off like this, so I’m writing an (incomplete!) list of things I was thankful for this year, written to the sounds of Mori Calliope telling the year what it can do, and reminding us it won’t bring us down.

Clara, and health

Dad didn’t lose his life or home in the Australian bushfires
This was only in January, I already can’t believe it. Helping him pack some essentials and evacuating on advice of the Rural Fire Service was… I can’t summon the words right now. But he and his home survived, and hopefully we’ll have a postponed Xmas again soon!

Reconnecting with friends
Dealing with anxiety over the last few years led me to distance from people I care about. I reconnected with so many of them again this year, from high school to now, and they’re all awesome… and understanding. Thanks everyone.

Me awkwardly presenting my talk on FreeBSD at OrionVM

Becoming more involved with FreeBSD and NetBSD
I spoke at the FreeBSD miniconf at Linux.conf.au 2020 in January, met some more members of the Australian BSD community, and I was mentioned on the BSD Now podcast! I still have impostor syndrome something fierce, but people have helped coax me out of my /bin/sh.

Hololive EN
People acting anime characters in realtime while playing games like Minecraft sounds niche but not groundbreaking. But their English-speaking generation launched this year have brought us so much joy. Clara and I will always be Investimigators, but Gura and Ina have become de facto councillors given the heavy questions they answer with care and good humour. I only half joke that they’ve probably saved lives during these depressing times.

Screenshot of one of our Minecraft villages

Minecraft
I blame Hololive-EN for getting me into this time sink game that I’d so successfully avoided for a decade. WOW it’s fun. You could do worse than spending your evenings building out villages and exploring with your girlfriend if you can’t travel or go outside.

OpenZFS 2.0
I use and advocate for ZFS everywhere I can, professionally and personally. Merging the disparate branches of open source ZFS into one tree was a huge technical and community achievement, and most importantly signalled the stability, long-term support, and viability of the world’s most trustworthy file system and volume manager now that Oracle holds the other keys. I run it today, and can’t wait for it to be in FreeBSD BASE next year.

Emacs
I like Vim and have used it for years, but this whole time I didn’t realise that Emacs interfaces to my brain better: read into that as much as you want. Finding all these great tools that can run it has been too much fun.

This blog
I added 490 posts this year, and reached 7,200. Writing each one was a cathartic exercise to write, and even got mentioned on some high-profile news sites, aggregators, and mailing lists. I’ve had so many great emails, comments, and feedback. You’ve even taken time to read my site or RSS feed, and the post I’m writing now. Thank you.

Happy New Year. Ganbatte kudasai! Let’s do our best to make 2021 better.

By Ruben Schade, 2020-12-31.

Pullup 8 [pullup-8 #1645] ufs_quota1: avoid OOB array access

December 29, 2020

Pullup 8 [pullup-8 #1644] add missing null pointer checks to fss(4)

December 28, 2020

Pullup 8 [pullup-8 #1643] Fix ntpdate

December 27, 2020

Pullup 8 [pullup-8 #1642] hp300 hilkbd console fix

December 26, 2020

DragonFly BSD Digest In Other BSDs for 2020/12/26

Lots of history this week.

 


December 25, 2020

Stack Overflow Which processor would execute hardware interrupt in a muticore system

In general hardware interrupts need to be processed immediately, at least so as to acknowledge it and do some first level of processing. As I understand this is not scheduled activity. Please correct me.

So the question is how to choose a processor that would actually execute this hardware interrupt handler?

One can answer this for Linux and/or BSD systems


December 21, 2020

NetBSD Blog Allen K. Briggs Memorial Scholarship

Allen Briggs was one of the earliest members of the NetBSD community, pursuing his interest in macBSD, and moving to become a NetBSD developer when the two projects merged. Allen was known for his quiet and relaxed manner, and always brought a keen wisdom with him; allied with his acute technical expertise, he was one of the most valued members of the NetBSD community.

He was a revered member of the NetBSD core team, and keenly involved in many aspects of its application; from working on ARM chips to helping architect many projects, Allen was renowned for his expertise. He was a distinguished engineer at Apple, and used his NetBSD expertise there to bring products to market.

Allen lived in Blacksburg Virginia with his wife and twin boys and was active with various community volunteer groups. His family touched the families of many other NetBSD developers and those friendships have endured beyond his passing.

We have received the following from Allen's family and decided to share it with the NetBSD community. If you can, we would ask you to consider contributing to his Memorial Scholarship.

https://www.ncssm.edu/donate/distance-education/allen-k-briggs-88-memorial-scholarship

The Allen K. Briggs Memorial Scholarship is an endowment to provide scholarships in perpetuity for summer programs at the North Carolina School of Science & Math, which Allen considered to be a place that fundamentally shaped him as a person. We would love to invite Allen's friends and colleagues from the BSD community to donate to this cause so that we can provide more scholarships to students with financial need each year. We are approximately halfway to our goal of $50K with aspirations to exceed that target and fund additional scholarships.

Two quick notes on donating: Important! When donating, you must select "Allen K. Briggs Memorial Scholarship" under designation for the donation to be routed to the scholarship If you have the option to use employer matching (i.e., donating to NCSSM through an employer portal to secure a match from your employer), please email the NCSSM Foundation's Director of Development, April Horton ([email protected]), after donating to let her know you want your gift and employer match to go to the Allen K. Briggs Memorial Scholarship Thanks in advance for your help. I'd be happy to answer any questions you or any others have about this.


December 08, 2020

Ruben Schade Block copy disk over SSH with gzip

We haven’t had a things you already know, unless you don’t installment since March. So many things have happened in the interim, not least the need to copy disks over a network:

$ dd if=$SOURCE | gzip -1 - | pv | ssh target 'gunzip dd of=$TARGET

This will copy a block device across SSH to a remote server, compressing with gzip to remove empty space, and pv to show progress.

By Ruben Schade, 2020-12-08.


December 07, 2020

Ruben Schade Antranig moving from macOS to FreeBSD

Antranig Vartanian wrote about his jump from macOS to a FreeBSD ThinkPad at the end of November. It comes after a year or so of tweets and comments to my blog here discussing his increasing frustration at where the Mac platform is headed, and I find it hard to fault him.

His main reasons for the switch came down to macOS becoming less Unix-y, with services he doesn’t need and an outdated userland; Big Sur’s frustrating new interface; Linux and Windows having their own problems; and his working knowledge of FreeBSD on the server making the switch easier. I’ve noted the same trends, and have similar views.

Mac users like us have felt the ebbs and flows of the platform over the years, and the announcement of the M1 chip has reaffirmed the company’s interest in the Mac after a lost decade chasing iOS instead. My current Intel 16-inch MacBook Pro is a great machine, and all the benchmarks suggest the M1 based Macs absolutely smoke any PC in their class. Almost all PC laptops have crappy screens with bad colour, poor viewing angles, and low resolutions; and their trackpads don’t come close to matching the sensitivity and precision of what Apple had a decade ago.

(Font rendering is another sticking point. Ironically, *nix desktops still have better looking fonts than Windows. It’s another thing you become accustomed to on macOS, and the standardisation of their Retina screens only makes the difference more stark when you go back to PCs ).

But software is another story, and I’m tending to lean in the direction of Antranig here from a usability perspective. Every Big Sur screenshot I’ve seen has reminded me of how I blanched seeing Windows Aero in Vista/7 and Metro in 8/10. We’re by no means in the minority here; prominent Mac developers have voiced their own frustrations at the seeming iOS 7-ificiation of the platform and the throwing away of their own user interface guidelines.

Apple have their reasons for doing this, but it shows their priorities for the platform are drifting further away from what users like me buy their kit for: a portable Unix workstation where I spend my time working and playing a few games rather than constantly tinkering with window managers and drivers. This wasn’t a coincidence or convenient alignment of our priorities, Apple used to heavily advertise macOS’s certified Unix pedigree. They’re the only ones left doing this after SGI and Sun.

I’ve got it to the point where I can configure a new Mac, save for updates, within an hour. Homebrew Cask lets me install graphical packages, and I lean heavily on NetBSD’s pkgsrc tooling for everything else. I’ve somehow avoided the headaches others in the community have had with VPN configs, firewall rules, OpenSSH, and others. Maybe I’ve just internalised so much of it from two decades of use.

That said, I’ve been careful to only use cross-platform software where I can, save for a few work-specific tools. Emacs, of all things, removed some of the last Mac-specific tools I used for years for note taking, reading RSS, using IRC, and expanding snippets. My Venn diagram of what my on-call Panasonic Let’s Note laptop with FreeBSD can do, and what my Mac can, overlap more than ever before.

I’m glad to see gentleman like Antranig are able to productively move onto a FreeBSD desktop that works better for them. I’m sticking with the Mac for now, but it sounds like all I need is some more compelling hardware. I sure wouldn’t mind more upgradeable ones!

By Ruben Schade, 2020-12-08.


December 05, 2020

UnitedBSD login.conf

Netbsd users, what's in your login.conf? Asking so I can get an idea of what I can do with it .

edited: and sysctl.conf as well. I'm trying to see what's possible with net and get the most out of my hardware

DragonFly BSD Digest In Other BSDs for 2020/12/05

Some interesting ‘how do you do this?’ sort of material this week.

UnitedBSD Help Tuning netbsd

I just installed netbsd on an old desktop with an amd A6 and 8 gb of ram. Obviously it's an old cpu, but the performance on a recent debian install was much better. I've taken a cursory look at the docs to fine tune performance by editing kernel configs etc....

Anyone here have good advice on how to get the most of netbsd?


December 04, 2020

UnitedBSD exec dwm "libX11.so.6" not found

I try compile dwm (not in pkgsrc) in NetBSD and run it. I have my config.mk file look like this

PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
X11INC = /usr/pkg/include
X11LIB = /usr/pkg/lib
XINERAMALIBS = -lXinerama
XINERAMAFLAGS = -DXINERAMA
FREETYPELIBS = -lfontconfig -lXft
FREETYPEINC = /usr/pkg/include/freetype2
INCS = -I${X11INC} -I${FREETYPEINC}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\"${XINERAMAFLAGS}
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
LDFLAGS = ${LIBS}
CC = cc

and my .xinitrc

exec dwm

But the output when I startx is:

dwm: Shared object "libX11.so.6 not found"
/usr/pkg/bin/xinit: connection to X server lost

What did I do wrong?


December 03, 2020

UnitedBSD Thinkpad install finalization

I'm working on a Thinkpad x230 which I've had for a long time. I love it, and NetBSD is working well. However, I can't seem to find good documentation about which pieces of software, or Kernel modules make things work.

I know these laptops see a lot of use, and I'm sure someone can point me in the right direction.

What I am looking for:

I want an icon to self populate onto the desktop which when clicked, opens a file manager window to an already automounted USB or SD card drive.

I'm still working to get all the pieces of FVWM working, but I like it so far. I've not ruled out going back to xfce, but I wanted to try something different.

Hopefully someone can point me in the right directions with some of this.

cheers!


December 02, 2020

UnitedBSD Can the aarch64 image file provided by netbsd run on rockpis?

Processor SoC RK3308
Quad Cortex-A35 ARM 64bits processor
frequency up to 1.3GHz
Memory 256MB or 512MB DDR3
Storage MicroSD(TF), optional on board 1/2/4/8Gb NAND flash
Wireless 802.11 b/g/n wifi
Bluetooth 4.0(rtl8723DS)
external antenna
USB USB2.0 Type-A HOST x1
USB3.0 Type-C OTG x1
Key maskrom x1
reset x1
Ethernet 100MB ethernet, RTL8201F,optional PoE(additional HAT requried)
IO 26-pin expansion header
I2C x4
PWM x3
SPI x2
UART x3
I2S0 x1
5V DC power in x2
3.3V DC power in x2
Others ---
Power USB Type-C DC 5V
Size 1.7inch square


November 25, 2020

OS News Before the BSD kernel starts

In this article, I will walk through the early kernel initialization process, defining the meaning of this term. System initialization is a broad topic that ranges from the platform’s hardware design all the way up to typical functions of an operating system such as handling I/O operations. It is not possible to cover the entire topic adequately within the scope of an article. In this first part I will describe the well-known AMD64: 64-bit platform. I am going to highlight a very interesting part of the initialization process the early initialization of the kernel. Later, I will compare it with ARM64. In both cases I will discuss the topic in the context of NetBSD, the operating system known for its portability.

Some light reading.


November 22, 2020

Unix Stack Exchange NetBSD sh -c "echo OK" doesn't give any output? [closed]

I'm testing the portability of some stuff I'm writing to BSD. It's working on Linux, FreeBSD, OpenBSD. It isn't working on NetBSD.

The following is on a fresh VM installation I've made just for the purpose of testing this. I've traced the issue to

NetBSD$ uname -a
NetBSD NetBSD.local 9.1 NetBSD 9.1 (GENERIC) #0: Sun Oct 18 19:24:30 UTC 2020 [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC amd64
NetBSD$ cat /etc/shells                                                                                 
#       $NetBSD: shells,v 1.3 1996/12/29 03:23:07 mrg Exp $
#
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/sh
/bin/csh
/bin/ksh
/usr/pkg/bin/zsh
/usr/pkg/bin/bash
NetBSD$ for s in /bin/sh /bin/csh /bin/ksh /usr/pkg/bin/zsh /usr/pkg/bin/bash ; do echo $s; $s -c "echo OK" ; done
/bin/sh
/bin/csh
OK
/bin/ksh
/usr/pkg/bin/zsh
OK
/usr/pkg/bin/bash
OK
NetBSD$ su -
Password:
NetBSD# for s in /bin/sh /bin/csh /bin/ksh /usr/pkg/bin/zsh /usr/pkg/bin/bash ; do echo $s; $s -c "echo OK" ; done
/bin/sh
OK
/bin/csh
OK
/bin/ksh
OK
/usr/pkg/bin/zsh
OK
/usr/pkg/bin/bash
OK

Why doesn't sh -c "echo OK" and ksh -c "echo OK" work when I'm a non-root user, and why do they work when I'm root?

Other shells (csh, zsh, bash) work correctly, as shown above.


November 21, 2020

DragonFly BSD Digest In Other BSDs for 202/11/21

Right outta RSS.


November 08, 2020

Unix Stack Exchange How to install a torrent client on a NetBSD server with only SSH access [closed]

I have a remote server running NetBSD 6, to which I have access only via SSH. I have very limited Unix/Linux experience but I guess there are some command line torrent cliens available for Unixes like the ones in the BSD family. Could someone help install a torrent client only using SSH access onto a NetBSD 6 server?

Thank you!


October 30, 2020

Ruben Schade NetBSD 9.1, FreeBSD 12.2-R, OpenBSD 6.8

The BSD Daemon

Holiday presents have come early this year! We saw updates for the three biggest BSDs this month, all with something interesting to try. Emphasis added on what my weekend will be spent checking out:

NetBSD 9.1:

The NetBSD Project is pleased to announce NetBSD 9.1, the firstfeature and stability update for the netbsd-9 release branch.

Over the last months many changes have been made to the NetBSD 9 stablebranch. As a stable branch the release engineering team and the NetBSDdevelopers are conservative with changes to this branch and many usersrely on the binaries from our regular auto-builds for production use.

The new release features (among various other changes) many bug fixes,a few performance enhancements, stability improvements for ZFS and LFSand support for USB security keys in a mode easily usable in Firefoxand other applications.

FreeBSD 12.2-RELEASE:

The FreeBSD Release Engineering Team is pleased to announce theavailability of FreeBSD 12.2-RELEASE. This is the third release of thestable/12 branch.

Some of the highlights:

  • Updates to the wireless networking stack and various drivers havebeen introduced to provide better 802.11n and 802.11ac support.

  • The ice(4) driver has been added, supporting Intel(R) 100Gb ethernetcards.

  • The jail(8) utility has been updated to allow running Linux(R) in ajailed environment.

  • OpenSSL has been updated to version 1.1.1h.

  • OpenSSH has been updated to version 7.9p1.

  • The clang, llvm, lld, lldb, compiler-rt utilities and libc++ havebeen updated to version 10.0.1.

I don’t run OpenBSD anywhere, but I keep being given good reasons to finally try it again. OpenBSD 6.8, via the OpenBSD Journal:

On its 25th birthday, the OpenBSD project has released OpenBSD 6.8, the 49th release.

The new release comes with a large number of improvements and debuts a new architecture, OpenBSD/powerpc64, running on the POWER9 family of processors. The full list of changes can be found in the announcement and on the release page.


By Ruben Schade in Sydney.


October 24, 2020

Ruben Schade Firefox 82.0 resolves macOS stuttering scrolling

My new MacBook Pro coincided with the release of Firefox 81.x, which lead me to think there was something wrong with the discrete GPU on this refurbished machine. Each time I loaded a site and scrolled, regardless of how heavy the page was, it would occasionally stop then lurch in an attempt to catch up. I joked with colleagues that it was a *nix VESA desktop emulation mode.

Safari and Vivaldi didn’t have the same issue, which thankfully ruled out a hardware.

Firefox icon

I’m pleased to report now that the issue is gone as of Firefox 82. Either that, or an extension I use also updated in the interim. Either way, I’m unreasonably happy.

I used to use Phoenix/Firebird/Firefox back in the day to push against IE. Now the few of us still using it are at it again, only we use it to push against Chrome hegemony. Please use it; it’s a great browser and especially quick since the Quantum update. We need its user agent in server logs to show the world there’s still value in cross-browser testing and development. We’re already starting to see Chrome-only sites again, presumably written by people who either weren’t alive or don’t remember the lessons of the first browser wars.

Special thanks to these fine contributors for maintaining the Homebrew Cask for Firefox, the FreeBSD Gecko team, and ryoon for pkgsrc. A lot of work goes into people like me being able to install Firefox on our various platforms with a single command.


This post originally appeared on Rubenerd.


October 21, 2020

NetBSD Blog NetBSD 9.1 released

After a small delay*, the NetBSD Project is pleased to announce NetBSD 9.1, the first feature and stability maintenance release of the netbsd-9 stable branch.

The new release features (among various other changes) many bug fixes, a few performance enhancements, stability improvements for ZFS and LFS and support for USB security keys in a mode easily usable in Firefox and other applications.

For more details and instructions see the 9.1 announcement.

Get NetBSD 9.1 from our CDN (provided by fastly) or one of the ftp mirrors.

Complete source and binaries for NetBSD are available for download at many sites around the world. A list of download sites providing FTP, AnonCVS, and other services may be found at https://www.NetBSD.org/mirrors/.

* for the delay: let us say there was a minor hickup and we took the opportunity to provide up to date timezone files for NetBSD users in Fiji.


October 20, 2020

The NetBSD Foundation NetBSD 9.1 released

October 19, 2020

NetBSD Blog Google Summer of Code 2020: [Final Report] Enhancing Syzkaller support for NetBSD
This report was written by Ayushu Sharma as part of Google Summer of Code 2020.

This post is a follow up of the first report and second report. Post summarizes the work done during the third and final coding period for the Google Summer of Code (GSoc’20) project - Enhance Syzkaller support for NetBSD

Sys2syz

Sys2syz would give an extra edge to Syzkaller for NetBSD. It has a potential of efficiently automating the conversion of syscall definitions to syzkaller’s grammar. This can aid in increasing the number of syscalls covered by Syzkaller significantly with the minimum possibility of manual errors. Let’s delve into its internals.

A peek into Syz2syz Internals

This tool parses the source code of device drivers present in C to a format which is compatible with grammar customized for syzkaller. Here, we try to cull the details of the target device by compiling, and then collocate the details with our python code. For further details about proposed design for the tool, refer to previous post.

Python code follows 4 major steps:

Extraction:

This step involves fetching the possible ioctl commands for the target device driver and getting the files which have to be included in our dev_target.txt file. We have already seen all the commands for device drivers are defined in a specific way. These commands defined in the header files need to be grepped along with the major details, regex comes in as a rescue for this


	io = re.compile("#define\s+(.*)\s+_IO\((.*)\).*")
	iow = re.compile("#define\s+(.*)\s+_IOW\((.*),\s+(.*),\s+(.*)\).*")
	ior = re.compile("#define\s+(.*)\s+_IOR\((.*),\s+(.*),\s+(.*)\).*")
	iowr = re.compile("#define\s+(.*)\s+_IOWR\((.*),\s+(.*),\s+(.*)\).*")

Code scans through all the header files present in the target device folder and extracts all the commands along with their details using compiled regex expressions. Details include the direction of buffer(null, in, out, inout) based on the types of Ioctl calls(_IO, _IOR, _IOW, _IOWR) and the argument of the call. These are stored in a file named ioctl_commands.txt at location out/&lttarget_name&gt. Example output:


out, I2C_IOCTL_EXEC, i2c_ioctl_exec_t

Preprocessing:

Preprocessing is required for getting XML files, about which we would look in the next step. Bear plays a major role when it comes to preprocessing C files. It records the commands executed for building the target device driver. This step is performed when setup.sh script is executed.

Extracted commands are modified with the help of parse_commands() function to include ‘-E’ and ‘-fdirectives’ flags and give it a new output location. Commands extracted by this function are then used by the compile_target function which filters out the unnecessary flags and generates preprocessed files in our output directory.

Generating XML files

Run C2xml on the preprocessed files to fetch XML files which stores source code in a tree-like structure, making it easier to collect all the information related to each and every element of structures, unions etc. For eg:


	&ltsymbol type="struct" id="_5970" file="am2315.i" start-line="13240" start-col="16" end-line="13244" end-col="11" bit-size="96" alignment="4" offset="0">
		&ltsymbol type="node" id="_5971" ident="ipending" file="am2315.i" start-line="13241" start-col="33" end-line="13241" end-col="41" bit-size="32" alignment="4" offset="0" base-type-builtin="unsigned int"/<
		&ltsymbol type="node" id="_5972" ident="ilevel" file="am2315.i" start-line="13242" start-col="33" end-line="13242" end-col="39" bit-size="32" alignment="4" offset="4" base-type-builtin="int"/>
		&ltsymbol type="node" id="_5973" ident="imasked" file="am2315.i" start-line="13243" start-col="33" end-line="13243" end-col="40" bit-size="32" alignment="4" offset="8" base-type-builtin="unsigned int"/>
	</symbol>
	&ltsymbol type="pointer" id="_5976" file="am2315.i" start-line="13249" start-col="14" end-line="13249" end-col="25" bit-size="64" alignment="8" offset="0" base-type-builtin="void"/>
	&ltsymbol type="array" id="_5978" file="am2315.i" start-line="13250" start-col="33" end-line="13250" end-col="39" bit-size="288" alignment="4" offset="0" base-type-builtin="unsigned int" array-size="9"/>

We would further see how attributes like - idents, id, type, base-type-builtin etc conveniently helps us to analyze code and generate descriptions in a trouble-free manner .

Descriptions.py

Final part, which offers a txt file storing all the required descriptions as its output. Here, information from the xml files and ioctl_commands.txt are combined together to generate descriptions of ioctl commands and their arguments.

Xml files for the given target device are parsed to form trees,


for file in (os.listdir(self.target)):
	tree = ET.parse(self.target+file)
	self.trees.append(tree)

We then traverse through these trees to search for the arguments of a particular ioctl command (particularly _IOR, _IOW, _IOWR commands) by the name of the argument. Once an element with the same value for ident attribute is found, attributes of the element are further examined to get its type. Possible types for these arguments are - struct, union, enum, function, array, pointer, macro and node. Using the type information we determine the way to define the element in accordance with syzkaller’s grammar syntax.

Building structs and unions involves defining their elements too, XML makes it easier. Program analyses each and every element which is a child of the root (struct/union) and generates its definitions. A dictionary helps in tracking the structs/unions which have been already built. Later, the dictionary is used to pretty print all the structs and union in the output file. Here is a code snippet which depicts the approach


            name = child.get("ident")
            if name not in self.structs_and_unions.keys():
                elements = {}
                for element in child:
                    elem_type = self.get_type(element)
                    elem_ident = element.get("ident")
                    if elem_type == None:
                        elem_type = element.get("type") 
                    elements[element.get("ident")] = elem_type

                element_str = ""
                for element in elements: 
                    element_str += element + "\t" + elements[element] + "\n"
                self.structs_and_unions[name] = " {\n" + element_str + "}\n"
            return str(name)

Task of creating descriptions for arrays is made simpler due to the attribute - `array-size`. When it comes to dealing with pointers, syzkaller needs the user to fill in the direction of the pointer. This has already been taken care of while analyzing the ioctl commands in Extractor.py. The second argument with in/out/inout as its possible value depends on ‘fun’ macros - _IOR, _IOW, _IOWR respectively.

There is another category named as nodes which can be distinguished using the base-type-builtin and base-type attributes.

Result

Once the setup script for sys2syz is executed, sys2syz can be used for a certain target_device file by executing the python wrapper script (sys2syz.py) with :

#bin/sh
python sys2syz.py -t &ltabsolute_path_to_device_driver_source> -c compile_commands.json -v

This would generate a dev_&ltdevice_driver&gt.txt file in the out directory. An example description file autogenerated by sys2syz for i2c device driver.


#Autogenerated by sys2syz
include 

resource fd_i2c[fd]

syz_open_dev$I2C(dev ptr[in, string["/dev/i2c"]], id intptr, flags flags[open_flags]) fd_i2c

ioctl$I2C_IOCTL_EXEC(fd fd_i2c, cmd const[I2C_IOCTL_EXEC], arg ptr[out, i2c_ioctl_exec])

i2c_ioctl_exec {
iie_op	flags[i2c_op_t_flags]
iie_addr	int16
iie_buflen	len[iie_buf, intptr]
iie_buf	buffer[out]
iie_cmdlen	len[iie_cmd, intptr]
iie_cmd	buffer[out]
}

Future Work

Though we have a basic working structure of this tool, yet a lot has to be worked upon for leveling it up to make the best of it. Perfect goals would be met when there would be least of manual labor needed. Sys2syz still looks forward to automating the detection of macros used by the flag types in syzkaller. List of to-dos also includes extending syzkaller’s support for generation of description of syscalls.

Some other yet-to-be-done tasks include-

Summary

We have surely reached closer to our goals but the project needs active involvement and incremental updates to scale it up to its full potential. Looking forward to much more learning and making more contribution to NetBSD community.

Atlast, a word of thanks to my mentors William Coldwell, Siddharth Muralee, Santhosh Raju and Kamil Rytarowski as well as the NetBSD organization for being extremely supportive. Also, I owe a big thanks to Google for giving me such a glaring opportunity to work on this project.


October 17, 2020

Unix Stack Exchange Does *BSD have the ability to encrypt a system partition with full disk encryption?

Does FreeBSD, NetBSD, or OpenBSD have an encryption feature like Linux's dm-crypt? And will it work for a system partition?


October 13, 2020

The NetBSD Foundation New Security Advisory: NetBSD-SA2020-003

October 09, 2020

The NetBSD Foundation pkgsrc-2020Q3 released

October 07, 2020

NetBSD Blog The GNU GDB Debugger and NetBSD (Part 5)
The NetBSD developers maintain two copies of GDB:

The base-system version of GDB (GPLv3) still relies on local patching to work. I have set a goal to reduce the number of custom patches to bare minimum, ideally achieving the state of GDB working without any local modifications at all.

GDB changes

Last month, the NetBSD/amd64 support was merged into gdbserver. This month, the gdbserver target support was extended to NetBSD/i386 and NetBSD/aarch64. The gdbserver and gdb code was cleaned up, refactored and made capable of introducing even more NetBSD targets.

Meanwhile, the NetBSD/i386 build of GDB was fixed. The missing include of x86-bsd-nat.h as a common header was added to i386-bsd-nat.h. The i386 GDB code for BSD contained a runtime assert that verified whether the locally hardcoded struct sigcontext is compatible with the system headers. In reality, the system headers are no longer using this structure since 2003, after the switch to ucontext_t, and the validating code was no longer effective. After the switch to newer GCC, this was reported as a unused local variable by the compiler. I have decided to remove the check on NetBSD entirely. This was followed up by a small build fix.

The NetBSD team has noticed that the GDB's agent.cc code contains a portability bug and prepared a local fix. The traditional behavior of the BSD kernel is that passing random values of sun_len (part of sockaddr_un) can cause failures. In order to prevent the problems, the sockaddr_un structure is now zeroed before use. I've reimplemented the fix and successfully upstreamed it.

In order to easily resolve the issue with environment hardening enforced by PaX MPROTECT, I've introduced a runtime warning whenever byte transfers betweeen the debugee and debugger occur with the EACCES errno code.

binutils changes

I've added support for NetBSD/aarch64 upstream, in GNU BFD and GNU GAS. NetBSD still carries local patches for the GNU binutils components, and GNU ld does not build out of the box on NetBSD/aarch64.

Summary

The NetBSD support in GNU binutils and GDB is improving promptly, and the most popular platforms of amd64, i386 and aarch64 are getting proper support out of the box, without downstream patches. The remaining patches for these CPUs include: streamlining kgdb support, adding native GDB support for aarch64, upstreaming local modifications from the GNU binutils components (especially BFD and ld) and introducing portability enhancements in the dependent projects like libiberty and gnulib. Then, the remaining work is to streamline support for the remaining CPUs (Alpha, VAX, MIPS, HPPA, IA64, SH3, PPC, etc.), to develop the missing generic features (such as listing open file descriptors for the specified process) and to fix failures in the regression test-suite.


October 01, 2020

The NetBSD Foundation New Developer in September 2020

September 30, 2020

OS News Wayland on NetBSD – trials and tribulations

Related to yesterday’s post about NetBSD switching to ctwm:

After I posted about the new default window manager in NetBSD I got a few questions, including “when is NetBSD switching from X11 to Wayland?”, Wayland being X11’s “new” rival. In this blog post, hopefully I can explain why we aren’t yet!

The short answer? Wayland is too Linux-specific to be easily ported or adapted to NetBSD, so don’t expect it any time soon.


September 29, 2020

Stack Overflow Trouble compiling ncurses-st-menu for BSD

I found a package on github (https://github.com/okbob/ncurses-st-menu) and am having trouble compile it for BSD platforms like NetBSD or OpenBSD. The instructions say to do ./autogen.sh, ./configure, and then make. So I install the autoconf, autotools, libtool, gettext, and any other necessary packages and run ./autogen.sh. It works without spitting out any errors. But ./configure says it doesn't support "OS x86_64-unknown-netbsd9.0" if for example on NetBSD. Can someone else try to compile this program? Because if this was done by autotools, it certainly should support any of the four major BSD operating systems.

Unix Stack Exchange Is NetBSD 'primes' utility or equivalent available in any package on MacOS?

Is the NetBSD primes utility (or equivalent) available on MacOS in any package, other than via manual download-and-compile (e.g. curl)? I searched quite a lot and couldn't find any package (other than the NetBSD CVS source).

(NetBSD primes is not a prime-sieve to find large/as-yet-unknown primes, just a simple command-line utility which tells you which integers are prime (or composite) in a given (64b) range).

(Unlike Gnu factor which is available via package coreutils "Finding Prime Numbers - “factor” command not found on MacOS", "Is there a practical use for the GNU factor command?")

Note: this question does not belong on AskDifferent since there is no brew/macports package.


September 28, 2020

OS News Default window manager switched to CTWM in NetBSD-current

For more than 20 years, NetBSD has shipped X11 with the “classic” default window manager of twm. However, it’s been showing its age for a long time now.

In 2015, ctwm was imported, but after that no progress was made. ctwm is a fork of twm with some extra features – the primary advantages are that it’s still incredibly lightweight, but highly configurable, and has support for virtual desktops, as well as a NetBSD-compatible license and ongoing development. Thanks to its configuration options, we can provide a default experience that’s much more usable to people experienced with other operating systems.

The ctwm website has more information for those interested.

NetBSD Blog Wayland on NetBSD - trials and tribulations

After I posted about the new default window manager in NetBSD I got a few questions, including "when is NetBSD switching from X11 to Wayland?", Wayland being X11's "new" rival. In this blog post, hopefully I can explain why we aren't yet!

Last year (and early this year) I was responsible for porting the first working Wayland compositor to NetBSD - swc. I chose it because it looked small and hackable. You can try it out by installing the velox window manager from pkgsrc.

A Wayland compositor running on my NetBSD laptop, with a few applications like Luakit and Dungeon Crawl Stone Soup open.

Difficulties

In a Wayland system, the "compositor" (display server) is responsible for managing displays, input, and window management. Generally, this means a lot of OS-specific code is contained there.

Wayland does not define protocols for features X11 users expect, like screenshots, screen locking, or window management. Either you implement these inside the compositor (lots of work that has to be redone), or you define your own protocol extension.

The Wayland "reference implementation" is a small set of libraries that can be used to build a compositor or a client application. These libraries currently have hard dependencies on Linux kernel APIs like epoll. In pkgsrc we've patched the libraries to add kqueue(2) support, but the patches haven't been accepted upstream. Wayland is written with the assumption of Linux to the extent that every client application tends to #include <linux/input.h> because Wayland's designers didn't see the need to define a OS-neutral way to get mouse button IDs.

So far, all Wayland compositors but swc have a hard dependency on libinput, which only supports Linux's input API (also cloned in FreeBSD). In NetBSD we have an entirely different input API - wscons(4). wscons is actually fairly simple to write code for, someone just needs to go out there and do it. You can use my code in swc as a reference. :)

In general, Wayland is moving away from the modularity, portability, and standardization of the X server.

Is it ready for production?

No, but you can play with it.

Task list

I've decided to take a break from this, since it's a fairly huge undertaking and uphill battle. Right now, X11 combined with a compositor like picom or xcompmgr is the more mature option.


September 21, 2020

NetBSD Package System (pkgsrc) on DaemonForums samba problem
hi guys ,i need some favour,i install and config samba follow "https://wiki.netbsd.org/tutorials/how_to_set_up_a_samba_server/",
it show " protocol negotiation failed: NT_STATUS_IO_TIMEOUT" when i run "smbclient -Usamba -L localhost" i dont konw what i miss?thanks

and this my step and config file
pkgin install samba
cp /usr/pkg/share/examples/rc.d/smbd /etc/rc.d/
cp /usr/pkg/share/examples/rc.d/nmbd /etc/rc.d/
cp /usr/pkg/share/examples/rc.d/samba /etc/rc.d/
and in /etc/rc.conf
smbd=YES
nmbd=YES
samba=YES
follow is my /usr/pkg/etc/samba/smb.conf
Code:

# smbclient -L localhost
protocol negotiation failed: NT_STATUS_IO_TIMEOUT
# vim /usr/pkg/etc/samba/smb.conf
# cat  /usr/pkg/etc/samba/smb.conf
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) most of which are not shown in this example
#
# For a step to step guide on installing, configuring and using samba,
# read the Samba-HOWTO-Collection. This may be obtained from:
#  http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# Many working examples of smb.conf files can be found in the
# Samba-Guide which is generated daily and can be downloaded from:
#  http://www.samba.org/samba/docs/Samba-Guide.pdf
#
# Any line which starts with a ; (semi-colon) or a # (hash)
# is a comment and is ignored. In this example we will use a #
# for commentry and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not made any basic syntactic errors.
#
#======================= Global Settings =====================================
[global]

# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
  workgroup = WORKGROUP

# server string is the equivalent of the NT Description field
  server string = Samba Server

# Server role. Defines in which mode Samba will operate. Possible
# values are "standalone server", "member server", "classic primary
# domain controller", "classic backup domain controller", "active
# directory domain controller".
#
# Most people will want "standalone server" or "member server".
# Running as "active directory domain controller" will require first
# running "samba-tool domain provision" to wipe databases and create a
# new domain.
#  server role = standalone server

# This option is important for security. It allows you to restrict
# connections to machines which are on your local network. The
# following example restricts access to two C class networks and
# the "loopback" interface. For more examples of the syntax see
# the smb.conf man page
  hosts allow = 192.168.31.

# Uncomment this if you want a guest account, you must add this to /etc/passwd
# otherwise the user "nobody" is used
;  guest account = pcguest

# this tells Samba to use a separate log file for each machine
# that connects
  log file = /var/log/log.%m

# Put a capping on the size of the log files (in Kb).
  max log size = 50

# Specifies the Kerberos or Active Directory realm the host is part of
;  realm = MY_REALM

# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
;  passdb backend = tdbsam

# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting.
# Note: Consider carefully the location in the configuration file of
#      this line.  The included file is read at that point.
;  include = /usr/local/samba/lib/smb.conf.%m

# Configure Samba to use multiple interfaces
# If you have multiple network interfaces then you must list them
# here. See the man page for details.
;  interfaces = 192.168.12.2/24 192.168.13.2/24

# Where to store roving profiles (only for Win95 and WinNT)
#        %L substitutes for this servers netbios name, %U is username
#        You must uncomment the [Profiles] share below
;  logon path = \\%L\Profiles\%U

# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server
;  wins support = yes

# WINS Server - Tells the NMBD components of Samba to be a WINS Client
#      Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
;  wins server = w.x.y.z

# WINS Proxy - Tells Samba to answer name resolution queries on
# behalf of a non WINS capable client, for this to work there must be
# at least one  WINS Server on the network. The default is NO.
;  wins proxy = yes

# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups. The default is NO.
  dns proxy = no

# These scripts are used on a domain controller or stand-alone
# machine to add or delete corresponding unix accounts
;  add user script = /usr/sbin/useradd %u
;  add group script = /usr/sbin/groupadd %g
;  add machine script = /usr/sbin/adduser -n -g machines -c Machine -d /dev/null -s /bin/false %u
;  delete user script = /usr/sbin/userdel %u
;  delete user from group script = /usr/sbin/deluser %u %g
;  delete group script = /usr/sbin/groupdel %g


#============================ Share Definitions ==============================
[homes]
  comment = Home Directories
  browseable = no
  writable = yes

[shared]
comment = Shared
path = /home/zero/work
browseable = yes
writable = yes
guest ok = yes
# Un-comment the following and create the netlogon directory for Domain Logons
; [netlogon]
;  comment = Network Logon Service
;  path = /usr/local/samba/lib/netlogon
;  guest ok = yes
;  writable = no
;  share modes = no


# Un-comment the following to provide a specific roving profile share
# the default is to use the user's home directory
;[Profiles]
;    path = /usr/local/samba/profiles
;    browseable = no
;    guest ok = yes


# NOTE: If you have a BSD-style print system there is no need to
# specifically define each individual printer
[printers]
  comment = All Printers
  path = /usr/spool/samba
  browseable = no
# Set public = yes to allow user 'guest account' to print
  guest ok = no
  writable = yes
  printable = yes

# This one is useful for people to share files
;[tmp]
;  comment = Temporary file space
;  path = /tmp
;  read only = no
;  public = yes

# A publicly accessible directory, but read only, except for people in
# the "staff" group
;[public]
;  comment = Public Stuff
;  path = /home/samba
;  public = yes
;  writable = no
;  printable = no
;  write list = @staff

# Other examples.
#
# A private printer, usable only by fred. Spool data will be placed in fred's
# home directory. Note that fred must have write access to the spool directory,
# wherever it is.
;[fredsprn]
;  comment = Fred's Printer
;  valid users = fred
;  path = /homes/fred
;  printer = freds_printer
;  public = no
;  writable = no
;  printable = yes

# A private directory, usable only by fred. Note that fred requires write
# access to the directory.
;[fredsdir]
;  comment = Fred's Service
;  path = /usr/somewhere/private
;  valid users = fred
;  public = no
;  writable = yes
;  printable = no

# a service which has a different directory for each machine that connects
# this allows you to tailor configurations to incoming machines. You could
# also use the %U option to tailor it by user name.
# The %m gets replaced with the machine name that is connecting.
;[pchome]
;  comment = PC Directories
;  path = /usr/pc/%m
;  public = no
;  writable = yes

# A publicly accessible directory, read/write to all users. Note that all files
# created in the directory by users will be owned by the default user, so
# any user with access can delete any other user's files. Obviously this
# directory must be writable by the default user. Another user could of course
# be specified, in which case all files would be owned by that user instead.
;[public]
;  path = /usr/somewhere/else/public
;  public = yes
;  only guest = yes
;  writable = yes
;  printable = no

# The following two entries demonstrate how to share a directory so that two
# users can place files there that will be owned by the specific users. In this
# setup, the directory should be writable by both users and should have the
# sticky bit set on it to prevent abuse. Obviously this could be extended to
# as many users as required.
;[myshare]
;  comment = Mary's and Fred's stuff
;  path = /usr/somewhere/shared
;  valid users = mary fred
;  public = no
;  writable = yes
;  printable = no
;  create mask = 0765


September 19, 2020

NetBSD General on DaemonForums New Shared Lib on i386
Hi,

NetBSD i386 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020

I have my own personal shared library, which complies and installs fine. When I compile programs that link against that library, the compile succeeds.

But when I attempt to run one of the programs I get:

Quote:

/usr/local/lib/libj_lib.so: text relocations
/usr/local/lib/libj_lib.so: Cannot write-enable text segment: Permission denied
I even tried a reboot without luck.

I did many searches but all I found was issues compiling mplayer and to use ld.so.conf, but nothing else. I read ld.so.conf is no longer needed and man pages has nothing I can find.

Does anyone know what I can do to fix this issue ?

edit: no luck with "-Wl,-R/usr/local/lib" as noted in the elf FAQ

Thanks
John

September 17, 2020

NetBSD General on DaemonForums Howto power off usb devices
Under FreeBSD, I can power off a usb device with usbconfig's "power_off" option. How can I do that under NetBSD?

Code:

# usbstats
Controller /dev/usb0:
      1069 control
        0 isochronous
 154806725 bulk
  8954336 interrupt
Controller /dev/usb1:
      375 control
        0 isochronous
  33390421 bulk
        2 interrupt

# usbdevs
addr 1: EHCI root hub, NetBSD
 addr 2: Rate Matching Hub, Intel
  addr 5: External USB 3.0, Toshiba
  addr 3: USB Optical Mouse, Primax Electronics
  addr 4: Kensington U+P Keyboard, NOVATEK
addr 1: EHCI root hub, NetBSD
 addr 2: Rate Matching Hub, Intel
  addr 3: USB2.0-CRW, Generic

I want to power off (and later on) External USB 3.0, Toshiba, which I believe is at usb0, addr 5.

September 15, 2020

Server Fault Non-standard IP address with dashes

I ran the who command on a shared NetBSD box, and this weird user IP came up:

<redacted> pts/33   May 13 02:13  (XXX.XXX.XXX.XXX)
<redacted> pts/35   May 12 20:59  (202-172-110-147-)
<redacted> pts/36   May  6 20:36  (XXX.XXX.XXX.XXX)

I've never seen an IP like that. Obviously, ping 202-172-110-147- will complain with "Cannot resolve ... (Unknown host)".

There was a similar question posted 7 years ago, which posited that it was a non-standard way of denoting IP ranges, but seeing there's a - at the end of the address, it doesn't seem like a similar thing.


Edit:

I've tried reverse DNS with nslookup 202-172-110-147-, which errors with "** server can't find 202-172-110-147-: NXDOMAIN"

Doing w <user> returns:

9:49AM  up 89 days,  7:46, 1 user, load averages: 0.23, 0.18, 0.17
USER          TTY     FROM              [email protected]  IDLE WHAT
<redacted>    pts/35  202-172-110-147- Tue08PM  4:13

Edit 2: This is on NetBSD, not Linux like I mentioned at the beginning (I thought the box was Linux):

$ uname -rsv
NetBSD 8.1 NetBSD 8.1 (GENERIC) #0: Fri May 31 08:43:59 UTC 2019  [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC

Edit 3: Following @NStorm update, I ran w -n to display network addresses as numbers. I still see the same result

$ w -n <user>
 9:57AM  up 89 days,  7:54, 1 user, load averages: 0.12, 0.12, 0.14
USER          TTY     FROM              [email protected]  IDLE WHAT
<redacted>    pts/35  202-172-110-147- Tue08PM  4:22

September 08, 2020

Benny Siegert pkgsrc Developer Monotony
Somehow, my contributions to NetBSD and pkgsrc have become monotonous. Because I am busy with work, family and real life, the amount of time I can spend on open source is fairly limited, and I have two commitments that I try to fulfill: Member of pkgsrc-releng: I process most of the pull-ups to the stable quarterly branch. Maintainer of Go and its infrastructure. Unfortunately, these things are always kinda the same.

September 07, 2020

Frederic Cambus Playing with Kore JSON API

Kore 4.0.0 has been released a few days ago, and features a brand new JSON API allowing to easily parse and serialize JSON objects.

During the last couple of years, I have been using Kore for various projects, including exposing hardware sensor values over the network via very simple APIs. In this article, I would like to present a generalization of this concept and show how easy it is to expose system information with Kore.

This small API example allows to identify hosts over the network and has been tested on Linux, OpenBSD, NetBSD, and macOS (thanks Joris!).

After creating a new project:

kodev create identify

Populate src/identify.c with the following code snippet:

#include <sys/utsname.h>

#include <kore/kore.h>
#include <kore/http.h>

#if defined(__linux__)
#include <kore/seccomp.h>

KORE_SECCOMP_FILTER("json",
	KORE_SYSCALL_ALLOW(uname)
);
#endif

int		page(struct http_request *);

int
page(struct http_request *req)
{
	char *answer;

	struct utsname u;

	struct kore_buf buf;
	struct kore_json_item *json;

	if (uname(&u) == -1) {
		http_response(req, HTTP_STATUS_INTERNAL_ERROR, NULL, 0);
		return (KORE_RESULT_OK);
	}

	kore_buf_init(&buf, 1024);
	json = kore_json_create_object(NULL, NULL);

	kore_json_create_string(json, "system", u.sysname);
	kore_json_create_string(json, "hostname", u.nodename);
	kore_json_create_string(json, "release", u.release);
	kore_json_create_string(json, "version", u.version);
	kore_json_create_string(json, "machine", u.machine);

	kore_json_item_tobuf(json, &buf);

	answer = kore_buf_stringify(&buf, NULL);
	http_response(req, 200, answer, strlen(answer));

	kore_buf_cleanup(&buf);
	kore_json_item_free(json);

	return (KORE_RESULT_OK);
}

And finally launch the project:

kodev run

The kodev tool will build and run the project, and we can now query the API to identify hosts:

{
  "system": "OpenBSD",
  "hostname": "foo.my.domain",
  "release": "6.8",
  "version": "GENERIC.MP#56",
  "machine": "amd64"
}

September 02, 2020

NetBSD General on DaemonForums restart network
I ran the command
Code:

# ifconfig mue0 down
to take the computer offline, but how do I now bring it back up?
When I try
Code:

# ifconfig mue0 up
I get
Code:

exec_matches: No buffer space available
error

What is the NetBSD equivalent of the FreeBSD command
Code:

# /etc/rc.d/netif restart
or OpenBSD equivalent
Code:

# /etc/netstart
I want to be able to restart all network services

August 31, 2020

Frederic Cambus Modernizing the OpenBSD console

At the beginning were text mode consoles. Traditionally, *BSD and Linux on i386 and amd64 used text mode consoles which by default provided 25 rows of 80 columns, the "80x25 mode". This mode uses a 8x16 font stored in the VGA BIOS (which can be slightly different across vendors).

OpenBSD uses the wscons(4) console framework, inherited from NetBSD.

CRT monitors allowed to set the resolution you wanted, so on bigger monitors a 80x25 console in textmode was fairly large but not blurry.

Framebuffer consoles allowed taking advantage of larger monitor sizes, to fit more columns and row. With the switch to LCD monitors, also in part driven by the decreasing costs of laptops, the fixed size panels became a problem as the text mode resolution needed to be stretched, leading to distortion and blurriness.

One thing some people might not realize, is the huge discrepancy between text mode and framebuffer consoles regarding the amount of data you have to write to cover the whole screen. In text mode, we only need to write 2 bytes per character: 1 byte for the ASCII code, and 1 byte for attributes. So in 80x25 text mode, we only need to write 80 * 25 * 2 bytes of data, which is 4000 bytes, and the VGA card itself takes care of plotting characters to the screen. In framebuffer however, to fill a 4K UHD-1 (3840x2160) screen in 32bpp mode we need to send 3840 * 2160 * 4 bytes of data, which is 33177600 bytes (approximately 33 MB).

On framebuffer consoles, OpenBSD uses the rasops(9) subsystem (raster operations), imported from NetBSD in 2001.

While they had been used for a while on platforms without VGA cards, framebuffer consoles were only enabled on i386 and amd64 in 2013 for inteldrm(4) and radeondrm(4).

In recent years, rasops(9) itself and framebuffer drivers have seen some improvements:

General improvements:

Performance related improvements:

Console fonts improvements:

There is an article about Spleen in the OpenBSD Journal with more information, notably on the font selection mechanism relative to screen resolution.

And work slowly continues to make framebuffer consoles more usable.

It is interesting to note that while NetBSD has been adding a lot of features to rasops(9) over the years, OpenBSD has taken a more conservative approach. There is however one major feature that NetBSD currently has which would be beneficial: the capability for loading fonts of different metrics and subsequently resizing screens.

Looking forward, performance of various operations could likely still be improved, possibly by leveraging the new OpenBSD dynamic tracing mechanism to analyze bottlenecks.

Another open question is UTF-8 support, Miod Vallat started work in this direction back in 2013 but there are still a few things missing. I have plans to implement sparse font files support in the future, at least so one can take advantage of box drawing and possibly block elements characters.

Lastly, a major pain point has been the lack of larger fonts in RAMDISK kernels, making installations and upgrades very difficult and error-prone on large DPI monitors as the text is basically unreadable. There is no technical blocker to make this happen, which ironically makes it the most difficult kind of issue to tackle.