blog.netbsd.org.atom.xml - sfeed_tests - sfeed tests and RSS and Atom files
(HTM) git clone git://git.codemadness.org/sfeed_tests
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
blog.netbsd.org.atom.xml (280500B)
---
1 <?xml version="1.0" encoding='utf-8'?>
2 <?xml-stylesheet type="text/xsl" href="https://blog.netbsd.org/roller-ui/styles/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom">
3 <title type="html">NetBSD Blog</title>
4 <subtitle type="html"></subtitle>
5 <id>https://blog.netbsd.org/tnf/feed/entries/atom</id>
6 <link rel="self" type="application/atom+xml" href="https://blog.netbsd.org/tnf/feed/entries/atom" />
7 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/" />
8 <updated>2022-03-09T23:57:54+00:00</updated>
9 <generator uri="http://roller.apache.org" version="5.0.3 (1388864191739:dave)">Apache Roller (incubating)</generator>
10 <entry>
11 <id>https://blog.netbsd.org/tnf/entry/making_rockpro64_a_netbsd_server</id>
12 <title type="html">Making RockPro64 a NetBSD Server</title>
13 <author><name>matthew green</name></author>
14 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/making_rockpro64_a_netbsd_server"/>
15 <published>2022-03-09T23:57:54+00:00</published>
16 <updated>2022-03-09T23:57:54+00:00</updated>
17 <category term="/General" label="General" />
18 <category term="rockpro64" scheme="http://roller.apache.org/ns/tags/" />
19 <category term="aarch64" scheme="http://roller.apache.org/ns/tags/" />
20 <category term="pine64" scheme="http://roller.apache.org/ns/tags/" />
21 <category term="evbarm" scheme="http://roller.apache.org/ns/tags/" />
22 <category term="aarch64eb" scheme="http://roller.apache.org/ns/tags/" />
23 <content type="html"><p>The time has come to upgrade my SunBlade 2500s to something more power friendly and faster. I'd already removed one CPU and thus half the ram from two of these systems to reduce their power consumption, but it's still much higher than it could be.</p>
24
25 <p>After much searching, I've decided on <a href="https://wiki.pine64.org/wiki/ROCKPro64">Pine64's RockPro64</a> 4GiB ram model (technically, only 3.875GiB ram.) Pine64 make SBCs, laptops, phones, and various other mostly ARM gadgets, and the RockPro64 has the fastest CPU they ship (Rockchip RK3399), and can use a small "NAS Case", that is sufficient to house 2 HDDs and, at a stretch, upto 6 SSDs (cooling would become quite an issue at this point.)</p>
26
27 <p>In my SATA setup, I have 3 SSDs with a JMicron 585 card in the PCIe slot, two SSDs in the NAS case SSD region, and the third is in the HDD region with an adapter. I have used two SATA power splitters to convert the NAS case's 2 SATA power ports into 4, with the 4th one also powering a Noctua case fan. The cabling is not great with this, with enough SATA power cabling for 6 devices to lay. Probably a bespoke power cable to connect to the RockPro64 would make this nicer and probably improve cooling slightly, but I'm just using off-the-shelf components for now.</p>
28
29
30 <p>In the last year or so I've been working on making NetBSD/arm64 big-endian more featureful. In particular, I've added support for:
31 <ul><li>other-endian access disklabels, FFS file-systems in the NetBSD libsa</li>
32 <li>the "look 64 sectors later" for RAIDFrame partitions in MI efiboot (the x86 specific efiboot has more extensive support for this that should be ported over)</li>
33 <li>other-endian access to RAIDFrame labels in the kernel</li>
34 <li>updated the U-Boot package and featureset to include AHCI/SATA support, workaround some bugs and fix the newer U-Boot SPI loader location, and figured out how to default loading from either SATA or NVMe</li>
35 </ul></p>
36 <p>There are not too many special actions needed for this sort of setup compared to a normal NetBSD or Arm system. While I built my installations by hand, the standard NetBSD Arm images are suitable for this task. It's easiest to start from an SD card with the RockPro64 u-boot installed. There are two U-Boot images available, one for SD/eMMC, and one for SPI (there is an odd problem with the early SPI loader that requires a portion of the image to be different.) The pkgsrc package for sysutils/u-boot-rockpro64 version 2022.01 has these suggested methods for installing the U-Boot image (this package should be buildable on any supported pkgsrc platform).</p>
37
38 <p>To install U-Boot into the SD/eMMC card (can run on any system, the image must be written at 32KiB into the device):
39 <pre>
40 # dd if=/usr/pkg/share/u-boot/rockpro64/rksd_loader.img seek=64 of=/dev/rld0c
41 </pre>
42 <p>
43 To install U-Boot into the SPI flash (must be run on the host, and lives at the very start of the device:
44 <pre>
45 # dd if=/usr/pkg/share/u-boot/rockpro64/rkspi_loader.img bs=64k of=/dev/spiflash0
46 </pre>
47 </p>
48
49 <p>When booting from NVMe or SATA, one must drop to the U-Boot prompt and adjust the "boot_targets" value to put scsi* (SATA) or nvme* ahead of the mmc* and usb* options.</p>
50
51 <p>The original value for me:
52 <pre>
53 => printenv boot_targets
54 boot_targets=mmc1 usb0 mmc0 nvme0 scsi0 pxe dhcp sf0
55 </pre>
56 </p>
57
58 <p>Which is then adjusted and saved with eg:
59 <pre>
60 => setenv boot_targets nvme0 scsi0 mmc1 usb0 mmc0 pxe dhcp sf0
61 => saveenv
62 Saving Environment to SPIFlash... Erasing SPI flash...Writing to SPI flash...done
63 OK
64 </pre></p>
65
66 <p>(In this list, mmc1 is the SD slot, mmc0 is the eMMC card, pxe and dhcp are netbooting, and sf0 attempts to load further U-Boot scripts from SPI.)</p>
67
68 <p>There are some minor issues with the RockPro64. It has no ability to use ECC memory. It only comes with 1 PCIe 4x slot, and Rockchip errata limited this to PCIe 1.x (though no NetBSD users encounted any issues with PCIe 2.x enabled, and this can be forced back on via a DTS patch.) It is possible to use a PCIe bridge (I have never done this, though I would like to try in the future) to enable more devices for booting, or to enable both a network and storage device.</p>
69 </content>
70 </entry>
71 <entry>
72 <id>https://blog.netbsd.org/tnf/entry/project_report_add_support_for</id>
73 <title type="html">Project Report: Add support for chdir(2) support in posix_spawn(3)</title>
74 <author><name>martin</name></author>
75 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/project_report_add_support_for"/>
76 <published>2021-11-22T18:01:54+00:00</published>
77 <updated>2021-11-23T16:38:20+00:00</updated>
78 <category term="/Development" label="Development" />
79 <category term="projects" scheme="http://roller.apache.org/ns/tags/" />
80 <category term="tnf" scheme="http://roller.apache.org/ns/tags/" />
81 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
82 <summary type="html"><p>Piyush Sachdeva finished the "add chdir support to posix_spawn(3)" project and reports about his work and experience.
83 His code is already in -current and will be part of NetBSD 10.</p>
84 <p>Originally submitted as a proposal for GSoC, but unfortunately (due to low slot allocations) this project was not part of GSoC.</p>
85 <p>The NetBSD Foundation decided to nevertheless run the project and funded it.</p></summary>
86 <content type="html"><h3>This post was written by Piyush Sachdeva:</h3>
87
88 <h2>Abstract</h2>
89
90 <p>The primary goal of the project was to extend posix_spawn(3) to include chdir(2)
91 for the newly created child process. Two functions were supposed to be implemented,
92 namely posix_spawn_file_actions_addchdir() and
93 posix_spawn_file_actions_addfchdir(), to support both chdir(2) and
94 fchdir(2) respectively.
95 posix_spawn() is a POSIX standard method
96 responsible for creating and executing new child processes.</p>
97
98 <h2>Implementation</h2>
99 <p>The original code can be found at <a href="https://github.com/cosmologistPiyush/posix_spawn-chdir/tree/trunk">my github tree</a>.</p>
100 <p>The implementation plan was discussed and made with the guidance of both my
101 mentors Martin Husemann and Joerg Sonnenberger. The plan was divided into
102 three phases each corresponding to the specific part of The NetBSD code-base which is
103 supposed to be touched:</p>
104
105 <h3>User-Land</h3>
106 <p>The following actions were performed in the user-land to set things up for the
107 kernel-space.
108 <ul>
109 <li>Add another member to the posix_spawn_file_actions_t struct i.e a union,
110 which would hold the path to chdir to.</li>
111 </li>
112 <li>Implement the two functions posix_spawn_file_actions_addchdir()
113 and posix_spawn_file_actions_addfchdir(). These functions would:
114 <ol>
115 <li>allocate memory for another posix_spawn_file_actions_t object in the
116 posix_spawn_file_actions_t array.</li>
117 <li>take the path/file descriptor from the user as an argument and make the
118 relative field of the newly allocated file actions object, point to it.</li>
119 </ol>
120 </li>
121 <li>The final step was to add the prototypes for the two new functions to the
122 `src/include/spawn.h' header file
123 </li>
124 </ul>
125
126 <p>
127 Once the aforementioned changes were made, the only thing left to do was to make the
128 kernel support these two new functions.</p>
129
130 <h3>Kernel-Space</h3>
131 <p>The following actions were performed inside the kernel space.</p>
132 <ul>
133 <li>The three functions in the `src/sys/kern_exec.c' file which correspond to the
134 posix_spawn_file_actions were edited:
135 <ul>
136 <li>posix_spawn_fa_alloc() was adjusted to make sure that the path passed to
137 posix_spawn_file_actions_addchdir() gets copied from the user-land
138 to the kernel-space.
139 </li>
140 <li>Similarly posix_spawn_fa_free() was adjusted to make sure that the
141 memory allocated in case of FAE_CHDIR gets freed as well.
142 </li>
143 <li>Finally, two new cases FAE_CHDIR &amp; FAE_FCHDIR were added in the
144 handle_posix_spawn_file_actions(). In each of the cases,
145 a call to one of the two newly created functions (discussed in the next point)
146 do_sys_chdir() and do_sys_fchdir() was made respectively.
147 </li>
148 </ul>
149
150 <p>Note: At the time of code integration, a helper function was written by
151 Christos Zoulas. This function aimed to reduce the amount of repeated code
152 in both posix_spawn_fa__free() and posix_spawn_fa_alloc()</p>
153 </li>
154
155 <li>Two new functions, similar to the already present sys_chdir() and sys_fchdir() in
156 `src/sys/vfs_syscalls.c' were created. Namely do_sys_chdir() and do_sys_chdir
157 were written with two specific thoughts in mind:
158 <ul>
159 <li>By default sys_chdir() and sys_fchdir() took syscallargs as a parameter.
160 The purpose of the new functions was to replace this with
161 const char * and an int type parameter respectively.</li>
162 <li>The do_sys_chdir() also replaced UIO_USERSPACE with
163 UIO_SYSSPACE. This was done because the chdir path passed to this
164 function already resided in the Kernel-space due to the change made in
165 posix_spawn_fa_alloc().</li>
166 </ul></li>
167 <li>Finally, the prototypes for the newly written functions were added to the
168 `src/sys/sys/vfs_syscalls.h' file and this file was also included in the
169 'sys/kern/kern_exec.c'.</li>
170
171 </ul>
172
173 <p>Note: Similar to the above changes of user-land and kernel-space, a few tweaks were also made to
174 `src/sys/compat/netbsd/netbsd32.h' and `netbsd32_execve.c'. This was required to help COMPAT_NETBSD32
175 deal with the new file actions member. However, these changes were made at the time of integration
176 by Martin Husemann.</p>
177
178
179 <p>With most of addition of new features being done, all that remained was testing and documentation.</p>
180
181
182 <h3>Testing &amp; Documentation</h3>
183 <ul>
184 <li>A total of ten new test cases have been added to the
185 `src/tests/lib/libc/gen/posix_spawn/t_spawn.c' file.</li>
186 <li>Three utility functions were also used to aid in testing. Out of the three,
187 one new function was written and two existing functions (filesize()
188 and empty_outfile()) from `t_fileactions.c' were used.
189 To make sure that the 2 existing functions were shared between both the files i.e `t_spawn.c'
190 and `t_fileactions.c' a new header and C file was created, namely `fa_spawn_utils.h' and
191 `fa_spawn_utils.c'.
192 Following this, the bodies of both the functions were moved from
193 `t_fileactions.c' to `fa_spawn_utils.c' and their prototypes were added to the
194 corresponding header file.</li>
195 <li>The general approach that was taken to all test cases was to make
196 posix_spawn() execute ``/bin/pwd'' and write the output to a file.
197 Then read the file and do string comparison. The third function i.e. check_succes()
198 was written for just this purpose.</li>
199 <li>The ten test cases cover the following scenarios:
200 <ul>
201 <li>Absolute path test - for both chdir and fchdir.</li>
202 <li>Relative path test - for both chdir and fchdir.</li>
203 <li>Trying to open a file instead of directory - for both chdir and fchdir.</li>
204 <li>Invalid path/file descriptor (fd=-1) - for both chdir and fchdir.</li>
205 <li>Trying to open a directory without access permissions for chdir.</li>
206 <li>Opening a closed file descriptor for fchdir.</li>
207 </ul></li>
208 <li>The first 8 test cases had a lot of repetitive code. Therefore, at the time of integration,
209 another function was created i.e spawn_chdir().
210 This function included a huge chunk of the common code and it did all the heavy lifting
211 for those first 8 test cases.</li>
212 </ul>
213
214 <h4>Documentation:</h4>
215 <p>In this matter, a complete man page is written which explains both
216 posix_spawn_file_actions_addchdir() and posix_spawn_file_actions_addfchdir() in great detail.
217 The content of the manual page is taken from the POSIX documentation provided to us by Robert Elz.
218 </p>
219
220
221 <h2>Issues</h2>
222 <p>Since the project was well planned from the beginning, it resulted in few issues.</p>
223 <ul>
224 <li>The user-land was the most straight forward part of the project and I had no
225 trouble sailing through it.</li>
226 <li>Kernel space was where things got a bit complicated, as I had to add functionality
227 to pre-existing functions.</li>
228 <li>I was completely new to using atf(7) and groff(1). Therefore, it took me some time
229 to understand the respective man pages and become comfortable with testing and
230 documentation part.</li>
231 </ul>
232
233 <p>
234 Most of the issues faced were generally logistical. As it was my first time doing a
235 kernel project, I was new to building from source, Virtual Machines and other things like SSH.
236 But luckily, I had great help from my mentors and the entire NetBSD community.</p>
237
238 <h2>Thanks</h2>
239 <p>I would like to express my heartfelt gratitude to The NetBSD Foundation for
240 giving me this opportunity and sponsoring the Project.
241 This project would not have been possible without the constant support and
242 encouragement of both my mentors Martin Husemann and Joerg Sonnenberger.
243 My gratitude to Christos Zoulas who worked on the crucial part of integrating the code.
244 A special mention to all of the other esteemed NetBSD developers,
245 who have helped me navigate through the thick and thin of this project and
246 have answered even my most trivial questions.</p>
247 </content>
248 </entry>
249 <entry>
250 <id>https://blog.netbsd.org/tnf/entry/wifi_project_status_update</id>
251 <title type="html">wifi project status update</title>
252 <author><name>martin</name></author>
253 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/wifi_project_status_update"/>
254 <published>2021-08-26T17:46:53+00:00</published>
255 <updated>2021-08-26T17:46:53+00:00</updated>
256 <category term="/Development" label="Development" />
257 <category term="funded" scheme="http://roller.apache.org/ns/tags/" />
258 <category term="wifi" scheme="http://roller.apache.org/ns/tags/" />
259 <category term="freebsd" scheme="http://roller.apache.org/ns/tags/" />
260 <summary type="html"><p>About a year ago the <a href="/tnf/entry/wifi_renewal_restarted">wifi renewal project</a> got restarted. A lot things happened, but the high hopes of a quick breakthrough and fast merge to mainline did not come true.</p>
261 <p>Here is where we are today, what needs to be done and how things are planned to move on...</p></summary>
262 <content type="html"><p>After initial work on the <a href="https://wiki.NetBSD.org/Wifi_renewal_on_hg/">wifi renewal branch</a> went quite fast and smooth, things have slowed down a bit in the last few months.</p>
263
264 <p>Most of the slow down was due to me not being available for this type of work for unexpectedly long times - a problem that should be fixed now.</p>
265
266 <p>However, there were other obstacles and unexpected issues on the way:</p>
267 <ul>
268 <li>bpf taps are handled differently in the new stack and some slightly obscure site conditions of this had been overlooked in the initial conversion. To make everything work, changes to our bpf framework were needed (and have landed in -current some time ago now).</li>
269 <li>Many wifi drivers seem to be in a, let's say, slightly fragile state. When testing the random collection of wifi hardware that I acquired during this project in -current, many drivers did not work at first try and often I was able to provoke kernel panics quickly.
270 This is not a happy base to start converting drivers from.</li>
271 <li>After the great success of usbnet(9) for USB ethernet drivers, core and I agreed to do the same for wifi - the result is called usbwifi(9) and makes conversion of usb drivers a lot easier than other wifi drivers. See <a href="https://wiki.NetBSD.org/tutorials/converting_usb_drivers_to_usbwifi__40__9__41__/">the conversion instructions</a> for more details. usbwifi(9) is both quite similar but also quite different to usbnet(9), mostly for two reasons: it interfaces to a totally different stack, and many usb wlan chipsets are more complex than ethernet chipsets (e.g. have support for multiple send queues with different priorities). Developing usbwifi did cost quit some time (initially unplanned), but is expected to amortize over the next few drivers and quickly end up as a net win.</li>
272 <li>I have been hitting a bug in the urtwn(4) driver used for inial usbwifi(9) development and still not found it (as of today). It seems to hit randomly and not be caused by the usbwifi(9) conversion - a fact that I found out only recently. So for now I will put this driver aside (after spending *way* too much time on it) and instead work on other usb drivers, returning to the bug every now and then and see if I can spot it. Maybe I can borrow a USB analyzer and get more insight that way.</li>
273 </ul>
274
275 <p>The current state of driver conversion and what drivers are still open are listed in <a href="https://wiki.NetBSD.org/Driver_state_matrix/">the wifi driver conversion matrix</a>.</p>
276
277 <p>Next steps ahead are:</p>
278 <ul>
279 <li><s>make another pass over documentation and improve things / fixup for recent changes</s> (done before this blog post got published)</li>
280 <li>sync the branch with HEAD and keep tracking it more closely</li>
281 <li>convert run(4) to usbwifi</li>
282 <li>revisit rtwn(4) and decide if/how it should be merged with urtwn(4)</li>
283 <li>revisit iwm(4) and make it work fully</li>
284 <li>convert all other drivers, starting with the ones I have hardware for</li>
285 </ul>
286
287 <p>Currently it is not clear if this branch can be merged to HEAD before branching for netbsd-10. We will not delay the netbsd-10 branch for this.</p>
288 </content>
289 </entry>
290 <entry>
291 <id>https://blog.netbsd.org/tnf/entry/support_for_chdir_2_in</id>
292 <title type="html">Support for chdir(2) in posix_spawn(3)</title>
293 <author><name>martin</name></author>
294 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/support_for_chdir_2_in"/>
295 <published>2021-06-10T15:28:05+00:00</published>
296 <updated>2021-06-10T15:28:05+00:00</updated>
297 <category term="/Development" label="Development" />
298 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
299 <category term="posix_spawn" scheme="http://roller.apache.org/ns/tags/" />
300 <summary type="html"><p>Piyush Sachdeva is working on an extension to NetBSD's posix_spawn system call implementation and library support.</p>
301
302 <p>He applied as a GSoC student, but unfortunately we only got a single slot from Google this year, so The NetBSD Foundation
303 offered Piyush to work on it by TNF funding outside of the official GSoC.</p>
304
305 <p>In this post Piyush introduces himself and the project. He already started with the work... </p></summary>
306 <content type="html"><h3>This post was written by Piyush Sachdeva:</h3>
307
308 <p>What really happens when you double click an icon on your desktop?</p>
309
310 <h1>Support for chdir(2) in posix_spawn(3)</h1>
311
312 <p>Processes are the bread and butter of your operating system. The moment
313 you double click an icon, that particular program gets loaded in your
314 Random Access Memory (RAM) and your operating system starts to run it. At
315 this moment the program becomes a process. Though you can only see the execution
316 of your process, the operating system (the Kernel) is always running a lot
317 of processes in the background to facilitate you.</p>
318
319 <p>From the moment you hit that power button, everything that happens on the
320 screen is the result of some or the other process. In this post we are
321 going to talk about one such interface which helps in creation of your
322 programs.</p>
323
324 <h2>The fork() & exec() shenanigans</h2>
325
326 <p>The moment a computer system comes alive, it launches a bunch of
327 processes. For the purpose of this blog let&#x2019s call them, &#x2018the master
328 processes&#x2019. These processes run in perpetuity, provided the computer is
329 switched on. One such process is <a href="#note1">init/systemd/launchd (depending on your OS)</a>.
330 This &#x2018init&#x2019 master process owns all the other processes in the computer,
331 either directly or indirectly.</p>
332
333 <p>Operating systems are elegant, majestic software that work
334 seamlessly under the hood. They do so much without even breaking a sweat
335 (unless it&#x2019s Windows). Let's consider a scenario where you have decided to
336 take a trip down memory lane and burst open those old photos. The &#x2018init
337 master process&#x2019 just can&#x2019t terminate itself and let you look at your
338 photos. What if you unknowingly open a malicious file, which corrupts all
339 your data? So init doesn&#x2019t just exit, rather it employs fork() and exec()
340 to start a new process. The fork() function is used to create child
341 processes which are an exact copy of their parents. Whichever process calls
342 fork, gets duplicated. The newly created process becomes the child of the
343 original running process and the original running process is called the
344 parent. Just how parents look after their kids, the parent process makes
345 sure that the child process doesn't do any mischief. So now you have two
346 exactly similar processes running in your computer.</p>
347
348 <img id="flowchar", src="//www.NetBSD.org/~martin/flowchart.jpg", alt="Flowchart of fork() + exec()", width="960", height="362", object-fit="contain">
349
350 <p>One might think that the newly created child process doesn&#x2019t really help
351 us. But actually, it does. Now exec() comes into the picture. What exec()
352 does is, it replaces any process which calls it. So what if we replace the child
353 process, the one we just thought to be useless, with our photos? That's
354 exactly what we are going to do indeed. This will result in replacement of
355 the fork() created child process with your photos. Therefore, the master
356 init process is still running and you can also enjoy your photos with no
357 threat to your data.</p>
358
359
360 <cite>
361 &#x201cNeither abstraction nor simplicity is a substitute for getting it right.
362 Sometimes, you just have to do the right thing, and when you do, it is way
363 better than the alternatives. There are lots of ways to design APIs for
364 process creation; however, the combination of fork() and exec() is simple
365 and immensely powerful. Here, the UNIX designers simply got it right.&#x201d
366 </cite> <a href="#note2">Lampson&#x2019s Law - Getting it Right</a>
367
368 <p>Now you could ask me, `But what about the title, some &#x2018posix_spawn()&#x2019
369 thing?´ Don&#x2019t worry, that&#x2019s next.</p>
370
371 <h2>posix_spawn()</h2>
372
373 <p>posix_spawn() is an alternative to the fork() + exec() routine. It
374 implements fork() and exec(), but not directly (as that would make it
375 slow, and we all need everything to be lightning fast). What actually
376 happens is that posix_spawn() only implements the functionality of the
377 fork() + exec() routines, but in one single call. However, because fork() +
378 exec() is a combination of two different calls, there is a lot of room for
379 customization. Whatever software you are running on your computer, calls
380 these routines on its own and does the necessary. Meanwhile a lot is
381 cooking in the background. Between the call to fork() and exec() there is
382 plenty of leeway for tweaking different aspects of the exec-ing process.
383 But posix_spawn doesn&#x2019t bear this flexibility and therefore has a lot of
384 limitations. It does take a lot of parameters to give the caller some
385 flexibility, but it is not enough.</p>
386
387 <p>Now the question before us is,
388 &#x201cIf fork() + exec() is so much more powerful, then why have,
389 or use the posix_spawn() routine?&#x201d The answer to that is, that
390 <a href="#note3">fork() and exec()</a> are UNIX system routines.
391 They are not present in operating systems that are not a derivative of UNIX.
392 Eg- Windows implements a family of spawn functions.<br/>
393 There is another issue with fork() (not exec() ), which in reality is one
394 of the biggest reasons behind the growth of posix_spawn(). The outline of
395 the issue is that, creating child processes in multi-threaded programs is a
396 whole another ball game altogether.</p>
397
398
399 <p>Concurrency is one of those disciplines in operating systems where the
400 order in which the cards are going to unravel is not always how you expect
401 them to. Multi-threading in a program is a way to do different and independent tasks of a
402 program simultaneously, to save time. No matter how jazzy or intelligent the above statement looks,
403 multi-threaded programs require an eagle&#x2019s eye as they can often have a lot
404 of holes. Though the &#x201ctasks&#x201d are different and independent, they often
405 share a few common attributes. When these different tasks due to
406 concurrency start running in parallel, a data race begins to access those
407 shared attributes. To not wreak havoc, there are mechanisms through which,
408 when modifying/accessing these common attributes (Critical Section) we can
409 provide a sort of mutual exclusion (locks/conditional variables) - only
410 letting one of the processes modify the shared attribute at a time. Here
411 when things are already so intricate due to multithreading, and to top it
412 off, we start creating child processes. Complications are bound to arise.
413 When one of the threads from the multi-threaded program calls fork() to
414 create a child process, fork() does clone everything (variables, their
415 states, functions, etc) but it fails to clone other threads (though this is not
416 required at all times).</p>
417
418 <p>The child process now knows only about that one thread which called fork().
419 But all the other attributes of the child that were inherited from
420 the parent (locks, mutexes) are set from the parent&#x2019s address space
421 (considering multiple threads). So there is no way for the child process to
422 know which attributes conform to which parts of the parent. Also, those
423 mechanisms that we used to provide mutual exclusion, like locks and
424 conditional variables, need to be reset. This reset step is essential
425 in letting the parent access it&#x2019s attributes. Failing this reset can cause deadlocks.
426 To put it simply, you can see how difficult things
427 have become all of a sudden. The posix_spawn() call is free from these
428 limitations of fork() encountered in multi-threaded programs. However, as
429 mentioned by me earlier, there needs to be enough rope to meet all the
430 requirements before posix_spawn() does the implicit exec().</p>
431
432
433 <h2>About my Project</h2>
434
435 <p>Hi, I am Piyush Sachdeva and I am going to start a project which will focus
436 on relaxing one limitation of posix_spawn - changing the current directory
437 of the child process, before the said call to exec() is made. This is not
438 going to restrict it to the parent&#x2019s current working directory. Just
439 passing the new directory as one of the parameters will do the trick.
440 Resolving all the impediments would definitely be marvelous. Alas! That is
441 not possible. Every attempt to resolve even a single hindrance can create
442 plenty of new challenges.</p>
443
444 <p>As already mentioned by me, posix_spawn() is a POSIX standard. Hence the
445 effect of my project will probably be reflected in the next POSIX release.
446 I came across this project through Google Summer of Code 2021. It was being
447 offered by The NetBSD Foundation Inc. However, as the slots for
448 Google Summer of Code were numbered, my project didn&#x2019t make the selection.
449 Nevertheless, the Core Team at The NetBSD Foundation offered me to work on
450 the project and even extended a handsome stipend. I will forever be
451 grateful to The NetBSD Foundation for this opportunity.</p>
452
453 <h2>Notes</h2>
454
455 <ul>
456 <li>init, systemd & launchd are system daemon processes. init is the
457 historical process present since System III UNIX. systemd was the replacement
458 for the authentic init which was written for the Linux kernel.
459 launchd is the MacOS alternative of init/systemd.</li>
460
461 <li>This is taken from Operating Systems: The Three Easy Pieces book by
462 Andrea C. Arpaci-Dusseau and Remzi H. Arpaci-Dusseau.</li>
463
464 <li>UNIX is the original AT&T UNIX operating system developed at the Bell
465 Labs research center, headed by Ken Thompson and Dennis Ritchie.</li>
466 </ul>
467
468 <h2>References</h2>
469
470 <ol>
471 <li> <a name="note1"> Operating Systems: Three Easy Pieces by Andrea C. Arpaci-Dusseau and
472 Remzi H. Arpaci-Dusseau.</a></li>
473 <li> <a name="note2"> Advanced Programming in the UNIX Environment by W. Richard Stevens
474 and Stephen A. Rago.</a></li>
475 <li> <a name="note3">UNIX and Linux System Administration Handbook by Evi Nemeth, Garth
476 Synder, Trent R. Hein, Ben Whaley and Dan Mackin.</a></li>
477 </ol></content>
478 </entry>
479 <entry>
480 <id>https://blog.netbsd.org/tnf/entry/public_netbsd_irc_channels_moved</id>
481 <title type="html">Public NetBSD IRC chat channels moved to Libera</title>
482 <author><name>Nia Alarie</name></author>
483 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/public_netbsd_irc_channels_moved"/>
484 <published>2021-05-30T18:23:29+00:00</published>
485 <updated>2021-05-30T18:24:49+00:00</updated>
486 <category term="/General" label="General" />
487 <summary type="html"><pHi everyone,</p>
488
489 <p>Due to the unfortunate situation regarding changes in administration on
490 freenode.net, and the resulting chaos, we have decided to move the public
491 NetBSD IRC channels from freenode to irc.libera.chat.</p>
492
493 <p>This includes:</p>
494
495 <ul>
496 <li><a href="https://web.libera.chat/#NetBSD">#NetBSD</a> - general discussion</li>
497 <li><a href="https://web.libera.chat/#netbsd-code">#netbsd-code</a> - development discussion</li>
498 <li><a href="https://web.libera.chat/#pkgsrc">#pkgsrc</a> - pkgsrc (primarily development) discussion</li>
499 </ul>
500
501 <p>You can find information on connecting to Libera at <a href="https://libera.chat">https://libera.chat/</a></p></summary>
502 <content type="html"><p>Hi everyone,</p>
503
504 <p>Due to the unfortunate situation regarding changes in administration on
505 freenode.net, and the resulting chaos, we have decided to move the public
506 NetBSD IRC chat channels from freenode to irc.libera.chat.</p>
507
508 <p>This includes:</p>
509
510 <ul>
511 <li><a href="https://web.libera.chat/#NetBSD">#NetBSD</a> - general discussion</li>
512 <li><a href="https://web.libera.chat/#netbsd-code">#netbsd-code</a> - development discussion</li>
513 <li><a href="https://web.libera.chat/#pkgsrc">#pkgsrc</a> - pkgsrc (primarily development) discussion</li>
514 </ul>
515
516 <p>You can find information on connecting to Libera at <a href="https://libera.chat">https://libera.chat/</a></p></content>
517 </entry>
518 <entry>
519 <id>https://blog.netbsd.org/tnf/entry/netbsd_9_2_released</id>
520 <title type="html">NetBSD 9.2 released</title>
521 <author><name>Nia Alarie</name></author>
522 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/netbsd_9_2_released"/>
523 <published>2021-05-17T14:06:03+00:00</published>
524 <updated>2021-05-17T14:37:04+00:00</updated>
525 <category term="/Release engineering" label="Release engineering" />
526 <summary type="html"><p> The NetBSD Project is pleased to announce NetBSD 9.2 "Nakatomi Socrates", the second update of the NetBSD 9 release branch.</p>
527
528 <p>As well as the usual bug, stability, and security fixes, this release includes: support for exporting ZFS filesystems over NFS, various updates to the bozotic HTTP daemon, improvements to ARM 32-bit and Linux compatibility, <code>fread()</code> performance improvements, support for the TP-Link TL-WN821N V6 wireless adapter, support for the Allwinner H5 cryptographic accelerator, Pinebook Pro display brightness fixes, new defaults for <code>kern.maxfiles</code>, and accessibility improvements for the default window manager configuration.</p>
529
530 <p><a href="//www.NetBSD.org/releases/formal-9/NetBSD-9.2.html">Release notes and download links for NetBSD 9.2</a></p></summary>
531 <content type="html"><p> The NetBSD Project is pleased to announce NetBSD 9.2 "Nakatomi Socrates", the second update of the NetBSD 9 release branch.</p>
532
533 <p>As well as the usual bug, stability, and security fixes, this release includes: support for exporting ZFS filesystems over NFS, various updates to the bozotic HTTP daemon, improvements to ARM 32-bit and Linux compatibility, <code>fread()</code> performance improvements, support for the TP-Link TL-WN821N V6 wireless adapter, support for the Allwinner H5 cryptographic accelerator, Pinebook Pro display brightness fixes, new defaults for <code>kern.maxfiles</code>, and accessibility improvements for the default window manager configuration.</p>
534
535 <p><a href="//www.NetBSD.org/releases/formal-9/NetBSD-9.2.html">Release notes and download links for NetBSD 9.2</a></p></content>
536 </entry>
537 <entry>
538 <id>https://blog.netbsd.org/tnf/entry/aiomixer_x_open_curses_and</id>
539 <title type="html">aiomixer, X/Open Curses and ncurses, and other news</title>
540 <author><name>Nia Alarie</name></author>
541 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/aiomixer_x_open_curses_and"/>
542 <published>2021-05-12T13:35:14+00:00</published>
543 <updated>2021-05-12T14:48:40+00:00</updated>
544 <category term="/Development" label="Development" />
545 <summary type="html"><p>aiomixer, X/Open Curses and ncurses, and other news</p></summary>
546 <content type="html"><p>
547 aiomixer is an application that I've been maintaining outside of NetBSD for a
548 few years. It was available as a package, and was a "graphical" (curses,
549 terminal-based) mixer for NetBSD's audio API, inspired by programs like alsamixer.
550 For some time I've thought that it should be integrated into the NetBSD
551 base system - it's small and simple, very useful, and many developers
552 and users had it installed (some told me that they would install it on all
553 of their machines that needed audio output).
554 For my particular use case, as well as my NetBSD laptop, I have some small
555 NetBSD machines around the house plugged into speakers that I play music from.
556 Sometimes I like to SSH into them to adjust the playback volume, and it's often
557 easier to do visually than with
558 <a href="https://man.NetBSD.org/mixerctl.1">mixerctl(1)</a>.
559 </p>
560
561 <p>
562 However, there was one problem: when I first wrote aiomixer 2 years ago,
563 I was intimidated by the curses API, so opted to use the
564 <a href="https://invisible-island.net/cdk/">Curses Development Kit</a>
565 instead.
566 This turned out to be a mistake, as not only was CDK inflexible for an
567 application like aiomixer, it introduced a hard dependency on ncurses.
568 </p>
569
570 <h2>X/Open Curses and ncurses</h2>
571
572 <p>
573 Many people think ncurses is the canonical way to develop terminal-based
574 applications for Unix, but it's actually an implementation of the
575 <a href="https://pubs.opengroup.org/onlinepubs/7908799/xcurses/curses.h.html">X/Open Curses specification</a>.
576 There's a few other Curses implementations:
577 </p>
578
579 <ul>
580 <li><a href="https://man.netbsd.org/curses.3">NetBSD libcurses</a></li>
581 <li><a href="https://docs.oracle.com/cd/E36784_01/html/E36880/curses-3curses.html">Solaris libcurses</a></li>
582 <li><a href="https://en.wikipedia.org/wiki/PDCurses">PDCurses</a>, used on Windows</li>
583 </ul>
584
585 <p>
586 NetBSD curses is descended from the original BSD curses, but contains
587 many useful extensions from ncurses as well. We use it all over the
588 base system, and for most packages in pkgsrc.
589 It's also been
590 <a href="https://github.com/sabotage-linux/netbsd-curses">ported to other operating systems</a>,
591 including Linux.
592 As far as I'm aware, NetBSD is one of the last operating systems left
593 that doesn't primarily depend on ncurses.
594 </p>
595
596 <p>
597 There's one crucial incompatibility, however: ncurses exposes its
598 internal data structures, NetBSD libcurses keeps them opaque.
599 Since CDK development is very tied to ncurses development (they have
600 the same maintainer), CDK peeks into those structures, and can't
601 be used with NetBSD libcurses.
602 There are also a few places where ncurses breaks with X/Open Curses,
603 like
604 <a href="https://github.com/irssi/irssi/pull/1305">this case I recently fixed in irssi</a>.
605 </p>
606
607 <h2>Rewriting aiomixer</h2>
608
609 <p>
610 I was able to rewrite aiomixer in a few days using only my free time
611 and NetBSD libcurses. It's now been imported to the base system.
612 It was a good lesson in why Curses isn't actually that intimidating -
613 while there are many functions, they're mostly variations on the
614 same thing. Using Curses directly resulted in a much lighter and
615 more usable application, and provided a much better fit for the
616 types of widgets I needed.
617 </p>
618
619 <p>
620 Many people also provided testing, and I learned a lot about
621 how different terminal attributes should be used in the process.
622 NetBSD is probably one of the few communities where you'll get
623 easy and direct feedback on how to not only make your software
624 work well in a variety of terminal emulators, but also old school
625 hardware terminals. During development, I was also able to find
626 a strange bug in the curses library's window resizing function.
627 </p>
628
629 <p>
630 The API support was also improved, and the new version of aiomixer
631 should work better with a wider variety of sound hardware drivers.
632 </p>
633
634 <a href="https://cdn.netbsd.org/pub/NetBSD/misc/nia/aiomixer2.png"><img src="https://cdn.netbsd.org/pub/NetBSD/misc/nia/aiomixer2.png" width=400" /></a>
635
636 <h2>Other happenings</h2>
637
638 <p>
639 Since I'm done plugging my own work, I thought I might talk
640 a bit about some other recent changes to CURRENT.
641 </p>
642
643 <ul>
644 <li>Most ports of NetBSD now build with GCC 10, thanks to work by mrg.
645 The new version of GCC introduced many new compiler warnings. By
646 default, since NetBSD is compiled with a fixed toolchain version,
647 we use <code>-Werror</code>. Many minor warnings and actual-bugs
648 were uncovered and fixed with the new compiler.</li>
649 <li>On the ARM front, support for the Allwiner V3S system-on-a-chip
650 was introduced thanks to work by Rui-Xiang Guo. This is an
651 older model Allwinner core, primarily used on small embedded
652 devices. It's of likely interest to hardware hackers because it
653 comes in an easily soldered package. A development board is
654 available, the Lichee Pi Zero. Also in the Allwinner world,
655 support for the H3 SoC (including the NanoPi R1) was added
656 to the
657 <a href="https://man.NetBSD.org/sun8icrypto.4">sun8icrypto(4)</a>
658 driver by bad.</li>
659 <li>Support for RISC-V is progressing, including an UEFI
660 bootloader for 64-bit systems, and an in-kernel disassembler.
661 Some NetBSD developers have recently obtained Beagle-V development
662 boards.</li>
663 <li>On the SPARC64 front, support for sun4v is progressing thanks
664 to work by palle. The
665 sun4v architecture includes most newer SPARC servers that are
666 based on the
667 <a href="https://en.wikipedia.org/wiki/Oracle_VM_Server_for_SPARC">Logical Domains</a>
668 architecture - virtualization is
669 implemented at the hardware/firmware level, and operating systems
670 get an abstracted view of the underlying hardware. With other
671 operating systems are discussing removing support for SPARC64, there's
672 an interest among NetBSD developers in adding and maintaining
673 support for this very interesting hardware from Oracle, Fujitsu,
674 and Sun in an open source operating system, not just Oracle
675 Solaris.</li>
676 <li>A kernel-wide audit and rework of the auto-configuration
677 APIs was completed by thorpej.</li>
678 <li>Various new additions and fixes have been made to the
679 networking stack's
680 <a href="https://man.NetBSD.org/pppoe.4">PPP over Ethernet</a>
681 support by yamaguchi.</li>
682 <li>A new API was introduced by macallan that allows adding
683 a <code>-l</code> option to the
684 <a href="https://man.NetBSD.org/wsfontload.8">wsfontload(8)</a>
685 command, allowing easy viewing of the tty fonts currently
686 loaded into the kernel.</li>
687 <li>... OK, I'm not done plugging my own work: I recently
688 wrote new documentation on
689 using
690 <a href="https://www.netbsd.org/docs/guide/en/chap-virt.html">NetBSD for virtualization</a>,
691 <a href="https://www.netbsd.org/docs/guide/en/chap-power.html">Power Management</a>,
692 and rewrote the
693 <a href="https://www.netbsd.org/docs/guide/en/index.html">NetBSD Guide</a>'s sections on
694 <a href="https://www.netbsd.org/docs/guide/en/chap-net-practice.html">Networking in Practice</a>
695 and
696 <a href="https://www.netbsd.org/docs/guide/en/chap-audio.html">Audio</a>.
697 I also recently added support for the
698 <a href="https://en.wikipedia.org/wiki/Neo_(keyboard_layout)">Neo 2 keyboard layout</a>
699 to NetBSD's console system - Neo 2 is a Dvorak-like
700 optimized layout for German and other languages based on
701 multiple layers for alphabetical characters, navigation,
702 and symbols.</li>
703
704 </ul>
705 </content>
706 </entry>
707 <entry>
708 <id>https://blog.netbsd.org/tnf/entry/gsoc_reports_make_system_31</id>
709 <title type="html">GSoC Reports: Make system(3), popen(3) and popenve(3) use posix_spawn(3) internally (Final report)</title>
710 <author><name>Nikita Ronja Gillmann</name></author>
711 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_reports_make_system_31"/>
712 <published>2021-03-30T11:11:15+00:00</published>
713 <updated>2022-02-24T10:36:27+00:00</updated>
714 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
715 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
716 <summary type="html"><i>This report was prepared by Nikita Ronja Gillmann as a part of Google Summer of Code 2020</i>
717
718 <p>This is my second and final report for the Google Summer of Code project I am working on for NetBSD.</p>
719
720 <p>
721 My code can be found at <a href="https://github.com/teknokatze/src/">github.com/teknokatze/src</a> in the gsoc2020 branch, at the time of writing some of it is still missing. The test facilities and logs can be found in <a href="https://github.com/teknokatze/gsoc2020/">github.com/teknokatze/gsoc2020</a>. A diff can be found at <a href="https://github.com/NetBSD/src/compare/trunk...teknokatze:gsoc2020">github</a> which will later be split into several patches before it is sent to QA for merging.
722 </p>
723
724 <p>
725 The initial and defined goal of this project was to <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_make_system_3">make system(3) and popen(3) use posix_spawn(3) internally</a>, which had been completed in June.
726 For the second part I was given the task to replace fork+exec calls in our standard shell (sh) in one scenario. Similar to the previous goal we determine through implementation if the initial motivation, to get performance improvements, is correct otherwise we collect metrics for why posix_spawn() in this case should be avoided. This second part meant in practice that I had to add and change code in the kernel, add a new public libc function, and understand shell internals.
727 </p>
728 </summary>
729 <content type="html"><i>This report was prepared by Nikita Ronja Gillmann as a part of Google Summer of Code 2020</i>
730
731 <p>This is my second and final report for the Google Summer of Code project I am working on for NetBSD.</p>
732
733 <p>
734 My code can be found at <a href="https://github.com/nikicoon/src/">github.com//src</a> in the <i>gsoc2020</i> branch, at the time of writing some of it is still missing.
735 The test facilities and logs can be found in <a href="https://github.com/nikicoon/gsoc2020/">github.com/nikicoon/gsoc2020</a>.
736 A diff can be found at <a href="https://github.com/NetBSD/src/compare/trunk...nikicoon:gsoc2020">github</a> which will later be split into several patches before it is sent to QA for merging.
737 </p>
738
739 <p>
740 The initial and defined goal of this project was to <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_make_system_3">make system(3) and popen(3) use posix_spawn(3) internally</a>, which had been completed in June.
741 For the second part I was given the task to replace fork+exec calls in our standard shell (sh) in one scenario. Similar to the previous goal we determined through implementation if the initial motivation, to get performance improvements, is correct otherwise we collect metrics for why posix_spawn() in this case should be avoided.
742 This second part meant in practice that I had to add and change code in the kernel, add a new public libc function, and understand shell internals.
743 </p>
744
745 <h2>Summary of part 1</h2>
746 <p>
747 Prior work: In GSoC 2012 Charles Zhang <a href="https://blog.netbsd.org/tnf/entry/posix_spawn_syscall_added">added the posix_spawn syscall</a> which according to <a href="https://web.archive.org/web/20150905210045/http://netbsd-soc.sourceforge.net/projects/posix_spawn/">its SF repository</a> at the time (maybe even now, I have not looked very much into comparing all other systems and libcs + kernels) is an in-kernel implementation of posix_spawn which provides performance benefits compared to FreeBSD and other systems which had a userspace implementation (in 2012).
748 </p>
749 <p>
750 After 1 week of reading POSIX and writing code, 2 weeks of coding and another 1.5 weeks of bugfixes I have successfully implemented posix_spawn in usage in system(3) and popen(3) internally.</p><p>The biggest challenge for me was to understand POSIX, to read the standard. I am used to reading more formal books, but I can't remember working with POSIX Standard directly before.
751 </p>
752 <h3>system(3)</h3>
753 <p>system(3) was changed to use posix_spawnattr_ (where we used sigaction before) and posix_spawn (which replaced execve + vfork calls).</p>
754 <h3>popen(3) and popenve(3)</h3>
755 <p>
756 Since the popen and popenve implementation in NetBSD's libc use a couple of shared helper functions, I was able to change both functions while keeping the majority of the changes focused on (some of ) the helper functions (pdes_child).
757 </p>
758 <p>
759 pdes_child, an internal function in popen.c, now takes one more argument (<i>const char *cmd</i>) for the command to pass to posix_spawn which is called in pdes_child.
760 </p>
761 <p>
762 On a high level what happens in pdes_child() and popen is that we first lock the pidlist_mutex. Then we create a file file action list for all concurrent popen() / popenve() instances and the side of the pipe not necessary, and the move to stdin/stdout. We unlock the pidlist_mutex. Finally we return the list and destroy.
763 </p>
764 <p>
765 In the new version of this helper function which now handles the majority of what popen/popenve did, we have to initialize a file_actions object which by default contains no file actions for posix_spawn() to perform. Since we have to have error handling and a common return value for the functions calling pdes_child() and deconstruction, we make use of <i>goto</i> in some parts of this function.
766 </p>
767 <p>
768 The close() and dup2() actions now get replaced by corresponding file_actions syscalls, they are used to specify a series of actions to be performed by a posix_spawn operation.</p>
769 <p>After this series of actions, we call _readlockenv(), and call posix_spawn with the file_action object and the other arguments to be executed. If it succeeds, we return the pid of the child to popen, otherwise we return -1, in both cases we destroy the file_action object before we proceed.</p>
770 <p>
771 In popen and popenve our code has been reduced to the <i>pid == -1</i> branch, everything else happens in pdes_child() now.
772 </p>
773 <p>
774 After readlockenv we call pdes_child and pass it the command to execute in the posix_spawn'd child process; if pdes_child returns -1 we run the old error handling code. Likewise for popenve.</p>
775 <p>
776 The outcome of the first part is, that thanks to how we implement posix_spawn in NetBSD we reduced the syscalls being made for popen and system.
777 A full test with proper timing should indicate this, my reading was based on comparing old and new logs with ktrace and kdump.
778 </p>
779 <h2>sh, posix_spawn actions, libc and kernel - Part 2</h2>
780 <h3>Motivation</h3>
781 <p>
782 The main goal of part 2 of this project was to change sh(1) to
783 determine which simple cases of (v)fork + exec I could replace, and to
784 replace them with posix_spawn where it makes sense.</p>
785 <p>
786 fork needs to create a new address space by cloning the address space,
787 or in the case of vfork update at least some reference counts.
788 posix_spawn can avoid most of this as it creates the new address space from scratch.
789 </p>
790 <h3>Issues</h3>
791 <p>
792 The current posix_spawn as defined in POSIX has no good way to do tcsetpgrp, and we found
793 that <a href="https://github.com/fish-shell/fish-shell/issues/360">fish just avoids posix_spawn for foreground processes</a>.
794 </p>
795 <h3>Implementation</h3>
796 <p>
797 Since, roughly speaking, modern BSDs handle &quot;#!&quot; execution in the kernel (probably since before the 1990s, systems which didn't handle this started to disappear most likely in the mid to late 90s), our main concern so far was in the evalcmd function the default cmd switch case ('NORMALCMD').</p><p>After adjusting the function to use posix_spawn, I hit an issue in the execution of the curses application htop where htop would run but input would not be accepted properly (keysequences pressed are visible).
798 In pre-posix_spawn sh, every subprocess that sh (v)forked runs forkchild() to set up the subprocess's environment.
799 With posix_spawn, we need to arrange posix_spawn actions to do the same thing.
800 </p>
801 <p>
802 The intermediate resolution was to switch FORK_FG processes to fork+exec again. For foreground processes with job control we're in an interactive shell, so the performance benefit is small enough in this case to be negligible. It's really only for shell scripts that it matters.</p><p>Next I implemented a posix_spawn file_action, with the prototype
803 </p>
804 <pre>
805 <code>int posix_spawn_file_actions_addtcsetpgrp(posix_spawn_file_actions_t *fa, int fildes)</code>
806 </pre>
807 <p>
808 The kernel part of this was implemented inline in sys/kern/kern_exec.c, in the function handle_posix_spawn_file_actions() for the new case 'FAE_TCSETPGRP'.</p><p>The new version of the code is still in testing and debugging phase and at the time of writing not included in my repository (it will be published after Google Summer of Code when I'm done moving).
809 </p>
810 <h3>Future steps</h3>
811 <h4>posix_spawnp kernel implementation</h4>
812 <p>
813 According to a conversation with kre@, the posix_spawnp() implementation we have is just itterating over $PATH calling posix_spawn until it succeeds.
814 For some changes we might want a kernel implementation of posix_spawnp(), as the path search is supposed to happen in the kernel so the file actions are only ever run once:
815 </p>
816 <pre>
817 <code>
818 some of the file actions may be &quot;execute once only&quot;,
819 they can't be repeated (eg: handling &quot;set -C; cat foo &gt;file&quot; - file
820 can only be created once, that has to happen before the exec (as the fd
821 needs to be made stdout), and then the exec part of posix_spawn is
822 attempted - if that fails, when it can't find &quot;cat&quot; in $HOME/bin (or
823 whatever is first in $PATH) and we move along to the next entry (maybe /bin
824 doesn't really matter) then the repeated file action fails, as file now
825 exists, and &quot;set -C&quot; demands that we cannot open an already existing file
826 (noclobber mode). It would be nice for this if there were &quot;clean up on
827 failure&quot; actions, but that is likely to be very difficult to get right,
828 and each would need to be attached to a file action, so only those which
829 had been performed would result in cleanup attempts.
830 </code>
831 </pre>
832 <h4>Replacing all of fork+exec in sh</h4>
833 <p>
834 Ideally we could replace all of (v)fork + exec with posix_spawn.
835 According to my mentors there is pmap synchronisation as an impact of
836 constructing the vm space from scratch with (v)fork.
837 Less IPIs (inter-processor interrupts) matter for small processes too.
838 </p>
839 <h4>posix_spawn_file_action_ioctl</h4>
840 <p>
841 Future directions could involve a posix_spawn action for an arbitrary ioctl.
842 </p>
843 <h2>Thanks</h2>
844 <p>
845 My thanks go to fellow NetBSD developers for answering questions, most recently kre@ for sharing invaluable sh knowledge, Riastradh and Jörg as the mentors I've interacted with most of the time and for their often in-depth explanations as well as allowing me to ask questions I sometimes felt were too obvious. My friends, for sticking up with my &quot;weird&quot; working schedule. Lastly would like to thank the Google Summer of Code program for continuing through the ongoing pandemic and giving students the chance to work on projects full-time.
846 </p></content>
847 </entry>
848 <entry>
849 <id>https://blog.netbsd.org/tnf/entry/hitting_donation_milestone_financial_report</id>
850 <title type="html">Hitting donation milestone, financial report for 2020</title>
851 <author><name>Maya Rashish</name></author>
852 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/hitting_donation_milestone_financial_report"/>
853 <published>2021-03-29T09:17:29+00:00</published>
854 <updated>2021-03-29T10:32:22+00:00</updated>
855 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
856 <summary type="html"><p>
857 We nearly hit our donation milestone set after the release of 9.0 of $50,000.<br />
858 These donations have enabled us to fund significant paid work on NetBSD in 2020.
859 </p></summary>
860 <content type="html"><p>
861 We nearly hit our 2020 donation milestone set after the release of 9.0 of $50,000.
862 These donations have enabled us to fund significant work on NetBSD in 2020 such as:
863 <ul>
864 <li>an aarch64 package build server, <a href="http://victory.netbsd.org/pkgsrc/packages/reports/HEAD/evbarm64-9.0/">victory.netbsd.org</a>. Thanks to Western Washington University for hosting this machine.</li>
865 <li><a href="https://blog.netbsd.org/tnf/entry/wifi_renewal_restarted">Modernizing wi-fi network stack</a> and release engineering work by Martin Husemann</li>
866 <li><a href="https://blog.netbsd.org/tnf/entry/lldb_work_concluded">LLDB support</a> by Michał Górny</li>
867 <li><a href="https://blog.netbsd.org/tnf/entry/accomplishment_of_porting_ptrace_2">ptrace and GDB improvements</a> by Kamil Rytarowski</li>
868 </ul>
869 </p>
870
871 <p>
872 If you are interested in seeing more work like this, please consider donating <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40NetBSD.org&currency_code=USD&source=url">via PayPal</a> or <a href="https://github.com/sponsors/NetBSD">GitHub sponsors</a>.
873 </p>
874
875 <p>
876 The <a href="https://www.netbsd.org/foundation/reports/financial/2020.html">financial report for 2020</a> is also available.
877 </p>
878
879 <p>
880 Note: We realize that this data is inconsistent with the website indicator of donations. This is due to the fact the website is updated manually in an error-prone process as the donations are processed. The financial report (just completed) is prepared separately using <a href="https://www.ledger-cli.org/">ledger</a>.
881 </p></content>
882 </entry>
883 <entry>
884 <id>https://blog.netbsd.org/tnf/entry/allen_k_briggs_memorial_scholarship</id>
885 <title type="html">Allen K. Briggs Memorial Scholarship</title>
886 <author><name>Leonardo Taccari</name></author>
887 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/allen_k_briggs_memorial_scholarship"/>
888 <published>2020-12-21T11:37:59+00:00</published>
889 <updated>2020-12-21T11:37:59+00:00</updated>
890 <category term="/General" label="General" />
891 <content type="html"><p>
892 Allen Briggs was one of the earliest members of the NetBSD community,
893 pursuing his interest in macBSD, and moving to become a NetBSD
894 developer when the two projects merged. Allen was known for his
895 quiet and relaxed manner, and always brought a keen wisdom with
896 him; allied with his acute technical expertise, he was one of the
897 most valued members of the NetBSD community.
898 </p>
899
900 <p>
901 He was a revered member of the NetBSD core team, and keenly involved
902 in many aspects of its application; from working on ARM chips to
903 helping architect many projects, Allen was renowned for his expertise.
904 He was a distinguished engineer at Apple, and used his NetBSD
905 expertise there to bring products to market.
906 </p>
907
908 <p>
909 Allen lived in Blacksburg Virginia with his wife and twin boys and
910 was active with various community volunteer groups. His family
911 touched the families of many other NetBSD developers and those
912 friendships have endured beyond his passing.
913 </p>
914
915 <p>
916 We have received the following from Allen's family and decided to
917 share it with the NetBSD community. If you can, we would ask you
918 to consider contributing to his Memorial Scholarship.
919 </p>
920
921 <p>
922 <a href="https://www.ncssm.edu/donate/distance-education/allen-k-briggs-88-memorial-scholarship">https://www.ncssm.edu/donate/distance-education/allen-k-briggs-88-memorial-scholarship</a>
923 </p>
924
925 <p>
926 The Allen K. Briggs Memorial Scholarship is an endowment to provide
927 scholarships in perpetuity for summer programs at the North Carolina
928 School of Science & Math, which Allen considered to be a place that
929 fundamentally shaped him as a person. We would love to invite
930 Allen's friends and colleagues from the BSD community to donate to
931 this cause so that we can provide more scholarships to students
932 with financial need each year. We are approximately halfway to our
933 goal of $50K with aspirations to exceed that target and fund
934 additional scholarships.
935 </p>
936
937 <p>
938 Two quick notes on donating: <strong>Important!</strong> When donating, you must
939 select "Allen K. Briggs Memorial Scholarship" under designation
940 for the donation to be routed to the scholarship If you have the
941 option to use employer matching (i.e., donating to NCSSM through
942 an employer portal to secure a match from your employer), please
943 email the NCSSM Foundation's Director of Development, April Horton
944 (<code>april.horton@ncssm.edu</code>), after donating to let her know you want
945 your gift and employer match to go to the Allen K. Briggs Memorial
946 Scholarship Thanks in advance for your help. I'd be happy to answer
947 any questions you or any others have about this.
948 </p>
949 </content>
950 </entry>
951 <entry>
952 <id>https://blog.netbsd.org/tnf/entry/netbsd_9_1_released</id>
953 <title type="html">NetBSD 9.1 released</title>
954 <author><name>martin</name></author>
955 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/netbsd_9_1_released"/>
956 <published>2020-10-21T04:19:23+00:00</published>
957 <updated>2020-10-21T04:19:23+00:00</updated>
958 <category term="/Release engineering" label="Release engineering" />
959 <category term="netbsd-9" scheme="http://roller.apache.org/ns/tags/" />
960 <category term="9.1" scheme="http://roller.apache.org/ns/tags/" />
961 <category term="release" scheme="http://roller.apache.org/ns/tags/" />
962 <category term="anouncement" scheme="http://roller.apache.org/ns/tags/" />
963 <summary type="html"><p>NetBSD 9.1, the first maintenance update for the NetBSD 9 branch, has been released</p></summary>
964 <content type="html"><p>After a small delay<super><a href="#footnote_delay">*</a></super>, the NetBSD Project is pleased to announce <a href="https://mail-index.NetBSD.org/netbsd-announce/2020/10/21/msg000321.html">NetBSD 9.1</a>, the first feature and stability maintenance release of the netbsd-9 stable branch.</p>
965 <p>
966 The new release features (among various other changes) many bug fixes,
967 a few performance enhancements, stability improvements for ZFS and LFS
968 and support for USB security keys in a mode easily usable in Firefox
969 and other applications.</p>
970 <p>
971 For more details and instructions see the <a href="https://www.netbsd.org/releases/formal-9/NetBSD-9.1.html">9.1 announcement</a>.</p>
972 <p>
973 Get NetBSD 9.1 from our <a href="https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.1/">CDN</a> (provided by <a href="http://www.fastly.com/">fastly</a>) or one of the ftp mirrors.</p>
974 <p>
975 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 <a href="https://www.NetBSD.org/mirrors/">https://www.NetBSD.org/mirrors/</a>.</p>
976
977 <p style="font-size: 0.8em" name="footnote_delay">* 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.</p></content>
978 </entry>
979 <entry>
980 <id>https://blog.netbsd.org/tnf/entry/google_summer_of_code_20202</id>
981 <title type="html">Google Summer of Code 2020: [Final Report] Enhancing Syzkaller support for NetBSD</title>
982 <author><name>Kamil Rytarowski</name></author>
983 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/google_summer_of_code_20202"/>
984 <published>2020-10-19T13:20:28+00:00</published>
985 <updated>2020-10-19T13:20:28+00:00</updated>
986 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
987 <category term="syzkaller" scheme="http://roller.apache.org/ns/tags/" />
988 <summary type="html">This report was written by Ayushu Sharma as part of Google Summer of Code 2020.
989
990 <p>This post is a follow up of the <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_enhancing_syzkaller_support">first report</a> and <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_enhancing_syzkaller_support1">second report</a>. Post summarizes the work done during the third and final coding period for the Google Summer of Code (GSoc’20) project - <a href="https://wiki.netbsd.org/projects/project/syzkaller/">Enhance Syzkaller support for NetBSD</a></p></summary>
991 <content type="html">This report was written by Ayushu Sharma as part of Google Summer of Code 2020.
992
993 <p>This post is a follow up of the <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_enhancing_syzkaller_support">first report</a> and <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_enhancing_syzkaller_support1">second report</a>. Post summarizes the work done during the third and final coding period for the Google Summer of Code (GSoc’20) project - <a href="https://wiki.netbsd.org/projects/project/syzkaller/">Enhance Syzkaller support for NetBSD</a></p>
994
995 <h2>Sys2syz</h2>
996 <p>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.</p>
997
998 <h2>A peek into Syz2syz Internals</h2>
999
1000 <p>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 <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_enhancing_syzkaller_support1">previous post</a>.<p>
1001
1002 <p>Python code follows 4 major steps:<p>
1003 <ul>
1004 <li><a href="https://github.com/ais2397/sys2syz/blob/master/core/Extractor.py"><b>Extractor.py</b></a> - Extraction of all ioctl commands of a given device driver along with their arguments from the header files.</li>
1005 <li><a href="https://github.com/ais2397/sys2syz/blob/master/core/Bear.py"><b>Bear.py</b></a> - Preprocessing of the device driver's files using compile_commands.json generated during the setup of tool using Bear.</li>
1006 <li><a href="https://github.com/ais2397/sys2syz/blob/master/core/C2xml.py"><b>C2xml.py</b></a> - XML files are generated by running c2xml on preprocessed device files. This eases the process of fetching the information related to arguments of commands</li>
1007 <li><a href="https://github.com/ais2397/sys2syz/blob/master/core/Description.py"><b>Description.py</b></a> - Generates descriptions for the ioctl commands and their arguments (builtin-types, arrays, pointers, structures and unions) using the XML files.</li>
1008 </ul>
1009
1010 <h3>Extraction:</h3>
1011 <p>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</p>
1012
1013 <pre>
1014 <code>
1015 io = re.compile("#define\s+(.*)\s+_IO\((.*)\).*")
1016 iow = re.compile("#define\s+(.*)\s+_IOW\((.*),\s+(.*),\s+(.*)\).*")
1017 ior = re.compile("#define\s+(.*)\s+_IOR\((.*),\s+(.*),\s+(.*)\).*")
1018 iowr = re.compile("#define\s+(.*)\s+_IOWR\((.*),\s+(.*),\s+(.*)\).*")
1019 </code>
1020 </pre>
1021
1022 <p>
1023 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.
1024
1025 Example output:
1026 <pre>
1027 <code>
1028 out, I2C_IOCTL_EXEC, i2c_ioctl_exec_t
1029 </code>
1030 </pre>
1031
1032 <h3>Preprocessing:</h3>
1033 <p>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.</p>
1034 <p>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.</p>
1035
1036 <h3>Generating XML files</h3>
1037 <p>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: </p>
1038 <pre>
1039 <code>
1040 &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"&gt
1041 &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"/&lt
1042 &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"/&gt
1043 &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"/&gt
1044 &lt/symbol&gt
1045 &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"/&gt
1046 &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"/&gt
1047 </code>
1048 </pre>
1049
1050 <p>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 .
1051 </p>
1052
1053 <h3>Descriptions.py</h3>
1054 <p>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.</p>
1055 <p>Xml files for the given target device are parsed to form trees, </p>
1056 <pre>
1057 <code>
1058 for file in (os.listdir(self.target)):
1059 tree = ET.parse(self.target+file)
1060 self.trees.append(tree)
1061 </code>
1062 </pre>
1063
1064 <p>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.
1065 </p>
1066 <p>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</p>
1067
1068 <pre>
1069 <code>
1070 name = child.get("ident")
1071 if name not in self.structs_and_unions.keys():
1072 elements = {}
1073 for element in child:
1074 elem_type = self.get_type(element)
1075 elem_ident = element.get("ident")
1076 if elem_type == None:
1077 elem_type = element.get("type")
1078 elements[element.get("ident")] = elem_type
1079
1080 element_str = ""
1081 for element in elements:
1082 element_str += element + "\t" + elements[element] + "\n"
1083 self.structs_and_unions[name] = " {\n" + element_str + "}\n"
1084 return str(name)
1085 </code>
1086 </pre>
1087
1088 <p>Task of creating descriptions for arrays is made simpler due to the attribute - `array-size`.
1089 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. </p>
1090
1091 <p>There is another category named as nodes which can be distinguished using the base-type-builtin and base-type attributes.
1092 </p>
1093
1094 <h2>Result</h2>
1095
1096 <p>Once the setup script for sys2syz is executed, sys2syz can be used for a certain target_device file by executing the python wrapper script (<a href="https://github.com/ais2397/sys2syz/blob/master/sys2syz.py">sys2syz.py</a>) with :</p>
1097 <pre>
1098 <code>#bin/sh
1099 python sys2syz.py -t &ltabsolute_path_to_device_driver_source&gt -c compile_commands.json -v
1100 </code>
1101 </pre>
1102 <p>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.</p>
1103
1104 <pre>
1105 <code>
1106 #Autogenerated by sys2syz
1107 include <i2c_io.h>
1108
1109 resource fd_i2c[fd]
1110
1111 syz_open_dev$I2C(dev ptr[in, string["/dev/i2c"]], id intptr, flags flags[open_flags]) fd_i2c
1112
1113 ioctl$I2C_IOCTL_EXEC(fd fd_i2c, cmd const[I2C_IOCTL_EXEC], arg ptr[out, i2c_ioctl_exec])
1114
1115 i2c_ioctl_exec {
1116 iie_op flags[i2c_op_t_flags]
1117 iie_addr int16
1118 iie_buflen len[iie_buf, intptr]
1119 iie_buf buffer[out]
1120 iie_cmdlen len[iie_cmd, intptr]
1121 iie_cmd buffer[out]
1122 }
1123 </code>
1124 </pre>
1125
1126 <h2>Future Work</h2>
1127 <p>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.</p>
1128 <p>Some other yet-to-be-done tasks include-
1129 <ul>
1130 <li> Generating descriptions for function type </li>
1131 <li> Calculating attributes for structs and unions </li>
1132 </ul>
1133
1134 <h2>Summary</h2>
1135
1136 <p>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.</p>
1137 <p>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.</p></content>
1138 </entry>
1139 <entry>
1140 <id>https://blog.netbsd.org/tnf/entry/the_gnu_gdb_debugger_and4</id>
1141 <title type="html">The GNU GDB Debugger and NetBSD (Part 5) </title>
1142 <author><name>Kamil Rytarowski</name></author>
1143 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/the_gnu_gdb_debugger_and4"/>
1144 <published>2020-10-07T17:16:53+00:00</published>
1145 <updated>2020-10-07T17:24:34+00:00</updated>
1146 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
1147 <category term="binutils" scheme="http://roller.apache.org/ns/tags/" />
1148 <category term="gdbserver" scheme="http://roller.apache.org/ns/tags/" />
1149 <category term="gdb" scheme="http://roller.apache.org/ns/tags/" />
1150 <summary type="html">The NetBSD developers maintain two copies of GDB:
1151 <ul>
1152 <li>One in the base-system that includes a significant set of local patches.</li>
1153 <li>Another one in pkgsrc whose patching is limited to mostly build fixes.</li>
1154 </ul>
1155 <p>
1156 The base-system version of GDB (GPLv3) still relies on local patching to work.
1157 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.</summary>
1158 <content type="html">The NetBSD developers maintain two copies of GDB:
1159 <ul>
1160 <li>One in the base-system that includes a significant set of local patches.</li>
1161 <li>Another one in pkgsrc whose patching is limited to mostly build fixes.</li>
1162 </ul>
1163 <p>
1164 The base-system version of GDB (GPLv3) still relies on local patching to work.
1165 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.
1166 <p>
1167 <h2>GDB changes</h2>
1168 <p>
1169 Last month, the NetBSD/amd64 support was merged into gdbserver.
1170 This month, the gdbserver target support was extended to
1171 <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=8b667faedf6012048f1f6e71785b1ac1412b8a9c">NetBSD/i386</a> and
1172 <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=8e1d09292902cff8325b08a64fa5a918c7f9aa4f">NetBSD/aarch64</a>.
1173 The gdbserver and gdb code was cleaned up, refactored and made capable of introducing even more NetBSD targets.
1174 <p>
1175 Meanwhile, the NetBSD/i386 build of GDB was
1176 <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=1eb6eb795fd3479c97d8aadc4f70d6afad5f8511">fixed</a>.
1177 The missing include of x86-bsd-nat.h as a common header was added to i386-bsd-nat.h.
1178 The i386 GDB code for BSD contained a runtime assert that verified whether the locally hardcoded
1179 <var>struct sigcontext</var> is compatible with the system headers. In reality, the system headers are no longer using
1180 this structure since 2003, after the switch to ucontext_t, and the validating code was no longer
1181 effective. After the switch to newer GCC, this was reported as a unused local variable by the compiler.
1182 I have decided to <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=6ff330351e7741774c4b7ac1214cf7d73c7eac4d">remove</a> the check on NetBSD entirely.
1183 This was followed up by a small <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=064280be25f2ff27477ce649f01a70d42ddad2ae">build fix</a>.
1184 <p>
1185 The NetBSD team has noticed that the GDB's agent.cc code contains a portability bug and prepared a local fix.
1186 The traditional behavior of the BSD kernel is that passing random values of sun_len (part of sockaddr_un)
1187 can cause failures. In order to prevent the problems, the sockaddr_un structure is now zeroed before use.
1188 I've reimplemented the fix and successfully
1189 <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=e2a2a24a8e78427ff8667d625f5befbe88c328bb">upstreamed it</a>.
1190 <p>
1191 In order to easily resolve the issue with environment hardening enforced by PaX MPROTECT,
1192 I've <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=91e5e8db334b9a87c54f03982dfa0c88e3c9d7a1">introduced
1193 a runtime warning whenever byte transfers betweeen the debugee and debugger occur with the EACCES errno code</a>.
1194 <p>
1195 <h2>binutils changes</h2>
1196 <p>
1197 I've added support for NetBSD/aarch64 upstream, in
1198 <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c0b313441717b65569edb01bf9984d2066d899de">GNU BFD</a> and
1199 <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=cc8b27f89cc8d0fde4532134c19c40c47a023abd">GNU GAS</a>.
1200 NetBSD still carries local patches for the GNU binutils components, and GNU ld does not build out of the box on NetBSD/aarch64.
1201 <p>
1202 <h2>Summary</h2>
1203 <p>
1204 The NetBSD support in GNU binutils and GDB is improving promptly, and the most popular
1205 platforms of amd64, i386 and aarch64 are getting proper support out of the box, without downstream patches.
1206 The remaining patches for these CPUs include: streamlining kgdb support,
1207 adding native GDB support for aarch64,
1208 upstreaming local modifications from the GNU binutils components (especially BFD and ld) and introducing portability enhancements
1209 in the dependent projects like libiberty and gnulib.
1210 Then, the remaining work is to streamline support for the remaining CPUs (Alpha, VAX, MIPS, HPPA, IA64, SH3, PPC, etc.),
1211 to develop the missing generic features (such as listing open file descriptors for the specified process) and
1212 to fix failures in the regression test-suite.</content>
1213 </entry>
1214 <entry>
1215 <id>https://blog.netbsd.org/tnf/entry/wayland_on_netbsd_trials_and</id>
1216 <title type="html">Wayland on NetBSD - trials and tribulations</title>
1217 <author><name>Nia Alarie</name></author>
1218 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/wayland_on_netbsd_trials_and"/>
1219 <published>2020-09-28T17:34:22+00:00</published>
1220 <updated>2020-09-28T17:34:22+00:00</updated>
1221 <category term="/Ports" label="Ports" />
1222 <summary type="html"><p>After I posted about the <a href="https://blog.netbsd.org/tnf/entry/default_window_manager_switched_to">new default window manager</a> in NetBSD I got a few questions, including "when is NetBSD switching from X11 to Wayland?", Wayland being X11's &quot;new&quot; rival. In this blog post, hopefully I can explain why we aren't yet!</p></summary>
1223 <content type="html"><p>After I posted about the <a href="https://blog.netbsd.org/tnf/entry/default_window_manager_switched_to">new default window manager</a> in NetBSD I got a few questions, including "when is NetBSD switching from X11 to Wayland?", Wayland being X11's &quot;new&quot; rival. In this blog post, hopefully I can explain why we aren't yet!</p>
1224 <p>Last year (and early this year) I was responsible for porting the first working Wayland compositor to NetBSD - <a href="https://github.com/michaelforney/swc">swc</a>. I chose it because it looked small and hackable. You can try it out by installing the <code>velox</code> window manager from pkgsrc.</p>
1225 <a href="http://ftp.netbsd.org/pub/NetBSD/misc/nia/images/wayland-laptop.jpg"><img src="http://ftp.netbsd.org/pub/NetBSD/misc/nia/images/wayland-laptop.jpg" style="max-width: 750px;"
1226 alt="A Wayland compositor running on my NetBSD laptop, with a few applications like Luakit and Dungeon Crawl Stone Soup open."
1227 title="A Wayland compositor running on my NetBSD laptop, with a few applications like Luakit and Dungeon Crawl Stone Soup open."></a>
1228 <h2>Difficulties</h2>
1229 <p>In a Wayland system, the &quot;compositor&quot; (display server) is responsible for managing displays, input, and window management. Generally, this means a lot of OS-specific code is contained there.</p>
1230 <p>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.</p>
1231 <p>The Wayland &quot;reference implementation&quot; 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 <code>epoll</code>. In pkgsrc we've patched the libraries to add <a href=https://man.netbsd.org/kqueue.2>kqueue(2)</a> 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 <code>#include &lt;linux/input.h&gt;</code> because Wayland's designers didn't see the need to define a OS-neutral way to get mouse button IDs.</p>
1232 <p>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 - <a href="https://man.netbsd.org/wscons.4">wscons(4).</a> 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. :)</p>
1233 <p>In general, Wayland is moving away from the modularity, portability, and standardization of the X server.</p>
1234 <h2>Is it ready for production?</h2>
1235 <p>No, but you can play with it.</p>
1236 <ul>
1237 <li>swc has some remaining bugs and instability.</li>
1238 <li>swc is incompatible with key applications like Firefox, but others like Luakit work, as do most things that use Qt5, GTK3, or SDL2. Not being able to run X11 applications currently is quite limiting.</li>
1239 <li>Other popular compositors are not yet available. Alternatively, someone could write some new ones.</li>
1240 <li>You need a supported GPU or SoC with kernel modesetting, since safe software fallbacks don't work here. So far, I've only tested this with Intel GPUs.</li>
1241 </ul>
1242 <h2>Task list</h2>
1243 <ul>
1244 <li>Adding support for wscons to more Wayland compositors and persuading developers to accept the patches.</li>
1245 <li>Persuading developers not to add hard dependencies on <code>epoll</code> and instead use an abstraction layer like libevent.</li>
1246 <li>Updating the NetBSD kernel DRM/KMS stack. This is a difficult undertaking that involves porting code from the Linux kernel (a very fast moving target).
1247 <ul>
1248 <li>Getting support for newer DRM versions</li>
1249 <li>Getting support for atomic modesetting</li>
1250 <li>Getting support for Glamor X servers (for running X11 applications inside wayland, etc)</li>
1251 <li>Newer AMDGPU drivers, etc</li>
1252 </ul>
1253 </li>
1254 <li>Adding support for basic (non-DRMKMS) framebuffers to a Wayland compositor. X11 can run from a basic unaccelerated NetBSD framebuffer, but this isn't yet possible in any Wayland compositor.</li>
1255 <li>Extending swc to add more features and fix bugs.</li>
1256 </ul>
1257 <p>I've decided to take a break from this, since it's a fairly huge undertaking and uphill battle.
1258 Right now, X11 combined with a compositor like picom or xcompmgr is the more mature option.</p>
1259 </content>
1260 </entry>
1261 <entry>
1262 <id>https://blog.netbsd.org/tnf/entry/default_window_manager_switched_to</id>
1263 <title type="html">Default window manager switched to CTWM in NetBSD-current</title>
1264 <author><name>Nia Alarie</name></author>
1265 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/default_window_manager_switched_to"/>
1266 <published>2020-09-28T08:33:28+00:00</published>
1267 <updated>2020-09-28T17:42:32+00:00</updated>
1268 <category term="/General" label="General" />
1269 <summary type="html"><p>
1270 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.
1271 </p>
1272 <p>
1273 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.
1274 </p></summary>
1275 <content type="html"><p>
1276 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.
1277 </p>
1278 <p>
1279 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.
1280 </p>
1281 <p>
1282 Recently, I've been installing NetBSD with some people in real life and was inspired by their reactions to the default twm to improve the situation, so I played with ctwm, wrote a config, and used it myself for a week. It's now the default in NetBSD-current.
1283 </p>
1284 <a href="https://ftp.netbsd.org/pub/NetBSD/misc/nia/images/desktop.png"><img src="https://ftp.netbsd.org/pub/NetBSD/misc/nia/images/desktop.png" alt="" style="max-width: 750px;"></a>
1285 <p>
1286 We gain some nice features like an auto-generated application menu (that will fill up as packages are installed to /usr/pkg), and a range of useful keyboard shortcuts including volume controls - the default config should be fully usable without a mouse. It should also work at a range of screen resolutions. We can add HiDPI support after some larger bitmap fonts are imported - another advantage of ctwm is that we can support very slow and very fast hardware with one config.
1287 </p>
1288 <p>
1289 If you're curious about ctwm, check out the <a href="https://www.ctwm.org/index.html">ctwm website</a>. It's also included in previous NetBSD releases, though not as the default window manager and not with this config.
1290 </p></content>
1291 </entry>
1292 <entry>
1293 <id>https://blog.netbsd.org/tnf/entry/google_summer_of_code_20201</id>
1294 <title type="html">Google Summer of Code 2020: [Final Report] RumpKernel Syscall Fuzzing</title>
1295 <author><name>Kamil Rytarowski</name></author>
1296 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/google_summer_of_code_20201"/>
1297 <published>2020-09-25T21:53:00+00:00</published>
1298 <updated>2020-10-19T13:22:39+00:00</updated>
1299 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
1300 <category term="rump" scheme="http://roller.apache.org/ns/tags/" />
1301 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
1302 <category term="fuzzing" scheme="http://roller.apache.org/ns/tags/" />
1303 <content type="html">This report was prepared by Aditya Vardhan Padala as a part of Google Summer of Code 2020
1304
1305 <p>This post is the third update to the project RumpKernel Syscall Fuzzing.</p>
1306 <p>Part1 - <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_fuzzing_rumpkernel_syscalls1">https://blog.netbsd.org/tnf/entry/gsoc_reports_fuzzing_rumpkernel_syscalls1</a></p>
1307 <p>Part2 - <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_fuzzing_rumpkernel_syscalls">https://blog.netbsd.org/tnf/entry/gsoc_reports_fuzzing_rumpkernel_syscalls</a></p>
1308 <p>The first and second coding period was entirely dedicated to fuzzing rumpkernel syscalls using hongfuzz. Initially a dumb fuzzer was developed to start fuzzing but it soon reached its limits.</p>
1309 <p>For the duration of second coding peroid we concentrated on crash reproduction and adding grammar to the fuzzer which yielded in better results as we tested on a bug in ioctl with grammar. Although this works for now crash reproduction needs to be improved to generate a working c reproducer.</p>
1310 <p>For the last coding period I have looked into the internals of syzkaller to understand how it pregenerates input and how it mutates data. I have continued to work on integrating <a href="https://github.com/rumpkernel/buildrump.sh">buildrump.sh</a> with build.sh. buildrump eases the task fo building the rumpkernel on any host for any target.</p>
1311 <p><a href="https://github.com/rumpkernel/buildrump.sh">buildrump.sh</a> is like a wrapper around build.sh to build the tools and rumpkernel from the source relevant to rumpkernel. So I worked to get buildrump.sh working with netbsd-src. Building the toolchain was successfull from netbsd-src. So binaries like rumpmake work just fine to continue building the rumpkernel.</p>
1312 <p>But the rumpkernel failed to build due to some warnings and errors similar to the following. It can be due to the fact that buildrump.sh has been dormant recently I faced a lot of build issues.</p>
1313 <pre><code><span class="hljs-attribute">nbmake[2]</span>: nbmake[2]: don't know how to make /root/buildrump.sh/obj/dest.stage/usr/lib/crti.o. Stop
1314
1315 <span class="crystal">nbmake[<span class="hljs-number">2</span>]: stopped in /root/buildrump.sh/src/<span class="hljs-class"><span class="hljs-keyword">lib</span>/<span class="hljs-title">librumpuser</span></span>
1316 &gt;&gt; <span class="hljs-symbol">ERROR:</span>
1317 &gt;&gt; make /root/buildrump.sh/obj/Makefile.first dependall</span>
1318 </code></pre><p>Few of the similar errors were easily fixed but I couldn&#39;t integrate it during the time span of the coding period.</p>
1319 <p><b>To Do</b></p>
1320 <ul>
1321 <li>Research more on grammar definition and look into the existing grammar fuzzers for a better understanding of generating grammar.</li>
1322 <li>Integrate <a href="https://github.com/ais2397/sys2syz">syz2sys</a> with the existing fuzzer to include grammar generation for better results.</li>
1323 </ul>
1324 <p>GSoC with NetBSD has been an amazing journey throughout, in which I had a chance to learn from awesome people and work on amazing projects. I will continue to work on the project to achieve the goal of integrating my fuzzer with OSS Fuzz. I thank my mentors Siddharth Muralee, Maciej Grochowski, Christos Zoulas for their support and Kamil for his continuous guidance.</p></content>
1325 </entry>
1326 <entry>
1327 <id>https://blog.netbsd.org/tnf/entry/google_summer_of_code_2020</id>
1328 <title type="html">Google Summer of Code 2020: [Final Report] Curses Library Automated Testing</title>
1329 <author><name>Kamil Rytarowski</name></author>
1330 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/google_summer_of_code_2020"/>
1331 <published>2020-09-25T21:50:01+00:00</published>
1332 <updated>2020-10-19T13:24:55+00:00</updated>
1333 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
1334 <category term="curses" scheme="http://roller.apache.org/ns/tags/" />
1335 <summary type="html">This report was prepared by Naman Jain as a part of Google Summer of Code 2020
1336 <p>
1337 My GSoC project under NetBSD involves the development of the test framework of curses. This is the final blog report in a series of blog reports; you can look at the <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_curses_library_automated" rel="nofollow">first report</a> and <a href="https://blog.netbsd.org/tnf/entry/gsoc_2020_second_evaluation_report" rel="nofollow">second report</a> of the series.
1338 <p>The first report gives a brief introduction of the project and some insights into the curses testframe through its architecture and language. To someone who wants to contribute to the test suite, this blog can act as the quick guide of how things work internally. Meanwhile, the second report discusses some of the concepts that were quite challenging for me to understand. I wanted to share them with those who may face such a challenge. Both of these reports also cover the progress made in various phases of the Summer of Code.</p></summary>
1339 <content type="html">This report was prepared by Naman Jain as a part of Google Summer of Code 2020
1340 <p>
1341 My GSoC project under NetBSD involves the development of the test framework of curses. This is the final blog report in a series of blog reports; you can look at the <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_curses_library_automated" rel="nofollow">first report</a> and <a href="https://blog.netbsd.org/tnf/entry/gsoc_2020_second_evaluation_report" rel="nofollow">second report</a> of the series.
1342 <p>The first report gives a brief introduction of the project and some insights into the curses testframe through its architecture and language. To someone who wants to contribute to the test suite, this blog can act as the quick guide of how things work internally. Meanwhile, the second report discusses some of the concepts that were quite challenging for me to understand. I wanted to share them with those who may face such a challenge. Both of these reports also cover the progress made in various phases of the Summer of Code.</p>
1343 <p>This being the final report in the series, I would love to share my experience throughout the project. I would be sharing some of the learning as well as caveats that I faced in the project.</p>
1344 <h2><a id="user-content-challenges-and-caveats" class="anchor" aria-hidden="true" href="#challenges-and-caveats"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Challenges and Caveats</h2>
1345 <p>By the time my application for GSoC was submitted, I had gained some knowledge about the curses library and the testing framework. Combined with compiler design and library testing experience, that knowledge proved useful but not sufficient as I progressed through the project. There were times when, while writing a test case, you have to look into documentation from various sources, be it NetBSD, FreeBSD, Linux, Solaris, etc. One may find questioning his understanding of the framework, documentation, or even curses itself. This leads to the conclusion that for being a tester, one has to become a user first. That made me write minimal programs to understand the behavior. The experience was excellent, and I felt amazed by the capability and complexity of curses.</p>
1346 <h2><a id="user-content-learnings" class="anchor" aria-hidden="true" href="#learnings"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Learnings</h2>
1347 <p>The foremost learning is from the experience of interacting with the open-source community and feeling confident in my abilities to contribute. Understanding the workflows; following the best practices like considering the maintainability, readability, and simplicity of the code were significant learning.</p>
1348 <p>The project-specific learning was not limited to test-framework but a deeper understanding of curses as I have to browse through codes for the functions tested. As <a href="https://www.linusakesson.net/programming/tty/" rel="nofollow">this</a> blog says, getting the TTY demystified was a long-time desire, which got fulfilled to some extent.</p>
1349 <h2><a id="user-content-some-tests-from-test-suite" class="anchor" aria-hidden="true" href="#some-tests-from-test-suite"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Some tests from test suite</h2>
1350 <p>In this section, I would discuss a couple of tests of the test suite written during the third phase of GSoC. Curses input model provides a variety of ways to obtain input from keyboard. We will consider 2 tests <code>keypad</code> and <code>halfdelay</code> that belong to input processing category but are somewhat unrelated.</p>
1351 <h3><a id="user-content-keypad-processing" class="anchor" aria-hidden="true" href="#keypad-processing"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Keypad Processing</h3>
1352 <p>An application can enable or disable the tarnslation of keypad using <code>keypad()</code> function. When translation is enabled, curses attempts to translate input sequence into a single key code. If disabled, curses passes the input as it is and any interpretation has to be made by application.</p>
1353 <pre><code>include window
1354 call $FALSE is_keypad $win1
1355 input "\eOA"
1356 call 0x1b wgetch $win1
1357 call OK keypad $win1 $TRUE
1358 input "\eOA"
1359 call $KEY_UP wgetch $win1
1360
1361 # disable assembly of KEY_UP
1362 call OK keyok $KEY_UP $FALSE
1363 input "\eOA"
1364 call 0x1b wgetch $win1
1365 </code></pre>
1366 <p>As keypad translation is disabled by default, on input of '\eOA', the input sequence is passed as it is and only '\e' (0x1b is hex code) is received on <code>wgetch()</code>. If we enable the translation, then the same input is translated as KEY_UP. In curses, one can disable assembly of specific key symbols using <code>keyok()</code>. See related <a href="http://man.netbsd.org/keypad.3" rel="nofollow">man page</a>.</p>
1367 <h3><a id="user-content-input-mode" class="anchor" aria-hidden="true" href="#input-mode"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Input Mode</h3>
1368 <p>Curses lets the application control the effect of input using four input modes; cooked, cbreak, half-delay, raw. They specify the effect of input in terms of echo-ing and delay. We will discuss about the <code>halfdelay</code> mode. The half-delay mode specifies how quickly certain curses function return to application when there is no terminal input waiting since the function is called.</p>
1369 <pre><code>include start
1370 delay 1000
1371 # input delay 1000 equals to 10 tenths of seconds
1372 # getch must fail for halfdelay(5) and pass for halfdelay(15)
1373 input "a"
1374 call OK halfdelay 15
1375 call 0x61 getch
1376 call OK halfdelay 5
1377 input "a"
1378 call -1 getch
1379 </code></pre>
1380 <p>We have set the delay for feeding input to terminal with delay of 1s(10 tenths of second). If the application sets the halfdelay to 15, and makes a call to <code>getch()</code> it receives the input. But it fails to get the input with haldelay set to 5. See related <a href="http://man.netbsd.org/halfdelay.3" rel="nofollow">man page</a>.</p>
1381 <h2><a id="user-content-project-work" class="anchor" aria-hidden="true" href="#project-work"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Project Work</h2>
1382 <p>The <a href="https://github.com/NamanJain8/curses">work</a> can be merged into organisation repository <a href="https://github.com/NetBSD/src">https://github.com/NetBSD/src</a> under <a href="https://github.com/NetBSD/src/tree/trunk/tests/lib/libcurses">tests/lib/libcurses</a>.</p>
1383 <p>This project involved:</p>
1384 <ol>
1385 <li>Improvement in testframework:
1386 <ul>
1387 <li>Automation of the checkfile generation.</li>
1388 <li>Enhnacement of support for complex character</li>
1389 <li>Addition of small features and code refactoring</li>
1390 </ul>
1391 </li>
1392 <li>Testing and bug reports:
1393 <ul>
1394 <li>Tests for a family of routines like wide character, complex character, line drawing, box drawing, pad, window operations, cursor manipulations, soft label keys, input-output stream, and the ones involving their interactions.</li>
1395 <li>Raising a bunch of Problem Report (PR) under <code>lib</code> category some of which have been fixed. The list of PRs raised can be found <a href="https://github.com/NamanJain8/curses/blob/master/reports/problem-reports.md">here</a></li>
1396 </ul>
1397 </li>
1398 </ol>
1399 <h2><a id="user-content-future-work" class="anchor" aria-hidden="true" href="#future-work"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Future Work</h2>
1400 <ul>
1401 <li>The current testframe supports complex character, but the support needs to be extended for its string. This will enable testing of <code>[mv][w]add_wch[n]str</code>, <code>[mv][w]in_wchstr</code> family of routines.</li>
1402 <li>Some of the tests for teminal manipulation routines like <code>intrflush</code>, <code>def_prog_mode</code>, <code>typeahead</code>, <code>raw</code>, etc. are not there in test suite.</li>
1403 <li>Not specifically related to the framework, but the documentation for wide character as well as complex character routines need to be added.</li>
1404 </ul>
1405 <h2><a id="user-content-acknowledgements" class="anchor" aria-hidden="true" href="#acknowledgements"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Acknowledgements</h2>
1406 <p>I want to extend my heartfelt gratitude to my mentor Mr. Brett Lymn, who helped me through all the technical difficulties and challenges I faced. I also thank my mentor Martin Huseman for valuable suggestions and guidance at various junctures of the project. A special thanks to Kamil Rytarowski for making my blogs published on the NetBSD site.</p></content>
1407 </entry>
1408 <entry>
1409 <id>https://blog.netbsd.org/tnf/entry/gsoc_reports_benchmarking_netbsd_third</id>
1410 <title type="html">GSoC Reports: Benchmarking NetBSD, third evaluation report</title>
1411 <author><name>Leonardo Taccari</name></author>
1412 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_reports_benchmarking_netbsd_third"/>
1413 <published>2020-09-12T08:29:06+00:00</published>
1414 <updated>2020-09-12T08:29:06+00:00</updated>
1415 <category term="/General" label="General" />
1416 <category term="gsoc2020" scheme="http://roller.apache.org/ns/tags/" />
1417 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
1418 <category term="benchmarks" scheme="http://roller.apache.org/ns/tags/" />
1419 <category term="pkgsrc" scheme="http://roller.apache.org/ns/tags/" />
1420 <summary type="html"><p>This report was written by Apurva Nandan as part of Google Summer of Code 2020.</p>
1421
1422 <p>This blog post is in continuation of
1423 <a href="//blog.NetBSD.org/tnf/entry/gsoc_reports_benchmarking_netbsd_first">GSoC Reports: Benchmarking NetBSD, first evaluation report</a>
1424 and <a href="//blog.NetBSD.org/tnf/entry/gsoc_reports_benchmarking_netbsd_second">GSoC Reports: Benchmarking NetBSD, second evaluation report</a>
1425 blogs, and describes my progress in the final phase of GSoC 2020 under
1426 The NetBSD Foundation.</p>
1427 <p>In the third phase, I upgraded to the latest stable version
1428 <a href="https://www.phoronix-test-suite.com/">Phoronix Test Suite (PTS)</a> 9.8.0 in
1429 pkgsrc-wip, resolved the TODOs and created patches for more
1430 test-profiles to fix their installation and runtime errors on
1431 NetBSD-current.</p></summary>
1432 <content type="html"><p>This report was written by Apurva Nandan as part of Google Summer of Code 2020.</p>
1433
1434 <h2>Introduction</h2>
1435 <p>This blog post is in continuation of
1436 <a href="//blog.NetBSD.org/tnf/entry/gsoc_reports_benchmarking_netbsd_first">GSoC Reports: Benchmarking NetBSD, first evaluation report</a>
1437 and <a href="//blog.NetBSD.org/tnf/entry/gsoc_reports_benchmarking_netbsd_second">GSoC Reports: Benchmarking NetBSD, second evaluation report</a>
1438 blogs, and describes my progress in the final phase of GSoC 2020 under
1439 The NetBSD Foundation.</p>
1440 <p>In the third phase, I upgraded to the latest stable version
1441 <a href="https://www.phoronix-test-suite.com/">Phoronix Test Suite (PTS)</a> 9.8.0 in
1442 pkgsrc-wip, resolved the TODOs and created patches for more
1443 test-profiles to fix their installation and runtime errors on
1444 NetBSD-current.</p>
1445
1446 <h2>Progress in the third phase of GSoC</h2>
1447 <h3>wip/phoronix-test-suite TODO and update</h3>
1448 <p>As a newer stable version of the Phoronix Test Suite was available in
1449 upstream, I upgraded the Phoronix Test Suite from version 9.6.1 to
1450 9.8.0 in pkgsrc-wip and is available as
1451 <a href="https://pkgsrc.se/wip/phoronix-test-suite">wip/phoronix-test-suite</a>.
1452 You can have a look at the
1453 <a href="https://github.com/phoronix-test-suite/phoronix-test-suite/blob/master/ChangeLog">PTS Changelog</a>
1454 to know about the improvements between these two versions.</p>
1455 <p>To get the package ready for merge in pkgsrc upstream, I also resolved
1456 the pkgsrc-wip TODOs.</p>
1457 <h4>pkgsrc-wip commits:</h4>
1458 <ul>
1459 <li><a href="https://github.com/NetBSD/pkgsrc-wip/commit/77ef21385452fe098abb12f7772ac21f0aeb7f86">wip/phoronix-test-suite: update phoronix-test-suite to 9.8.0</a></li>
1460 <li><a href="https://github.com/NetBSD/pkgsrc-wip/commit/7162cf86c3fced1702a4446d514b76640d7266f3">Resolved the pending TODOs</a></li>
1461 </ul>
1462 <p>If any new problems are encountered, please document them in
1463 <code>wip/phoronix-test-suite/TODO</code> file and/or contact me.</p>
1464 <h3>Testing of automated benchmarking framework</h3>
1465 <p>I had been assigned a remote testing machine having Intel 6138 dual
1466 processor, 40 cores, 80 threads, 192GB of RAM. I spent time reproducing
1467 my automated framework i.e., Phoromatic-Anita Integration on the
1468 machine. I was able to reproduce the integration framework working
1469 without networking configuration, but the network bridge needs to be
1470 setup on the remote machine and the integration script to be tested
1471 with it. I shall continue this task in the post-GSoC period.</p>
1472 <h4>Benchmarking Results</h4>
1473 <p>I also performed benchmarking of NetBSD-9 amd64 native installation by
1474 running 50 test-profiles on a remote machine assigned to me by mentors
1475 and uploaded the benchmark results to
1476 <a href="https://openbenchmarking.org/">OpenBenchmarking.org</a> at:</p>
1477 <ul>
1478 <li><a href="https://openbenchmarking.org/result/2008287-NE-3966268951">https://openbenchmarking.org/result/2008287-NE-3966268951</a></li>
1479 </ul>
1480 <h3>Test-profile debugging</h3>
1481 <p>I then continued the task of maintaining/porting test-profiles and
1482 fixed the following test-profiles:</p>
1483 <h4>Timed FFmpeg Compilation</h4>
1484 <p>This test times how long it takes to build FFmpeg.
1485 This test is part of <code>Processor Test</code> category.</p>
1486 <h5>Original Test-profile:</h5>
1487 <p><a href="https://openbenchmarking.org/test/pts/build-ffmpeg">https://openbenchmarking.org/test/pts/build-ffmpeg</a></p>
1488 <h5>Patched Test-profile:</h5>
1489 <p><a href="https://github.com/apurvanandan1997/pts-test-profiles-dev/tree/master/build-ffmpeg-1.0.1">https://github.com/apurvanandan1997/pts-test-profiles-dev/tree/master/build-ffmpeg-1.0.1</a></p>
1490 <h6>Commit:</h6>
1491 <ul>
1492 <li><a href="https://github.com/apurvanandan1997/pts-test-profiles-dev/commit/e9765185aabc01240cdb3671fb61f4c7d47e1b7e">Replace the make -&gt; gmake for compatibility with NetBSD</a></li>
1493 </ul>
1494 <h4>Compile Bench</h4>
1495 <p>Compilebench tries to age a filesystem by simulating some of the disk
1496 IO common in creating, compiling, patching, stating and reading kernel
1497 trees. It indirectly measures how well filesystems can maintain
1498 directory locality as the disk fills up and directories age.
1499 This test is part of <code>Disk Test</code> category.</p>
1500 <h5>Original Test-profile:</h5>
1501 <p><a href="https://openbenchmarking.org/test/pts/compilebench">https://openbenchmarking.org/test/pts/compilebench</a></p>
1502 <h5>Patched Test-profile:</h5>
1503 <p><a href="https://github.com/apurvanandan1997/pts-test-profiles-dev/tree/master/compilebench-1.0.2">https://github.com/apurvanandan1997/pts-test-profiles-dev/tree/master/compilebench-1.0.2</a></p>
1504 <h6>Commit:</h6>
1505 <ul>
1506 <li><a href="https://github.com/apurvanandan1997/pts-test-profiles-dev/commit/528b1853a07c22d79d2d8483b3fe2aa951d3866f">Replaced python2 with NetBSD style naming python2.7</a></li>
1507 </ul>
1508 <h4>Timed MAFFT Alignment</h4>
1509 <p>This test performs an alignment of 100 pyruvate decarboxylase sequences.
1510 This test is part of <code>Processor Test</code> category.</p>
1511 <h5>Original Test-profile:</h5>
1512 <p><a href="https://openbenchmarking.org/test/pts/mafft">https://openbenchmarking.org/test/pts/mafft</a></p>
1513 <h5>Patched Test-profile:</h5>
1514 <p><a href="https://github.com/apurvanandan1997/pts-test-profiles-dev/tree/master/mafft-1.5.0">https://github.com/apurvanandan1997/pts-test-profiles-dev/tree/master/mafft-1.5.0</a></p>
1515 <h6>Commits:</h6>
1516 <ul>
1517 <li><a href="https://github.com/apurvanandan1997/pts-test-profiles-dev/commit/2bb288c4d352693b42586e55caf68a847d5740f8">Replaced the make -&gt; gmake for compatibility with NetBSD</a></li>
1518 <li><a href="https://github.com/apurvanandan1997/pts-test-profiles-patches/commit/d31fee7256d165acfd22e23e04590ec322df3620">Patch for replacing /bin/bash interpreter with /usr/pkg/bin/bash</a></li>
1519 </ul>
1520 <h2>Future Plans</h2>
1521 <p>This officially summarizes my GSoC project: Benchmark NetBSD, and my
1522 end goal of the project that is to integrate Phoronix Test Suite with
1523 NetBSD and Anita for automated benchmarking is complete and its
1524 deployment on benchmark.NetBSD.org will be continued to be worked on
1525 with the coordination of moderators and merging the wip of Phoronix
1526 Test Suite 9.8.0 will be done by the pkgsrc maintainers in next days.</p>
1527 <p>I want to thank my mentors and the NetBSD community without whose
1528 constant support I wouldn't have achieved the goals.</p></content>
1529 </entry>
1530 <entry>
1531 <id>https://blog.netbsd.org/tnf/entry/the_gnu_gdb_debugger_and3</id>
1532 <title type="html">The GNU GDB Debugger and NetBSD (Part 4)</title>
1533 <author><name>Kamil Rytarowski</name></author>
1534 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/the_gnu_gdb_debugger_and3"/>
1535 <published>2020-09-10T21:13:01+00:00</published>
1536 <updated>2020-09-10T21:17:53+00:00</updated>
1537 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
1538 <category term="gdbserver" scheme="http://roller.apache.org/ns/tags/" />
1539 <category term="gdb" scheme="http://roller.apache.org/ns/tags/" />
1540 <summary type="html">The NetBSD team of developers maintains two copies of GDB:
1541 <ul>
1542 <li>One in the base-system with a stack of local patches.</li>
1543 <li>One in pkgsrc with mostly build fix patches.</li>
1544 </ul>
1545 <p>
1546 The base-system version of GDB (GPLv3) still relies on a set of local patches.
1547 I set a goal to reduce the local patches to bare minimum, ideally reaching no local modifications at all.</summary>
1548 <content type="html">The NetBSD team of developers maintains two copies of GDB:
1549 <ul>
1550 <li>One in the base-system with a stack of local patches.</li>
1551 <li>One in pkgsrc with mostly build fix patches.</li>
1552 </ul>
1553 <p>
1554 The base-system version of GDB (GPLv3) still relies on a set of local patches.
1555 I set a goal to reduce the local patches to bare minimum, ideally reaching no local modifications at all.
1556 <p>
1557 <h1>GDB changes</h1>
1558 <p>
1559 Over the past month I worked on gdbserver for NetBSD/amd64 and finally
1560 <a href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=62ba50486f1146f0cfd33074fc127fe00a02e87e">upstreamed</a> it to the GDB mainline, just in time for GDB 10.
1561 <p>
1562 What is gdbserver? Let's quote the official
1563 <a href="https://sourceware.org/gdb/onlinedocs/gdb/Server.html">GDB documentation</a>:
1564 <p>
1565 <i><quote>
1566 gdbserver is a control program for Unix-like systems, which allows you to connect your program with a remote GDB via target remote or target extended-but without linking in the usual debugging stub.
1567 <p>
1568 gdbserver is not a complete replacement for the debugging stubs, because it requires essentially the same operating-system facilities that GDB itself does. In fact, a system that can run gdbserver to connect to a remote GDB could also run GDB locally! gdbserver is sometimes useful nevertheless, because it is a much smaller program than GDB itself. It is also easier to port than all of GDB, so you may be able to get started more quickly on a new system by using gdbserver. Finally, if you develop code for real-time systems, you may find that the tradeoffs involved in real-time operation make it more convenient to do as much development work as possible on another system, for example by cross-compiling. You can use gdbserver to make a similar choice for debugging.
1569 <p>
1570 GDB and gdbserver communicate via either a serial line or a TCP connection, using the standard GDB remote serial protocol. remote
1571 </quote></i>
1572 <p>
1573 This illustrated that gdbserver is especially useful for debugging applications on embedded and thin devices, connected to
1574 a controlling computer equipped with full distribution sources, toolchain, debugging information etc.
1575 Eventually, this approach of gdb and gdbserver can replace the native gdb plugin entirely and spawn all connections
1576 debugging sessions using this protocol.
1577 This design decision was already introduced into LLDB, where remote process plugin is the only supported program
1578 on Linux, NetBSD and highly recommended for other kernels.
1579 <p>
1580 I've picked amd64 as the first target as it's the easiest to develop and test.
1581 <p>
1582 An example debugging session looks like this:
1583 <pre>
1584 $ uname -rms
1585 NetBSD 9.99.72 amd64
1586 $ LC_ALL=C date
1587 Thu Sep 10 22:43:10 CEST 2020
1588 $ ./gdbserver/gdbserver --version
1589 GNU gdbserver (GDB) 10.0.50.20200910-git
1590 Copyright (C) 2020 Free Software Foundation, Inc.
1591 gdbserver is free software, covered by the GNU General Public License.
1592 This gdbserver was configured as "x86_64-unknown-netbsd9.99"
1593 $ ./gdbserver/gdbserver localhost:1234 /usr/bin/nslookup
1594 Process /usr/bin/nslookup created; pid = 26383
1595 Listening on port 1234
1596 </pre>
1597 <p>
1598 Then on the other terminal:
1599 <p>
1600 <pre>
1601 $ ./gdb/gdb
1602 GNU gdb (GDB) 10.0.50.20200910-git
1603 Copyright (C) 2020 Free Software Foundation, Inc.
1604 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
1605 This is free software: you are free to change and redistribute it.
1606 There is NO WARRANTY, to the extent permitted by law.
1607 Type "show copying" and "show warranty" for details.
1608 This GDB was configured as "x86_64-unknown-netbsd9.99".
1609 Type "show configuration" for configuration details.
1610 For bug reporting instructions, please see:
1611 <https://www.gnu.org/software/gdb/bugs/>.
1612 Find the GDB manual and other documentation resources online at:
1613 --Type <RET> for more, q to quit, c to continue without paging--
1614 <http://www.gnu.org/software/gdb/documentation/>.
1615
1616 For help, type "help".
1617 Type "apropos word" to search for commands related to "word".
1618 (gdb) target remote localhost:1234
1619 Remote debugging using localhost:1234
1620 Reading /usr/bin/nslookup from remote target...
1621 warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
1622 Reading /usr/bin/nslookup from remote target...
1623 Reading symbols from target:/usr/bin/nslookup...
1624 Reading /usr/bin/nslookup.debug from remote target...
1625 Reading /usr/bin/.debug/nslookup.debug from remote target...
1626 Reading /usr/libdata/debug//usr/bin/nslookup.debug from remote target...
1627 Reading /usr/libdata/debug//usr/bin/nslookup.debug from remote target...
1628 Reading symbols from target:/usr/libdata/debug//usr/bin/nslookup.debug...
1629 process 28353 is executing new program: /usr/bin/nslookup
1630 Reading /usr/bin/nslookup from remote target...
1631 Reading /usr/bin/nslookup from remote target...
1632 Reading /usr/bin/nslookup.debug from remote target...
1633 Reading /usr/bin/.debug/nslookup.debug from remote target...
1634 Reading /usr/libdata/debug//usr/bin/nslookup.debug from remote target...
1635 Reading /usr/libdata/debug//usr/bin/nslookup.debug from remote target...
1636 Reading /usr/libexec/ld.elf_so from remote target...
1637 Reading /usr/libexec/ld.elf_so from remote target...
1638 Reading /usr/libexec/ld.elf_so.debug from remote target...
1639 Reading /usr/libexec/.debug/ld.elf_so.debug from remote target...
1640 Reading /usr/libdata/debug//usr/libexec/ld.elf_so.debug from remote target...
1641 Reading /usr/libdata/debug//usr/libexec/ld.elf_so.debug from remote target...
1642 warning: Invalid remote reply: timeout [kamil: repeated multiple times...]
1643 Reading /usr/lib/libbind9.so.15 from remote target...
1644 Reading /usr/lib/libisccfg.so.15 from remote target...
1645 Reading /usr/lib/libdns.so.15 from remote target...
1646 Reading /usr/lib/libns.so.15 from remote target...
1647 Reading /usr/lib/libirs.so.15 from remote target...
1648 Reading /usr/lib/libisccc.so.15 from remote target...
1649 Reading /usr/lib/libisc.so.15 from remote target...
1650 Reading /usr/lib/libkvm.so.6 from remote target...
1651 Reading /usr/lib/libz.so.1 from remote target...
1652 Reading /usr/lib/libblocklist.so.0 from remote target...
1653 Reading /usr/lib/libpthread.so.1 from remote target...
1654 Reading /usr/lib/libpthread.so.1.4.debug from remote target...
1655 Reading /usr/lib/.debug/libpthread.so.1.4.debug from remote target...
1656 Reading /usr/libdata/debug//usr/lib/libpthread.so.1.4.debug from remote target...
1657 Reading /usr/libdata/debug//usr/lib/libpthread.so.1.4.debug from remote target...
1658 Reading /usr/lib/libgssapi.so.11 from remote target...
1659 Reading /usr/lib/libheimntlm.so.5 from remote target...
1660 Reading /usr/lib/libkrb5.so.27 from remote target...
1661 Reading /usr/lib/libcom_err.so.8 from remote target...
1662 Reading /usr/lib/libhx509.so.6 from remote target...
1663 Reading /usr/lib/libcrypto.so.14 from remote target...
1664 Reading /usr/lib/libasn1.so.10 from remote target...
1665 Reading /usr/lib/libwind.so.1 from remote target...
1666 Reading /usr/lib/libheimbase.so.2 from remote target...
1667 Reading /usr/lib/libroken.so.20 from remote target...
1668 Reading /usr/lib/libsqlite3.so.1 from remote target...
1669 Reading /usr/lib/libcrypt.so.1 from remote target...
1670 Reading /usr/lib/libutil.so.7 from remote target...
1671 Reading /usr/lib/libedit.so.3 from remote target...
1672 Reading /usr/lib/libterminfo.so.2 from remote target...
1673 Reading /usr/lib/libc.so.12 from remote target...
1674 Reading /usr/lib/libgcc_s.so.1 from remote target...
1675 Reading symbols from target:/usr/lib/libbind9.so.15...
1676 Reading /usr/lib/libbind9.so.15.0.debug from remote target...
1677 Reading /usr/lib/.debug/libbind9.so.15.0.debug from remote target...
1678 Reading /usr/libdata/debug//usr/lib/libbind9.so.15.0.debug from remote target...
1679 Reading /usr/libdata/debug//usr/lib/libbind9.so.15.0.debug from remote target...
1680 Reading symbols from target:/usr/libdata/debug//usr/lib/libbind9.so.15.0.debug...
1681 Reading symbols from target:/usr/lib/libisccfg.so.15...
1682 Reading /usr/lib/libisccfg.so.15.0.debug from remote target...
1683 Reading /usr/lib/.debug/libisccfg.so.15.0.debug from remote target...
1684 Reading /usr/libdata/debug//usr/lib/libisccfg.so.15.0.debug from remote target...
1685 Reading /usr/libdata/debug//usr/lib/libisccfg.so.15.0.debug from remote target...
1686 --Type <RET> for more, q to quit, c to continue without paging--
1687 Reading symbols from target:/usr/libdata/debug//usr/lib/libisccfg.so.15.0.debug...
1688 Reading symbols from target:/usr/lib/libdns.so.15...
1689 Reading /usr/lib/libdns.so.15.0.debug from remote target...
1690 Reading /usr/lib/.debug/libdns.so.15.0.debug from remote target...
1691 Reading /usr/libdata/debug//usr/lib/libdns.so.15.0.debug from remote target...
1692 Reading /usr/libdata/debug//usr/lib/libdns.so.15.0.debug from remote target...
1693 Reading symbols from target:/usr/libdata/debug//usr/lib/libdns.so.15.0.debug...
1694 Reading symbols from target:/usr/lib/libns.so.15...
1695 Reading /usr/lib/libns.so.15.0.debug from remote target...
1696 Reading /usr/lib/.debug/libns.so.15.0.debug from remote target...
1697 Reading /usr/libdata/debug//usr/lib/libns.so.15.0.debug from remote target...
1698 Reading /usr/libdata/debug//usr/lib/libns.so.15.0.debug from remote target...
1699 Reading symbols from target:/usr/libdata/debug//usr/lib/libns.so.15.0.debug...
1700 Reading symbols from target:/usr/lib/libirs.so.15...
1701 Reading /usr/lib/libirs.so.15.0.debug from remote target...
1702 Reading /usr/lib/.debug/libirs.so.15.0.debug from remote target...
1703 Reading /usr/libdata/debug//usr/lib/libirs.so.15.0.debug from remote target...
1704 Reading /usr/libdata/debug//usr/lib/libirs.so.15.0.debug from remote target...
1705 Reading symbols from target:/usr/libdata/debug//usr/lib/libirs.so.15.0.debug...
1706 Reading symbols from target:/usr/lib/libisccc.so.15...
1707 Reading /usr/lib/libisccc.so.15.0.debug from remote target...
1708 Reading /usr/lib/.debug/libisccc.so.15.0.debug from remote target...
1709 Reading /usr/libdata/debug//usr/lib/libisccc.so.15.0.debug from remote target...
1710 Reading /usr/libdata/debug//usr/lib/libisccc.so.15.0.debug from remote target...
1711 Reading symbols from target:/usr/libdata/debug//usr/lib/libisccc.so.15.0.debug...
1712 Reading symbols from target:/usr/lib/libisc.so.15...
1713 Reading /usr/lib/libisc.so.15.0.debug from remote target...
1714 Reading /usr/lib/.debug/libisc.so.15.0.debug from remote target...
1715 Reading /usr/libdata/debug//usr/lib/libisc.so.15.0.debug from remote target...
1716 Reading /usr/libdata/debug//usr/lib/libisc.so.15.0.debug from remote target...
1717 Reading symbols from target:/usr/libdata/debug//usr/lib/libisc.so.15.0.debug...
1718 Reading symbols from target:/usr/lib/libkvm.so.6...
1719 Reading /usr/lib/libkvm.so.6.0.debug from remote target...
1720 Reading /usr/lib/.debug/libkvm.so.6.0.debug from remote target...
1721 Reading /usr/libdata/debug//usr/lib/libkvm.so.6.0.debug from remote target...
1722 Reading /usr/libdata/debug//usr/lib/libkvm.so.6.0.debug from remote target...
1723 Reading symbols from target:/usr/libdata/debug//usr/lib/libkvm.so.6.0.debug...
1724 Reading symbols from target:/usr/lib/libz.so.1...
1725 Reading /usr/lib/libz.so.1.0.debug from remote target...
1726 Reading /usr/lib/.debug/libz.so.1.0.debug from remote target...
1727 Reading /usr/libdata/debug//usr/lib/libz.so.1.0.debug from remote target...
1728 Reading /usr/libdata/debug//usr/lib/libz.so.1.0.debug from remote target...
1729 Reading symbols from target:/usr/libdata/debug//usr/lib/libz.so.1.0.debug...
1730 Reading symbols from target:/usr/lib/libblocklist.so.0...
1731 Reading /usr/lib/libblocklist.so.0.0.debug from remote target...
1732 Reading /usr/lib/.debug/libblocklist.so.0.0.debug from remote target...
1733 Reading /usr/libdata/debug//usr/lib/libblocklist.so.0.0.debug from remote target...
1734 Reading /usr/libdata/debug//usr/lib/libblocklist.so.0.0.debug from remote target...
1735 Reading symbols from target:/usr/libdata/debug//usr/lib/libblocklist.so.0.0.debug...
1736 Reading symbols from target:/usr/lib/libgssapi.so.11...
1737 Reading /usr/lib/libgssapi.so.11.0.debug from remote target...
1738 Reading /usr/lib/.debug/libgssapi.so.11.0.debug from remote target...
1739 Reading /usr/libdata/debug//usr/lib/libgssapi.so.11.0.debug from remote target...
1740 Reading /usr/libdata/debug//usr/lib/libgssapi.so.11.0.debug from remote target...
1741 Reading symbols from target:/usr/libdata/debug//usr/lib/libgssapi.so.11.0.debug...
1742 Reading symbols from target:/usr/lib/libheimntlm.so.5...
1743 Reading /usr/lib/libheimntlm.so.5.0.debug from remote target...
1744 Reading /usr/lib/.debug/libheimntlm.so.5.0.debug from remote target...
1745 Reading /usr/libdata/debug//usr/lib/libheimntlm.so.5.0.debug from remote target...
1746 Reading /usr/libdata/debug//usr/lib/libheimntlm.so.5.0.debug from remote target...
1747 Reading symbols from target:/usr/libdata/debug//usr/lib/libheimntlm.so.5.0.debug...
1748 Reading symbols from target:/usr/lib/libkrb5.so.27...
1749 Reading /usr/lib/libkrb5.so.27.0.debug from remote target...
1750 Reading /usr/lib/.debug/libkrb5.so.27.0.debug from remote target...
1751 Reading /usr/libdata/debug//usr/lib/libkrb5.so.27.0.debug from remote target...
1752 Reading /usr/libdata/debug//usr/lib/libkrb5.so.27.0.debug from remote target...
1753 Reading symbols from target:/usr/libdata/debug//usr/lib/libkrb5.so.27.0.debug...
1754 Reading symbols from target:/usr/lib/libcom_err.so.8...
1755 Reading /usr/lib/libcom_err.so.8.0.debug from remote target...
1756 Reading /usr/lib/.debug/libcom_err.so.8.0.debug from remote target...
1757 Reading /usr/libdata/debug//usr/lib/libcom_err.so.8.0.debug from remote target...
1758 Reading /usr/libdata/debug//usr/lib/libcom_err.so.8.0.debug from remote target...
1759 Reading symbols from target:/usr/libdata/debug//usr/lib/libcom_err.so.8.0.debug...
1760 Reading symbols from target:/usr/lib/libhx509.so.6...
1761 Reading /usr/lib/libhx509.so.6.0.debug from remote target...
1762 Reading /usr/lib/.debug/libhx509.so.6.0.debug from remote target...
1763 Reading /usr/libdata/debug//usr/lib/libhx509.so.6.0.debug from remote target...
1764 Reading /usr/libdata/debug//usr/lib/libhx509.so.6.0.debug from remote target...
1765 Reading symbols from target:/usr/libdata/debug//usr/lib/libhx509.so.6.0.debug...
1766 Reading symbols from target:/usr/lib/libcrypto.so.14...
1767 Reading /usr/lib/libcrypto.so.14.0.debug from remote target...
1768 Reading /usr/lib/.debug/libcrypto.so.14.0.debug from remote target...
1769 Reading /usr/libdata/debug//usr/lib/libcrypto.so.14.0.debug from remote target...
1770 Reading /usr/libdata/debug//usr/lib/libcrypto.so.14.0.debug from remote target...
1771 Reading symbols from target:/usr/libdata/debug//usr/lib/libcrypto.so.14.0.debug...
1772 Reading symbols from target:/usr/lib/libasn1.so.10...
1773 Reading /usr/lib/libasn1.so.10.0.debug from remote target...
1774 Reading /usr/lib/.debug/libasn1.so.10.0.debug from remote target...
1775 Reading /usr/libdata/debug//usr/lib/libasn1.so.10.0.debug from remote target...
1776 Reading /usr/libdata/debug//usr/lib/libasn1.so.10.0.debug from remote target...
1777 Reading symbols from target:/usr/libdata/debug//usr/lib/libasn1.so.10.0.debug...
1778 Reading symbols from target:/usr/lib/libwind.so.1...
1779 Reading /usr/lib/libwind.so.1.0.debug from remote target...
1780 Reading /usr/lib/.debug/libwind.so.1.0.debug from remote target...
1781 Reading /usr/libdata/debug//usr/lib/libwind.so.1.0.debug from remote target...
1782 Reading /usr/libdata/debug//usr/lib/libwind.so.1.0.debug from remote target...
1783 Reading symbols from target:/usr/libdata/debug//usr/lib/libwind.so.1.0.debug...
1784 Reading symbols from target:/usr/lib/libheimbase.so.2...
1785 Reading /usr/lib/libheimbase.so.2.0.debug from remote target...
1786 Reading /usr/lib/.debug/libheimbase.so.2.0.debug from remote target...
1787 Reading /usr/libdata/debug//usr/lib/libheimbase.so.2.0.debug from remote target...
1788 Reading /usr/libdata/debug//usr/lib/libheimbase.so.2.0.debug from remote target...
1789 Reading symbols from target:/usr/libdata/debug//usr/lib/libheimbase.so.2.0.debug...
1790 Reading symbols from target:/usr/lib/libroken.so.20...
1791 Reading /usr/lib/libroken.so.20.0.debug from remote target...
1792 Reading /usr/lib/.debug/libroken.so.20.0.debug from remote target...
1793 Reading /usr/libdata/debug//usr/lib/libroken.so.20.0.debug from remote target...
1794 Reading /usr/libdata/debug//usr/lib/libroken.so.20.0.debug from remote target...
1795 Reading symbols from target:/usr/libdata/debug//usr/lib/libroken.so.20.0.debug...
1796 Reading symbols from target:/usr/lib/libsqlite3.so.1...
1797 Reading /usr/lib/libsqlite3.so.1.4.debug from remote target...
1798 Reading /usr/lib/.debug/libsqlite3.so.1.4.debug from remote target...
1799 Reading /usr/libdata/debug//usr/lib/libsqlite3.so.1.4.debug from remote target...
1800 Reading /usr/libdata/debug//usr/lib/libsqlite3.so.1.4.debug from remote target...
1801 Reading symbols from target:/usr/libdata/debug//usr/lib/libsqlite3.so.1.4.debug...
1802 Reading symbols from target:/usr/lib/libcrypt.so.1...
1803 Reading /usr/lib/libcrypt.so.1.0.debug from remote target...
1804 Reading /usr/lib/.debug/libcrypt.so.1.0.debug from remote target...
1805 Reading /usr/libdata/debug//usr/lib/libcrypt.so.1.0.debug from remote target...
1806 Reading /usr/libdata/debug//usr/lib/libcrypt.so.1.0.debug from remote target...
1807 Reading symbols from target:/usr/libdata/debug//usr/lib/libcrypt.so.1.0.debug...
1808 Reading symbols from target:/usr/lib/libutil.so.7...
1809 Reading /usr/lib/libutil.so.7.24.debug from remote target...
1810 Reading /usr/lib/.debug/libutil.so.7.24.debug from remote target...
1811 Reading /usr/libdata/debug//usr/lib/libutil.so.7.24.debug from remote target...
1812 Reading /usr/libdata/debug//usr/lib/libutil.so.7.24.debug from remote target...
1813 Reading symbols from target:/usr/libdata/debug//usr/lib/libutil.so.7.24.debug...
1814 Reading symbols from target:/usr/lib/libedit.so.3...
1815 Reading /usr/lib/libedit.so.3.1.debug from remote target...
1816 Reading /usr/lib/.debug/libedit.so.3.1.debug from remote target...
1817 Reading /usr/libdata/debug//usr/lib/libedit.so.3.1.debug from remote target...
1818 Reading /usr/libdata/debug//usr/lib/libedit.so.3.1.debug from remote target...
1819 Reading symbols from target:/usr/libdata/debug//usr/lib/libedit.so.3.1.debug...
1820 Reading symbols from target:/usr/lib/libterminfo.so.2...
1821 Reading /usr/lib/libterminfo.so.2.0.debug from remote target...
1822 Reading /usr/lib/.debug/libterminfo.so.2.0.debug from remote target...
1823 Reading /usr/libdata/debug//usr/lib/libterminfo.so.2.0.debug from remote target...
1824 Reading /usr/libdata/debug//usr/lib/libterminfo.so.2.0.debug from remote target...
1825 Reading symbols from target:/usr/libdata/debug//usr/lib/libterminfo.so.2.0.debug...
1826 Reading symbols from target:/usr/lib/libc.so.12...
1827 Reading /usr/lib/libc.so.12.217.debug from remote target...
1828 Reading /usr/lib/.debug/libc.so.12.217.debug from remote target...
1829 Reading /usr/libdata/debug//usr/lib/libc.so.12.217.debug from remote target...
1830 Reading /usr/libdata/debug//usr/lib/libc.so.12.217.debug from remote target...
1831 Reading symbols from target:/usr/libdata/debug//usr/lib/libc.so.12.217.debug...
1832 Reading symbols from target:/usr/lib/libgcc_s.so.1...
1833 Reading /usr/lib/libgcc_s.so.1.0.debug from remote target...
1834 Reading /usr/lib/.debug/libgcc_s.so.1.0.debug from remote target...
1835 Reading /usr/libdata/debug//usr/lib/libgcc_s.so.1.0.debug from remote target...
1836 Reading /usr/libdata/debug//usr/lib/libgcc_s.so.1.0.debug from remote target...
1837 Reading symbols from target:/usr/libdata/debug//usr/lib/libgcc_s.so.1.0.debug...
1838 Reading /usr/libexec/ld.elf_so from remote target...
1839 _rtld_debug_state () at /usr/src/libexec/ld.elf_so/rtld.c:1577
1840 1577 __insn_barrier();
1841 (gdb) b main
1842 Breakpoint 1 at 0x211c00: file /usr/src/external/mpl/bind/bin/nslookup/../../dist/bin/dig/nslookup.c, line 990.
1843 (gdb) c
1844 Continuing.
1845
1846 Breakpoint 1, main (argc=1, argv=0x7f7fffffe768)
1847 at /usr/src/external/mpl/bind/bin/nslookup/../../dist/bin/dig/nslookup.c:990
1848 990 main(int argc, char **argv) {
1849 (gdb) bt
1850 #0 main (argc=1, argv=0x7f7fffffe768)
1851 at /usr/src/external/mpl/bind/bin/nslookup/../../dist/bin/dig/nslookup.c:990
1852 (gdb) info threads
1853 Id Target Id Frame
1854 * 1 Thread 28353.28353 main (argc=1, argv=0x7f7fffffe768)
1855 at /usr/src/external/mpl/bind/bin/nslookup/../../dist/bin/dig/nslookup.c:990
1856 (gdb) b pthread_setname_np
1857 Breakpoint 2 at 0x7f7ff4e0c9e4: file /usr/src/lib/libpthread/pthread.c, line 792.
1858 (gdb) c
1859 Continuing.
1860 [New Thread 28353.27773]
1861
1862 Thread 1 hit Breakpoint 2, pthread_setname_np (thread=0x7f7ff7e41000,
1863 name=name@entry=0x7f7fffffe610 "work-0", arg=arg@entry=0x0)
1864 at /usr/src/lib/libpthread/pthread.c:792
1865 792 {
1866 (gdb) info threads
1867 Id Target Id Frame
1868 * 1 Thread 28353.28353 pthread_setname_np (thread=0x7f7ff7e41000,
1869 name=name@entry=0x7f7fffffe610 "work-0", arg=arg@entry=0x0)
1870 at /usr/src/lib/libpthread/pthread.c:792
1871 2 Thread 28353.27773 0x00007f7ff0aa623a in ___lwp_park60 () from target:/usr/lib/libc.so.12
1872 (gdb) n
1873 796 pthread__error(EINVAL, "Invalid thread",
1874 (gdb) n
1875 799 if (pthread__find(thread) != 0)
1876 (gdb)
1877 802 namelen = snprintf(newname, sizeof(newname), name, arg);
1878 (gdb)
1879 803 if (namelen >= PTHREAD_MAX_NAMELEN_NP)
1880 (gdb)
1881 806 cp = strdup(newname);
1882 (gdb)
1883 807 if (cp == NULL)
1884 (gdb)
1885 810 pthread_mutex_lock(&thread->pt_lock);
1886 (gdb)
1887 811 oldname = thread->pt_name;
1888 (gdb)
1889 812 thread->pt_name = cp;
1890 (gdb)
1891 813 (void)_lwp_setname(thread->pt_lid, cp);
1892 (gdb)
1893 814 pthread_mutex_unlock(&thread->pt_lock);
1894 (gdb) n
1895 816 if (oldname != NULL)
1896 (gdb) n
1897 isc_taskmgr_create (mctx=<optimized out>, workers=workers@entry=1, default_quantum=<optimized out>,
1898 default_quantum@entry=0, nm=nm@entry=0x0, managerp=managerp@entry=0x418638 <taskmgr>)
1899 at /usr/src/external/mpl/bind/lib/libisc/../../dist/lib/isc/task.c:1431
1900 1431 for (i = 0; i < workers; i++) {
1901 (gdb) info threads
1902 Id Target Id Frame
1903 * 1 Thread 28353.28353 isc_taskmgr_create (mctx=<optimized out>, workers=workers@entry=1,
1904 default_quantum=<optimized out>, default_quantum@entry=0, nm=nm@entry=0x0,
1905 managerp=managerp@entry=0x418638 <taskmgr>)
1906 at /usr/src/external/mpl/bind/lib/libisc/../../dist/lib/isc/task.c:1431
1907 2 Thread 28353.27773 "work-0" 0x00007f7ff0aa623a in ___lwp_park60 ()
1908 from target:/usr/lib/libc.so.12
1909 (gdb) dis 1
1910 (gdb) b exit
1911 Breakpoint 3 at 0x7f7ff0b530e0: exit. (2 locations)
1912 (gdb) c
1913 Continuing.
1914
1915 Thread 1 hit Breakpoint 2, pthread_setname_np (thread=0x7f7ff7e42c00,
1916 name=name@entry=0x7f7ff5e6324e "isc-timer", arg=arg@entry=0x0)
1917 at /usr/src/lib/libpthread/pthread.c:792
1918 792 {
1919 (gdb) dis 2
1920 (gdb) c
1921 Continuing.
1922 Reading /usr/lib/i18n/libUTF8.so.5.0 from remote target...
1923 Reading /usr/lib/i18n/libUTF8.so.5.0.debug from remote target...
1924 Reading /usr/lib/i18n/.debug/libUTF8.so.5.0.debug from remote target...
1925 Reading /usr/libdata/debug//usr/lib/i18n/libUTF8.so.5.0.debug from remote target...
1926 Reading /usr/libdata/debug//usr/lib/i18n/libUTF8.so.5.0.debug from remote target...
1927 </pre>
1928 <p>
1929 Then, back to the first terminal:
1930 <pre>
1931 > netbsd.org
1932 Server: 62.179.1.62
1933 Address: 62.179.1.62#53
1934
1935 Non-authoritative answer:
1936 Name: netbsd.org
1937 Address: 199.233.217.205
1938 Name: netbsd.org
1939 Address: 2001:470:a085:999::80
1940 > exit
1941
1942 </pre>
1943 <p>
1944 <pre>
1945 Thread 1 hit Breakpoint 3, exit (status=1) at /usr/src/lib/libc/stdlib/exit.c:55
1946 55 {
1947 (gdb) info threads
1948 Id Target Id Frame
1949 * 1 Thread 28353.28353 exit (status=1) at /usr/src/lib/libc/stdlib/exit.c:55
1950 (gdb) bt
1951 #0 exit (status=1) at /usr/src/lib/libc/stdlib/exit.c:55
1952 #1 0x0000000000206122 in ___start ()
1953 #2 0x00007f7ff7c0c840 in ?? () from target:/usr/libexec/ld.elf_so
1954 #3 0x0000000000000001 in ?? ()
1955 #4 0x00007f7fffffed20 in ?? ()
1956 #5 0x0000000000000000 in ?? ()
1957 (gdb) kill
1958 Kill the program being debugged? (y or n) y
1959 [Inferior 1 (process 28353) killed]
1960 </pre>
1961 <p>
1962 <b>It worked!</b>
1963 <p>
1964 In order to get this functionality operational I had to implement multiple GDB functions, in particular: create_inferior,
1965 post_create_inferior, attach, kill, detach, mourn, join, thread_alive,
1966 resume, wait, fetch_registers, store_registers, read_memory, write_memory,
1967 request_interrupt, supports_read_auxv, read_auxv,
1968 supports_hardware_single_step, sw_breakpoint_from_kind,
1969 supports_z_point_type, insert_point, remove_point,
1970 stopped_by_sw_breakpoint, supports_qxfer_siginfo, qxfer_siginfo,
1971 supports_stopped_by_sw_breakpoint, supports_non_stop,
1972 supports_multi_process, supports_fork_events, supports_vfork_events,
1973 supports_exec_events, supports_disable_randomization,
1974 supports_qxfer_libraries_svr4, qxfer_libraries_svr4,
1975 supports_pid_to_exec_file, pid_to_exec_file, thread_name,
1976 supports_catch_syscall.
1977 <p>
1978 NetBSD is the first BSD and actually the first Open Source UNIX-like OS besides Linux to grow support for gdbserver.
1979 <p>
1980 <h1>Plan for the next milestone</h1>
1981 <p>
1982 Introduce AArch64 support for GDB/NetBSD.</content>
1983 </entry>
1984 <entry>
1985 <id>https://blog.netbsd.org/tnf/entry/gsoc_2020_report_2_fuzzing</id>
1986 <title type="html">GSoC 2020: Report-2: Fuzzing the NetBSD Network Stack in a Rumpkernel Environment</title>
1987 <author><name>Kamil Rytarowski</name></author>
1988 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_2020_report_2_fuzzing"/>
1989 <published>2020-08-30T13:21:57+00:00</published>
1990 <updated>2020-08-30T13:21:57+00:00</updated>
1991 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
1992 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
1993 <category term="rump" scheme="http://roller.apache.org/ns/tags/" />
1994 <category term="fuzzing" scheme="http://roller.apache.org/ns/tags/" />
1995 <summary type="html">This report was written by Nisarg S. Joshi as part of Google Summer of Code 2020.
1996
1997 <p>The objective of this project is to fuzz the various protocols and layers of the network stack of NetBSD using rumpkernel. This project is being carried out as a part of GSoC 2020. This blog post is regarding the project, the concepts and tools involved, the objectives and the current progress and next steps.</p>
1998 <p>You can read the previous post/report <a href="http://blog.netbsd.org/tnf/entry/gsoc_reports_fuzzing_the_netbsd">here</a>.</p></summary>
1999 <content type="html">This report was written by Nisarg S. Joshi as part of Google Summer of Code 2020.
2000
2001 <p>The objective of this project is to fuzz the various protocols and layers of the network stack of NetBSD using rumpkernel. This project is being carried out as a part of GSoC 2020. This blog post is regarding the project, the concepts and tools involved, the objectives and the current progress and next steps.</p>
2002 <p>You can read the previous post/report <a href="http://blog.netbsd.org/tnf/entry/gsoc_reports_fuzzing_the_netbsd">here</a>.</p>
2003 <p><strong>Overview of the work done:</strong></p>
2004 <p>The major time of the phase 1 and 2 were spent in analyzing the input and output paths of the particular protocols being fuzzed. During that time, 5 major protocols of the internet stack were taken up:</p>
2005 <ol>
2006 <li>IPv4 (Phase 1)</li>
2007 <li>UDP (Phase 1)</li>
2008 <li>IPv6 (Phase 2)</li>
2009 <li>ICMP (Phase 2)</li>
2010 <li>Ethernet (Phase 2)</li>
2011 </ol>
2012 <p>Quite a good amount of time was spent in understanding the input and output processing functions of the particular protocols, the information gathered was to be applied in packet creation code for that protocol. This is important so that we know which parts of the packet can be kept random by the fuzzer based input and which part of the packet need to be set to proper fixed values. Fixing some values in the data packet to be correct is important so that the packet does not get rejected for trivial cases like IP Protocol Version or Internet Checksum. (The procedure to come up with the decisions and the code design and flow is explained in IPv4 Protocol section as an example)</p>
2013 <p>For each protocol, mainly 2 things needed to be implemented:&nbsp;</p>
2014 <ol>
2015 <li>The Network Config: the topology for sending and receiving packets example using a TUN device or a TAP device, the socket used and so on. Configuring these devices was the first step in being able to send or receive packets</li>
2016 <li>Packet Creation: Using the information gathered in the code walkthrough of the protocol functions, packet creation is decided where certain parts of the packet are kept fixed and others random from the fuzzer input itself. Doing so we try to gain maximum code coverage. Also one thing to be noted here, we should not randomly change the fuzzer input, rather do it deterministically following the same rules for each packet, otherwise the evolutionary fuzzer cannot easily grow the corpus.</li>
2017 </ol>
2018 <p>In the next section, a few of the protocols will be explained in detail.</p>
2019 <p><strong>Protocols</strong></p>
2020 <p>In this section we will talk about the various protocols implemented for fuzzing and talk about the approach taken to create a packet.&nbsp;</p>
2021 <p><strong>IPv4:</strong></p>
2022 <p>IPv4 stands for the Internet protocol version 4. It is one of the most widely used protocols in the internet family of protocols. It is used as a network layer protocol for routing and host to host packet delivery using an addressing scheme called IP Address(A 32 bit address scheme). IP Protocol also handles a lot of other functions like fragmentation and reassembly of packets to accommodate for transmission of packets over varying sizes of physical channel capacities. It also supports the concept of multicasting and broadcasting (Via IP Options).</p>
2023 <p>In order to come up with a strategy for fuzzing, the first step was to carry out a code walkthrough of relevant functions/APIs and data structures involved in the IPv4 protocol. For that the major files and components studied were:</p>
2024 <ul>
2025 <li>ip_input() =&gt; Which carries out the processing of a incoming packet at the network layer for IPv4 (src <a href="https://github.com/NetBSD/src/blob/trunk/sys/netinet/ip_input.c">here</a>)</li>
2026 <li>ip_output() =&gt; Which carries out the processing of an outgoing packet at the network layer for IPv4 (src <a href="https://github.com/NetBSD/src/blob/trunk/sys/netinet/ip_output.c">here</a>)</li>
2027 <li>struct ip =&gt; Represents the IP header (src <a href="https://github.com/NetBSD/src/blob/trunk/sys/netinet/ip.h">here</a>)</li>
2028 </ul>
2029 <p>These sections of code represent the working of the input and output processing paths of IPv4 protocol and the struct ip is the main IPv4 header. On top of that other APIs related to mbuf (The NetBSD packet), ip_forward(), IP assembly and fragmentation etc. were also studied in order to determine information about packet structure that could be followed.</p>
2030 <p>In order to be able to reach these various aspects of the protocol and be able to fuzz it, we went forward with packet creation that took care of basic fields of the IP Header so that it would not get rejected in trivial cases as mentioned before. Hence we went ahead and fixed these fields:</p>
2031 <ul>
2032 <li><em>IP Version</em>: Set it to 0x4 which is a 4 bit value.</li>
2033 <li><em>IP Header Len</em>: Which is set to a value greater than or equal to sizeof(struct ip). Setting this to greater than that allows for IP Options processing.</li>
2034 <li><em>IP Len</em>: Set it to the size of the random buffer passed by fuzzer.</li>
2035 <li><em>IP Checksum</em>: We calculate the correct checksum for the packet using the internet checksum algorithm.</li>
2036 </ul>
2037 <p>Other fields were allowed to be populated randomly by fuzzer input. Here is an illustration of the IPv4 header with the fields marked in red as fixed.</p>
2038 <p>
2039 <img src="//netbsd.org/~kamil/gsoc_2020/rumpnetfuzz.png">
2040 <p>The packet creation code lies in the following section inside [<a href="https://github.com/NJnisarg/fuzznetrump/blob/master/src/helpers/pkt_create.c#L152">pkt_create.c</a>]. Another important component is the network configuration [located here <a href="https://github.com/NJnisarg/fuzznetrump/blob/master/src/helpers/net_config.c#L173">net_config</a>] where the code related to configuring a TUN/TAP device is present. All the code uses the rumpkernel exposed APIs and syscalls (prepended with rump_sys_) so as to utilize the rumpkernel while executing the application binary. After packet creation and network config is handled the main fuzzing function is written where a series of steps are followed:</p>
2041 <ol>
2042 <li>We call rump_init() to initialize the rumpkernel linked via libraries</li>
2043 <li>We setup the Client and server IP addresses</li>
2044 <li>We setup the TUN device by calling the network config functions described above</li>
2045 <li>We create the packet using the packet creation function utilizing the random buffer passed by the fuzzer and transforming that into a semi-random buffer.</li>
2046 <li>Pass this forged packet into the network stack of the rumpkernel linked with the application binary by calling rump_sys_write on the TUN device setup.</li>
2047 </ol>
2048 <p><strong>IPv6:</strong></p>
2049 <p>IPv6 stands for the Internet protocol version 4. It is the successor of the IPv4 protocol. It came into existence in order to overcome the addressing requirements that could not fit in a 32 bit IPv4 address. It is used as a network layer protocol for routing and host to host packet delivery using an addressing scheme called IPv6 Address(A 128 bit address scheme). It also supports almost similar other functions as IPv4 except some things like fragmentation, broadcast(instead uses multicast).&nbsp;</p>
2050 <p>In order to be able to reach these various aspects of the protocol and be able to fuzz it, we went forward with packet creation that took care of basic fields of the IP Header so that it would not get rejected in trivial cases as mentioned before. Hence we went ahead and fixed these fields:</p>
2051 <ul>
2052 <li><em>IP Version</em>: Set it to 0x6 which is a 4 bit value.</li>
2053 <li><em>IP Hop Limit</em>: This is an alias for TTL. Set it to a maximum possible value of 255(8 bits).</li>
2054 </ul>
2055 <p>Other fields were allowed to be populated randomly by fuzzer input. Allowing the payload len value to be randomly populated allowed processing of various &ldquo;next headers&rdquo; or &rdquo;Extension headers&rdquo;. Extension headers carry optional Internet Layer information, and are placed between the fixed header and the upper-layer protocol header. The headers form a chain, using the Next Header fields. The Next Header field in the fixed header indicates the type of the first extension header; the Next Header field of the last extension header indicates the type of the upper-layer protocol header in the payload of the packet. A further work can be done to set the value of the next header chain and form packets for multiple scenarios with a combination of various next headers.</p>
2056 <p><strong>UDP:</strong></p>
2057 <p>UDP stands for User Datagram Protocol. It is one of the simplest protocols and is designed to be simple so that it simply carries payload with minimal overhead. It does not have many options except for checksum information and ports in order to demultiplex the packet to the processes.&nbsp;</p>
2058 <p>Since UDP runs at the transport layer and hence is wrapped up in an IP header. Since we do not want to fuzz the IP code section, we form a well formed IP header so that the packet does not get rejected in the IP processing section. We only randomize the UDP header using the fuzzer input. We used previously built out IP packet creation utilities to form the IP header and then use the fuzzer input for UDP header.&nbsp;</p>
2059 <p>In UDP, we fix the following fields:</p>
2060 <ul>
2061 <li><em>UDP Checksum</em>: Set it to zero in order to avoid checksums.</li>
2062 </ul>
2063 <p><strong>ICMP:</strong></p>
2064 <p>ICMP stands for Internet control message protocol. This protocol is sometimes called a sister protocol of IP protocol and is used as a troubleshooting protocol at the network layer. It is used for major 2 purposes:</p>
2065 <ol>
2066 <li>Error messages</li>
2067 <li>Request-Reply Queries.</li>
2068 </ol>
2069 <p>ICMP has a lot of options and is quite generic in the sense that it handles a lot of error messages and queries. Although ICMP is generally considered at the network layer, it is actually wrapped inside an IP header, hence it has its own protocol number(= 1). Again similar to UDP, we wrap the ICMP headers inside IP headers, hence we do not randomize the IP header and only the ICMP headers using fuzzer input.</p>
2070 <p>In order to test various ICMP messages and queries, we could not fix values for the <em>type </em>and <em>code</em> fields in the ICMP header since they decide the ICMP message type. Also if we allowed random input, most of the packets would get rejected since the number of options of type and code fields are limited and most other values would discard the packet while processing. Hence we came up with a solution where we <em>deterministically</em> modified the input bits from the fuzzer corresponding to the <em>code</em> and <em>type</em> fields. For the <em>type</em> field we simply took a modulo of the number of types(ICMP_NTYPES macro used here). For the value of <em>code </em>, we had to fix values in a certain range based on the <em>type </em>value set already. This technique allowed us to cover all different ICMP message types via the fuzzer input. We also ensured that the input buffer was not modified completely randomly, since that is a bad practice for a feedback-driven fuzzer like ours. Apart from this we fixed the ICMP Checksum field as well by calculating the checksum using the internet checksum algorithm.</p>
2071 <p><strong>Ethernet:</strong></p>
2072 <p>Ethernet protocol defined by the IEEE 802.3 standard is a widely used data link layer protocol. The ethernet packet called a frame carries an IP(or the network layer protocol) datagram. The header is simple with Link Layer Addresses called MAC address (used for switching at data link layer which is a part of addressing), for source and destination each of 6 octets(=48 bytes) present, followed by a 4 octet Ethertype and QTag field. This is followed by payload and finally the FCS(frame check sequence) which is a four-octet cyclic redundancy check (CRC) that allows detection of corrupted data within the entire frame as received on the receiver side.&nbsp;</p>
2073 <p>In case of Ethernet protocol fuzzing, we had to use a TAP device instead of a TUN device, since the TUN device supports passing an IP packet to the network stack, whereas a TAP device accepts an ethernet frame.&nbsp;</p>
2074 <p>For packet creation, we set the source and destination MAC address and let the payload and ethertype be randomly populated by the fuzzer.</p>
2075 <p><br /><br /></p>
2076 <p><strong>Current Progress and Next steps</strong></p>
2077 <p>The project currently has reached a stage where many major internet family protocols have been covered for fuzzing. As described above a structured approach to fuzzing them have been taken by forming packets based on the internal workings of the protocols. Also as mentioned in the previous post, Rumpkernel environment is being used for fuzzing all these protocols. In order to get better results as compared to raw fuzzing, we have taken these steps. In the next report we shall talk about and compare the coverage of raw fuzzing with our approach.</p>
2078 <p>For the next phase of GSoC, the major focus would be to validate this process of fuzzing by various methods to check the penetration of packets into the network stack as well as the code coverage. Also the code would be made more streamlined and standardized so that it can be extended for adding more protocols even beyond the scope of the GSoC project.</p></content>
2079 </entry>
2080 <entry>
2081 <id>https://blog.netbsd.org/tnf/entry/gsoc_reports_benchmarking_netbsd_second</id>
2082 <title type="html">GSoC Reports: Benchmarking NetBSD, second evaluation report</title>
2083 <author><name>Leonardo Taccari</name></author>
2084 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_reports_benchmarking_netbsd_second"/>
2085 <published>2020-08-12T10:09:16+00:00</published>
2086 <updated>2020-08-12T10:09:16+00:00</updated>
2087 <category term="/General" label="General" />
2088 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
2089 <category term="benchmarking" scheme="http://roller.apache.org/ns/tags/" />
2090 <summary type="html"><p>This report was written by Apurva Nandan as part of Google Summer of Code
2091 2020.</p>
2092
2093 <p>This blog post is in continuation of
2094 <a href="//blog.NetBSD.org/tnf/entry/gsoc_reports_benchmarking_netbsd_first">GSoC Reports: Benchmarking NetBSD, first evaluation report</a>
2095 blog and describes my progress in the second phase of GSoC 2020 under
2096 The NetBSD Foundation.</p>
2097
2098 <p>In this phase, I worked on the automation of the regression suite made
2099 using <a href="https://www.phoronix-test-suite.com">Phoronix Test Suite (PTS)</a>
2100 and its integration with <a href="https://www.gson.org/netbsd/anita">Anita</a>.</p>
2101
2102 <p>The automation framework consists of two components Phoromatic server,
2103 provided by Phoronix Test Suite in pkgsrc, and Anita, a Python tool for
2104 automating NetBSD installation.</p>
2105 </summary>
2106 <content type="html"><p>This report was written by Apurva Nandan as part of Google Summer of Code
2107 2020.</p>
2108
2109 <p>This blog post is in continuation of
2110 <a href="//blog.NetBSD.org/tnf/entry/gsoc_reports_benchmarking_netbsd_first">GSoC Reports: Benchmarking NetBSD, first evaluation report</a>
2111 blog and describes my progress in the second phase of GSoC 2020 under
2112 The NetBSD Foundation.</p>
2113
2114 <p>In this phase, I worked on the automation of the regression suite made
2115 using <a href="https://www.phoronix-test-suite.com">Phoronix Test Suite (PTS)</a>
2116 and its integration with <a href="https://www.gson.org/netbsd/anita">Anita</a>.</p>
2117
2118 <p>The automation framework consists of two components Phoromatic server,
2119 provided by Phoronix Test Suite in pkgsrc, and Anita, a Python tool for
2120 automating NetBSD installation.</p>
2121
2122 <h2>About Phoromatic</h2>
2123
2124 <p>Phoromatic is a remote management system for the Phoronix Test Suite,
2125 which allows the automatic scheduling of tests, remote installation of
2126 new tests, and the management of multiple test systems through a web
2127 interface. Tests can be scheduled to run on a routine basis across
2128 multiple test systems automatically. Phoromatic can also interface with
2129 revision control systems to offer support for issuing new tests on a
2130 context-basis, such as whenever a Git commit has been pushed. The test
2131 results are then available from the web interface.</p>
2132
2133 <h3>Phoromatic client-server architecture</h3>
2134
2135 <p><img src="//www.NetBSD.org/~leot/blog-posts/imgs/pts_phoromatic-server-client-arch.png" alt="Phoromatic server-client architecture" width="800" /></p>
2136
2137 <p>The Phoromatic server relies upon a PHP/HHVM built-in web server
2138 process and a PTS-hosted WebSocket server. The web server process
2139 handles the web UI and the responsibilities of the Phoromatic server.</p>
2140
2141 <p>Phoromatic clients are testing machines installed with PTS that connect
2142 to the Phoromatic web server through the HTTP port of the server.</p>
2143
2144 <h3>Phoromatic Setup</h3>
2145
2146 <p>To start the Phoromatic server, Phoromatic server HTTP port and web
2147 server socket port needs to be set in
2148 <code>~/.phoronix-test-suite/user-config.xml</code> as shown:</p>
2149
2150 <pre>
2151 ...
2152 &lt;Server&gt;
2153 &lt;RemoteAccessPort&gt;8640&lt;/RemoteAccessPort&gt;
2154 &lt;Password&gt;&lt;/Password&gt;
2155 &lt;WebSocketPort&gt;8642&lt;/WebSocketPort&gt;
2156 &lt;AdvertiseServiceZeroConf&gt;TRUE&lt;/AdvertiseServiceZeroConf&gt;
2157 &lt;AdvertiseServiceOpenBenchmarkRelay&gt;TRUE&lt;/AdvertiseServiceOpenBenchmarkRelay&gt;
2158 &lt;PhoromaticStorage&gt;~/.phoronix-test-suite/phoromatic/&lt;/PhoromaticStorage&gt;
2159 &lt;/Server&gt;
2160 </pre>
2161
2162 <h3>Phoromatic Usage</h3>
2163
2164 <p>To start the Phoromatic web server for controlling local Phoronix Test Suite client systems:</p>
2165
2166 <p><code>$ phoronix-test-suite start-phoromatic-server</code></p>
2167
2168 <p>The Phoromatic web server will be hosted at <code>localhost:8640</code> and will require a local account creation on the server.</p>
2169
2170 <h4>Phoromatic Clients</h4>
2171
2172 <p>The Phoromatic client is used for connecting to a Phoromatic server to facilitate the automatic running of tests on that client.</p>
2173
2174 <p>Phoromatic clients can be created and connected to the server using the following command:</p>
2175
2176 <p><code>
2177 $ phoronix-test-suite phoromatic.connect SERVER_IP:SERVER_HTTP_PORT/ACCOUNT_ID
2178 </code></p>
2179
2180 <p>Phoromatic server interacts with the Phoromatic clients through the HTTP port specified in the <code>~/.phoronix-test-suite/user-config.xml</code>.</p>
2181
2182 <h4>Phoromatic Test-schedules</h4>
2183
2184 <p>A test schedule is used to facilitate automatically running a set of
2185 test(s)/suite(s) on either a routine timed basis or whenever triggered
2186 by an external script or process, e.g. Git/VCS commit, manually
2187 triggered, etc.
2188 Phoromatic provides an option for pre-install, pre-run, post-install
2189 and post-run shell scripts that are executed on the Phoromatic
2190 clients.
2191 Test-schedules can be configured to run any tests on any specific
2192 systems.</p>
2193
2194 <h2>About Anita</h2>
2195
2196 <p>Anita is a tool for automated testing of the NetBSD operating system.
2197 Using Anita, we can download a NetBSD distribution and install it in a
2198 virtual machine in a fully automated fashion. Anita is written in
2199 Python and uses the pexpect module to &ldquo;screen scrape&rdquo; the sysinst
2200 output over an emulated serial console and script the installation
2201 procedure.</p>
2202
2203 <h3>Installation</h3>
2204
2205 <p>Anita can be installed on NetBSD, Linux and macOS systems using the following:</p>
2206
2207 <pre>
2208 $ pip install pexpect
2209 $ git clone https://github.com/gson1703/anita/
2210 $ python setup.py install
2211 </pre>
2212
2213 <h2>Phoromatic-Anita Integration</h2>
2214
2215 <p>I would like to describe the workflow here briefly:</p>
2216
2217 <ul>
2218 <li>A test-schedule was created on the Phoromatic server meant to run
2219 <code>pts/idle-1.2.0</code> test on the host machine that contains the
2220 <a href="https://gist.github.com/apurvanandan1997/48b54402db1df3723920735f85fc7934">phoromatic-anita-integration.sh</a>
2221 as a pre-run script.</li>
2222 <li>The script performs the following:
2223
2224 <ul>
2225 <li>Creates a mountable disk image with an executable script for
2226 setting up Phoronix Test Suite and Phoromatic client creation on the
2227 benchmarking VM systems.</li>
2228 <li>Invokes Anita with the appropriate command-line options for
2229 configurations and network setup and mounts the image to run the
2230 configuration script on the VM.</li>
2231 <li>Configuration script performs hostname change, DHCP setup, NFS
2232 setup, <code>PKG_PATH</code> setup, PTS installation, its configuration and
2233 connecting it to the Phoromatic server through a network bridge.</li>
2234 </ul>
2235 </li>
2236 <li>Once the benchmarking VM systems get connected to the Phoromatic
2237 server, Phoromatic server identifies the benchmarking VM systems with
2238 their IP address, hostname and MAC address.</li>
2239 <li>After the identification, Phoromatic initiates the pending tests on
2240 VM (test-profiles are downloaded on the go in the VM and executed) and
2241 maintains a history of the test result data.</li>
2242 </ul>
2243
2244
2245 <p>Few points to be noted:</p>
2246
2247 <ul>
2248 <li>I have used a local PKG_PATH with a NFS server setup as PTS 9.6.1 is
2249 available in wip and recompiling it would be a wastage of time. Later I
2250 have planned to use the binary shard by Joyent:
2251 <a href="https://pkgsrc.joyent.com/packages/NetBSD/9.99.69/amd64/All/">https://pkgsrc.joyent.com/packages/NetBSD/9.99.69/amd64/All/</a> once the
2252 updated PTS gets upstreamed.</li>
2253 <li>The host machine needs some one-time manual setup like installation
2254 of QEMU, Anita, pexpect, term, cvs, etc., initial user registration on
2255 Phoromatic server, Phoromatic port setup, network bridge setup. Apart
2256 from this, the rest of the framework does not require user
2257 supervision.</li>
2258 </ul>
2259
2260
2261 <h5>VM configuration script</h5>
2262
2263 <p>The following script is used as a pre-run script in the test-schedules for invoking Anita and setting up the VMs:</p>
2264
2265 <p><a href="https://gist.github.com/apurvanandan1997/48b54402db1df3723920735f85fc7934">https://gist.github.com/apurvanandan1997/48b54402db1df3723920735f85fc7934</a></p>
2266
2267 <h5>Networking Setup</h5>
2268
2269 <p>A bridged networking mode configuration of QEMU has been used in Anita
2270 as multiple VMs will be able to accommodate with a single bridge
2271 (created on the host machine, one-time setup) using
2272 <a href="//man.NetBSD.org/dhcpcd.8">dhcpcd(8)</a>,
2273 without complicated host forwarding setup (Phoromatic server requires
2274 HTTP port forwarding).</p>
2275
2276 <p>In order to enable bridged networking for your QEMU guests, you must
2277 first create and configure a bridge interface on your host.</p>
2278
2279 <pre>
2280 # ifconfig virbr0 create
2281 </pre>
2282
2283 <p>Next, you must specify the newly-created bridge interface in
2284 <code>/etc/qemu/bridge.conf</code>:</p>
2285
2286 <pre>
2287 $ sudo mkdir /etc/qemu
2288 $ sudo touch /etc/qemu/bridge.conf &amp;&amp; sudo chmod 644 /etc/qemu/bridge.conf
2289 $ sudo sh -c "echo 'allow virbr0' >> /etc/qemu/bridge.conf"
2290 </pre>
2291
2292 <p>Finally, in order for non-privileged processes to be able to invoke
2293 qemu-bridge-helper, you must set the setuid bit on the utility:</p>
2294
2295 <p><code>
2296 $ sudo chmod u+s /usr/local/libexec/qemu-bridge-helper
2297 </code></p>
2298
2299 <p>For more details on the bridged mode networking setup in QEMU, please
2300 refer to the following guides:</p>
2301
2302 <ul>
2303 <li><a href="https://t.pagef.lt/basic-networking-with-qemu/">https://t.pagef.lt/basic-networking-with-qemu/</a></li>
2304 <li><a href="https://www.NetBSD.org/docs/guide/en/chap-net-practice.html#chap-net-practice-bridge">https://www.NetBSD.org/docs/guide/en/chap-net-practice.html#chap-net-practice-bridge</a></li>
2305 </ul>
2306
2307
2308 <h5>Reproducing the framework</h5>
2309
2310 <p>To reproduce the framework, you need to have Phoronix Test Suite, QEMU,
2311 Anita, pexpect, cvs, xterm, makefs installed on your host machine.</p>
2312
2313 <p>For example on NetBSD:</p>
2314
2315 <pre>
2316 # pkg_add qemu
2317 # pkg_add py37-anita
2318 $ cd pkgsrc/wip/phoronix-test-suite
2319 $ make install
2320 </pre>
2321
2322 <p>The step-by-step process to get the framework after installing PTS,
2323 including the one-time manual setup, can be summarized as follows: All
2324 control and configuration of the Phoromatic Server is done via the
2325 web-based interface when the Phoromatic Server is active.</p>
2326
2327 <ul>
2328 <li>Configure the port of Phoromatic server as 8640 and web socket as
2329 8642 as described above.</li>
2330 <li>Start the Phoromatic server using the command stated above.
2331 <img src="//www.NetBSD.org/~leot/blog-posts/imgs/pts_phoromatic-register.png" alt="Phoromatic login page image" width="800" /></li>
2332 <li>Create your user account on the Phoromatic server using the web interface GUI.
2333 <img src="//www.NetBSD.org/~leot/blog-posts/imgs/pts_phoromatic.png" alt="Phoromatic default page image" width="800" /></li>
2334 <li>Disable client system approval for new system addition from the
2335 settings menu in the web interface.</li>
2336 <li>Connect the host machine as a Phoromatic client to the Phoromatic
2337 server using the command stated above.</li>
2338 <li>Create a test-schedule for the host machine with the
2339 <a href="https://gist.github.com/apurvanandan1997/48b54402db1df3723920735f85fc7934">pre-run script</a>
2340 as specified above and <code>pts/idle-1.2.0</code> as the test-profile.
2341 <img src="//www.NetBSD.org/~leot/blog-posts/imgs/pts_create-sch.png" alt="Phoromatic create test-schedule image" width="800" /></li>
2342 <li>Execute the test-schedule or assign it on a timed-schedule and watch it running!
2343 <img src="//www.NetBSD.org/~leot/blog-posts/imgs/pts_host-machine-test-sch.png" alt="Phoromatic Anita integration test-scehdule" width="800" /></li>
2344 <li>New VM systems with the latest NetBSD-current binaries and packages
2345 will be created and identified by Phoromatic server automatically.</li>
2346 <li>Once for all, we need to specify what benchmarking test-profiles need
2347 to be run on the VM systems in the test-schedules section and it will
2348 be taken care of by Phoromatic.
2349 <img src="//www.NetBSD.org/~leot/blog-posts/imgs/pts_test-sch.png" alt="Phoromatic benchmarking system test-schedule image" width="800" /></li>
2350 <li>The result history can also be viewed from Phoromatic web interface.</li>
2351 </ul>
2352
2353
2354 <p>You can have a look at the video to get a clearer picture of how to
2355 setup the framework:</p>
2356
2357 <iframe width="800" height="450" src="https://www.youtube.com/embed/7OSaqDWIsxo" frameborder="0"></iframe>
2358
2359 <h2>Future Plans</h2>
2360
2361 <p>The regression suite is complete and final tasks of deploying it on
2362 benchmark.NetBSD.org and upstreaming the wip of Phoronix Test Suite
2363 will be done in the final phase of my GSoC project.
2364 I want to thank my mentors for their constant support.</p>
2365 </content>
2366 </entry>
2367 <entry>
2368 <id>https://blog.netbsd.org/tnf/entry/gsoc_2020_second_evaluation_report</id>
2369 <title type="html">GSoC 2020 Second Evaluation Report: Curses Library Automated Testing</title>
2370 <author><name>Kamil Rytarowski</name></author>
2371 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_2020_second_evaluation_report"/>
2372 <published>2020-08-07T11:21:00+00:00</published>
2373 <updated>2020-08-07T11:47:52+00:00</updated>
2374 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
2375 <category term="curses" scheme="http://roller.apache.org/ns/tags/" />
2376 <summary type="html"><i>This report was prepared by Naman Jain as a part of Google Summer of Code 2020</i>
2377 <p>My GSoC project under NetBSD involves the development of test framework of curses library. This blog report is second in series of blog reports; you can have a look at the <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_curses_library_automated" rel="nofollow">first report</a>. This report would cover the progress made in second coding phase along with providing some insights into the libcurses.</p></summary>
2378 <content type="html"><i>This report was prepared by Naman Jain as a part of Google Summer of Code 2020</i>
2379 <p>My GSoC project under NetBSD involves the development of test framework of curses library. This blog report is second in series of blog reports; you can have a look at the <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_curses_library_automated" rel="nofollow">first report</a>. This report would cover the progress made in second coding phase along with providing some insights into the libcurses.</p>
2380 <h2><a id="user-content-complex-characters" class="anchor" aria-hidden="true" href="#complex-characters"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Complex characters</h2>
2381 <p>A complex character is a set of associated character, which may include a spacing character and non-spacing characters associated with it. Typical effects of non-spacing character on associated complex character <em>c</em> include: modifying the appearance of <em>c</em> (like adding diacritical marks) or bridge <em>c</em> with the following character.
2382 The <strong>cchar_t</strong> data type represents a complex character and its rendition. In NetBSD, this data type has following structure:</p>
2383 <div class="highlight highlight-source-c"><pre><span class="pl-k">struct</span> <span class="pl-c1">cchar_t</span> {
2384 <span class="pl-c1">attr_t</span> attributes; <span class="pl-c"><span class="pl-c">/*</span> character attributes <span class="pl-c">*/</span></span>
2385 <span class="pl-k">unsigned</span> elements; <span class="pl-c"><span class="pl-c">/*</span> number of wide char in vals<span class="pl-c">*/</span></span>
2386 <span class="pl-c1">wchar_t</span> vals[CURSES_CCHAR_MAX]; <span class="pl-c"><span class="pl-c">/*</span> wide chars including non-spacing <span class="pl-c">*/</span></span>
2387 };</pre></div>
2388 <p><em>vals</em> array contains the spacing character and associated non-spacing characters. Note that NetBSD supports <strong>wchar_t</strong> (wide character) due to which multi-byte characters are supported. To use the complex characters one has to correctly set the locale settings.
2389 In this coding period, I wrote tests for routines involving complex characters.</p>
2390 <h2><a id="user-content-alternate-character-set" class="anchor" aria-hidden="true" href="#alternate-character-set"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Alternate character set</h2>
2391 <p>When you print "BSD", you would send the hex-codes 42, 53, 44 to the terminal. Capability of graphic capable printers was limited by 8-bit ASCII code. To solve this, additional character sets were introduced. We can switch between the modes using escape sequence. One such character set for Special Graphics is used by curses for line drawing. In a shell you can type</p>
2392 <div class="highlight highlight-source-shell"><pre><span class="pl-c1">echo</span> -e <span class="pl-s"><span class="pl-pds">"</span>\e(0j\e(b<span class="pl-pds">"</span></span></pre></div>
2393 <p>to get a lower-right corner glyph. This enables alternate character mode (<code>\e(</code>), prints a character(<code>j</code>) and disables alternate character mode (<code>\e(b</code>). One might wonder where this 'j' to 'Lower Right Corner glyph' comes from. You may see that mapping ("acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,) via</p>
2394 <div class="highlight highlight-source-shell"><pre>infocmp -1 <span class="pl-smi">$TERM</span> <span class="pl-k">|</span> grep acsc</pre></div>
2395 <p>These characters are used in <code>box_set()</code>, <code>border_set()</code>, etc. functions which I tested in the second coding period.</p>
2396 <h2><a id="user-content-progress-in-the-second-coding-phase" class="anchor" aria-hidden="true" href="#progress-in-the-second-coding-phase"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Progress in the second coding phase</h2>
2397 <h3><a id="user-content-improvements-in-the-framework" class="anchor" aria-hidden="true" href="#improvements-in-the-framework"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Improvements in the framework:</h3>
2398 <ol>
2399 <li>Added support for testing of functions to be called before <code>initscr()</code></li>
2400 <li>Updated the unsupported function definitions with some minor bug fixes.</li>
2401 </ol>
2402 <h3><a id="user-content-testing-and-bug-reports" class="anchor" aria-hidden="true" href="#testing-and-bug-reports"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Testing and bug reports</h3>
2403 <ol>
2404 <li>Added tests for following families of functions:
2405 <ul>
2406 <li>Complex character routines.</li>
2407 <li>Line/box drawing routines.</li>
2408 <li>Pad routines.</li>
2409 <li>Window and sub-window operations.</li>
2410 <li>Curson manipulation routines</li>
2411 </ul>
2412 </li>
2413 <li>Reported bugs (and possible fixes if I know):
2414 <ul>
2415 <li><a href="https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55454" rel="nofollow">lib/55454</a> <code>wredrawln()</code> in libcurses does not follow the sensible behaviour [<em>fixed</em>]</li>
2416 <li><a href="https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55460" rel="nofollow">lib/55460</a> copy error in libcurses [<em>fixed</em>]</li>
2417 <li><a href="https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55474" rel="nofollow">lib/55474</a> <code>wattroff()</code> unsets all attributes if passed STANDOUT as argument [<em>standard is not clear, so decided to have as it is</em>]</li>
2418 <li><a href="https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55482" rel="nofollow">lib/55482</a> <code>slk_restore()</code> does not restore the slk screen</li>
2419 <li><a href="https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55484" rel="nofollow">lib/55484</a> <code>newwin()</code> results into seg fault [<em>fixed</em>]</li>
2420 <li><a href="https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55496" rel="nofollow">lib/55496</a> <code>bkgrnd()</code> doesn't work as expected</li>
2421 <li><a href="https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55517" rel="nofollow">lib/55517</a> <code>wresize()</code> function incorrectly resizes the subwindows</li>
2422 </ul>
2423 </li>
2424 </ol>
2425 <p>I would like to thank my mentors Brett and Martin, as well as the NetBSD community for their support whenever I faced some issues.</p></content>
2426 </entry>
2427 <entry>
2428 <id>https://blog.netbsd.org/tnf/entry/gsoc_reports_fuzzing_rumpkernel_syscalls1</id>
2429 <title type="html">GSoC Reports: Fuzzing Rumpkernel Syscalls, Part 2</title>
2430 <author><name>Kamil Rytarowski</name></author>
2431 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_reports_fuzzing_rumpkernel_syscalls1"/>
2432 <published>2020-08-05T08:42:37+00:00</published>
2433 <updated>2020-08-05T08:42:37+00:00</updated>
2434 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
2435 <category term="fuzzing" scheme="http://roller.apache.org/ns/tags/" />
2436 <category term="rump" scheme="http://roller.apache.org/ns/tags/" />
2437 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
2438 <summary type="html"><i>This report was prepared by Aditya Vardhan Padala as a part of Google Summer of Code 2020</i>
2439 <p>I have been working on Fuzzing Rumpkernel Syscalls. This blogpost details the work I have done during my second coding period.</p></summary>
2440 <content type="html"><i>This report was prepared by Aditya Vardhan Padala as a part of Google Summer of Code 2020</i>
2441 <p>I have been working on Fuzzing Rumpkernel Syscalls. This blogpost details the work I have done during my second coding period.</p>
2442 <h2 id="reproducing-crash-found-in-ioctl-">Reproducing crash found in ioctl()</h2>
2443 <p>Kamil has worked on reproducing the following crash </p>
2444 <pre><code class="lang-bash=">Thread <span class="hljs-number">1</span> <span class="hljs-string">""</span> received signal SIGSEGV, Segmentation fault.
2445 pipe_ioctl (fp=&lt;optimized <span class="hljs-keyword">out</span>&gt;, cmd=&lt;optimized <span class="hljs-keyword">out</span>&gt;, data=<span class="hljs-number">0x7f7fffccd700</span>)
2446 at /usr/src/<span class="hljs-class"><span class="hljs-keyword">lib</span>/<span class="hljs-title">librump</span>/../../<span class="hljs-title">sys</span>/<span class="hljs-title">rump</span>/../<span class="hljs-title">kern</span>/<span class="hljs-title">sys_pipe</span>.<span class="hljs-title">c</span>:1108</span>
2447 <span class="hljs-symbol">warning:</span> Source file is more recent than executable.
2448 <span class="hljs-number">1108</span> *(int *)data = pipe-&gt;pipe_buffer.cnt;
2449 (gdb) bt
2450 <span class="hljs-comment">#0 pipe_ioctl (fp=&lt;optimized out&gt;, cmd=&lt;optimized out&gt;, data=0x7f7fffccd700)</span>
2451 at /usr/src/<span class="hljs-class"><span class="hljs-keyword">lib</span>/<span class="hljs-title">librump</span>/../../<span class="hljs-title">sys</span>/<span class="hljs-title">rump</span>/../<span class="hljs-title">kern</span>/<span class="hljs-title">sys_pipe</span>.<span class="hljs-title">c</span>:1108</span>
2452 <span class="hljs-comment">#1 0x000075b0de65083f in sys_ioctl (l=&lt;optimized out&gt;, uap=0x7f7fffccd820, retval=&lt;optimized out&gt;)</span>
2453 at /usr/src/<span class="hljs-class"><span class="hljs-keyword">lib</span>/<span class="hljs-title">librump</span>/../../<span class="hljs-title">sys</span>/<span class="hljs-title">rump</span>/../<span class="hljs-title">kern</span>/<span class="hljs-title">sys_generic</span>.<span class="hljs-title">c</span>:671</span>
2454 <span class="hljs-comment">#2 0x000075b0de6b8957 in sy_call (rval=0x7f7fffccd810, uap=0x7f7fffccd820, l=0x75b0de126500, </span>
2455 sy=&lt;optimized <span class="hljs-keyword">out</span>&gt;) at /usr/src/<span class="hljs-class"><span class="hljs-keyword">lib</span>/<span class="hljs-title">librump</span>/../../<span class="hljs-title">sys</span>/<span class="hljs-title">rump</span>/../<span class="hljs-title">sys</span>/<span class="hljs-title">syscallvar</span>.<span class="hljs-title">h</span>:65</span>
2456 <span class="hljs-comment">#3 sy_invoke (code=54, rval=0x7f7fffccd810, uap=0x7f7fffccd820, l=0x75b0de126500, sy=&lt;optimized out&gt;)</span>
2457 at /usr/src/<span class="hljs-class"><span class="hljs-keyword">lib</span>/<span class="hljs-title">librump</span>/../../<span class="hljs-title">sys</span>/<span class="hljs-title">rump</span>/../<span class="hljs-title">sys</span>/<span class="hljs-title">syscallvar</span>.<span class="hljs-title">h</span>:94</span>
2458 <span class="hljs-comment">#4 rump_syscall (num=num@entry=54, data=data@entry=0x7f7fffccd820, dlen=dlen@entry=24, </span>
2459 retval=retval@entry=<span class="hljs-number">0x7f7fffccd810</span>)
2460 at /usr/src/<span class="hljs-class"><span class="hljs-keyword">lib</span>/<span class="hljs-title">librump</span>/../../<span class="hljs-title">sys</span>/<span class="hljs-title">rump</span>/<span class="hljs-title">librump</span>/<span class="hljs-title">rumpkern</span>/<span class="hljs-title">rump</span>.<span class="hljs-title">c</span>:769</span>
2461 <span class="hljs-comment">#5 0x000075b0de6ad2ca in rump___sysimpl_ioctl (fd=&lt;optimized out&gt;, com=&lt;optimized out&gt;, </span>
2462 data=&lt;optimized <span class="hljs-keyword">out</span>&gt;) at /usr/src/<span class="hljs-class"><span class="hljs-keyword">lib</span>/<span class="hljs-title">librump</span>/../../<span class="hljs-title">sys</span>/<span class="hljs-title">rump</span>/<span class="hljs-title">librump</span>/<span class="hljs-title">rumpkern</span>/<span class="hljs-title">rump_syscalls</span>.<span class="hljs-title">c</span>:979</span>
2463 <span class="hljs-comment">#6 0x0000000000400bf7 in main (argc=1, argv=0x7f7fffccd8c8) at test.c:15</span>
2464 </code></pre>
2465 <p>in the rump using a fuzzer that uses pip2, dup2 and ioctl syscalls and specific arguments that are known to cause a crash upon which my work develops.</p>
2466 <p><a href="https://github.com/adityavardhanpadala/rumpsyscallfuzz/blob/master/honggfuzz/ioctl/ioctl_fuzz2.c">https://github.com/adityavardhanpadala/rumpsyscallfuzz/blob/master/honggfuzz/ioctl/ioctl_fuzz2.c</a></p>
2467 <p>Since rump is a multithreaded process. Crash occurs in any of those threads. By using a core dump we can quickly investigate the crash and fetch the backtrace from gdb for verification however this is not viable in the long run as you would be loading your working directory with lots of core dumps which consume a lot of space. So we need a better way to reproduce crashes.</p>
2468 <h2 id="crash-reproducers">Crash Reproducers</h2>
2469 <p>Getting crash reproducers working took quite a while. If we look at HF_ITER() function in honggfuzz, it is a simple wrapper for HonggfuzzFetchData() to fetch buffer of fixed size from the fuzzer.</p>
2470 <pre><code class="lang-cpp=">void HonggfuzzFetchData(const uint8<span class="hljs-emphasis">_t** buf_</span>ptr, size<span class="hljs-emphasis">_t* len_</span>ptr) {
2471 <span class="hljs-bullet">.
2472 </span><span class="hljs-bullet">.
2473 </span><span class="hljs-bullet">.
2474 </span><span class="hljs-bullet">.
2475 </span><span class="hljs-strong">*buf_ptr = inputFile;
2476 *</span>len<span class="hljs-emphasis">_ptr = (size_</span>t)rcvLen;
2477 <span class="hljs-bullet">.
2478 </span><span class="hljs-bullet">.
2479 </span>}
2480 </code></pre>
2481 <p>And if we observe the attribute we notice that <code>inputFile</code> is mmaped. </p>
2482 <pre><code class="lang-cpp="><span class="hljs-comment">//libhfuzz/fetch.c:26</span>
2483 <span class="hljs-keyword">if</span> ((inputFile = mmap(<span class="hljs-literal">NULL</span>, _HF_INPUT_MAX_SIZE, PROT_READ, MAP_SHARED, _HF_INPUT_FD, <span class="hljs-number">0</span>)) ==
2484 MAP_FAILED) {
2485 PLOG_F(<span class="hljs-string">"mmap(fd=%d, size=%zu) of the input file failed"</span>, _HF_INPUT_FD,
2486 (<span class="hljs-keyword">size_t</span>)_HF_INPUT_MAX_SIZE);
2487 }
2488 </code></pre>
2489 <p>So in a similar approach HF_ITER() can be modified to read input from a file and be mmapped so that we can reuse the reproducers generated by honggfuzz.</p>
2490 <p>Attempts have been made to use getchar(3) for fetching the buffer via STDIN but for some unknown reason it failed so we switched to mmap(2) </p>
2491 <p>So we overload HF_ITER() function whenever we require to reproduce a crash. I chose the following approach to use the reproducers. So whenever we need to reproduce a crash we just define CRASH_REPR.</p>
2492 <pre><code class="lang-cpp=">
2493 <span class="hljs-function"><span class="hljs-keyword">static</span>
2494 <span class="hljs-keyword">void</span> <span class="hljs-title">Initialize</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span>
2495 </span>{
2496 <span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> CRASH_REPR</span>
2497 FILE *fp = fopen(argv[<span class="hljs-number">1</span>], <span class="hljs-string">"r+"</span>);
2498 data = <span class="hljs-built_in">malloc</span>(max_size);
2499 fread(data, max_size, <span class="hljs-number">1</span>, fp);
2500 fclose(fp);
2501 <span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>
2502 <span class="hljs-comment">// Initialise the rumpkernel only once.</span>
2503 <span class="hljs-keyword">if</span>(rump_init() != <span class="hljs-number">0</span>)
2504 __builtin_trap();
2505 }
2506
2507 <span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> CRASH_REPR</span>
2508 <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">HF_ITER</span><span class="hljs-params">(<span class="hljs-keyword">uint8_t</span> **buf, <span class="hljs-keyword">size_t</span> *len)</span> </span>{
2509 *buf = (<span class="hljs-keyword">uint8_t</span> *)data;
2510 *len = max_size;
2511 <span class="hljs-keyword">return</span>;
2512 }
2513 <span class="hljs-meta">#<span class="hljs-meta-keyword">else</span></span>
2514 <span class="hljs-function">EXTERN <span class="hljs-keyword">void</span> <span class="hljs-title">HF_ITER</span><span class="hljs-params">(<span class="hljs-keyword">uint8_t</span> **buf, <span class="hljs-keyword">size_t</span> *len)</span></span>;
2515 <span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>
2516 </code></pre>
2517 <p>This way we can easily reproduce crashes that we get and get the backtraces.</p>
2518 <h2 id="generating-c-reproducers">Generating C reproducers</h2>
2519 <p>Now the main goal is to create a c file which can reproduce the same crash occuring due to the reproducer. This is done by writing all the syscall executions to a file with arguments so they can directly be compiled and used.</p>
2520 <pre><code class="lang-cpp=">#ifdef CRASH_REPR
2521 FILE *fp = fopen(<span class="hljs-string">"/tmp/repro.c"</span>,<span class="hljs-string">"a+"</span>)<span class="hljs-comment">;</span>
2522 fprintf(<span class="hljs-name">fp</span>, <span class="hljs-string">"rump_sys_ioctl(%"</span> PRIu8 <span class="hljs-string">", %"</span> PRIu64 <span class="hljs-string">");\n"</span>,get_u8(),get_ioctl_request())<span class="hljs-comment">;</span>
2523 fclose(<span class="hljs-name">fp</span>)<span class="hljs-comment">;</span>
2524 #else
2525 rump_sys_ioctl(<span class="hljs-name">get_u8</span>(), get_ioctl_request())<span class="hljs-comment">;</span>
2526 #endif
2527 </code></pre>
2528 <p>I followed the same above method for all the syscalls that are executed. So I get a proper order of syscalls executed in native c code that I can simply reuse.</p>
2529 <h3 id="obstacles">Obstacles</h3>
2530 <p>The number of times each syscall is executed before getting to a crash is quite high. So trying to perform a write to a file or STDOUT will create a lot of overhead when the number of syscalls executed are quite high. This method is good enough but a bit of optimization will make it even better.</p>
2531 <h2 id="to-do">To-Do</h2>
2532 <ul>
2533 <li>./build.sh building rump on linux+netbsd</li>
2534 <li>pregenerating fuzzer input using the implementation similar to that used in syzkaller.</li>
2535 </ul>
2536 <p>Finally I thank my mentors Siddharth Muralee, Maciej Grochowski, Christos Zoulas for their guidance and Kamil Rytarowski for his constant support whenever I needed it.</p></content>
2537 </entry>
2538 <entry>
2539 <id>https://blog.netbsd.org/tnf/entry/gsoc_reports_enhancing_syzkaller_support1</id>
2540 <title type="html">GSoC Reports: Enhancing Syzkaller support for NetBSD, Part 2</title>
2541 <author><name>Kamil Rytarowski</name></author>
2542 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_reports_enhancing_syzkaller_support1"/>
2543 <published>2020-08-05T08:10:10+00:00</published>
2544 <updated>2020-08-05T08:10:10+00:00</updated>
2545 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
2546 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
2547 <category term="syzkaller" scheme="http://roller.apache.org/ns/tags/" />
2548 <category term="fuzzing" scheme="http://roller.apache.org/ns/tags/" />
2549 <summary type="html"><i>This report was prepared by Ayushi Sharma as a part of Google Summer of Code 2020</i>
2550
2551 <p>As a part of Google summer code 2020, I have been working on <a href="https://wiki.netbsd.org/projects/project/syzkaller/">Enhance the Syzkaller support for NetBSD</a>. This post summarises the work done in the past month.</p>
2552
2553 <p>For work done in the first coding period, you can take a look at the <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_enhancing_syzkaller_support">previous post</a>.</p>
2554
2555 <h2>Automation for enhancement</h2>
2556 <p>With an aim of increasing the number of syscalls fuzzed, we have decided to automate the addition of descriptions for syscalls as well as ioctl device drivers in a customised way for NetBSD.</p></summary>
2557 <content type="html"><i>This report was prepared by Ayushi Sharma as a part of Google Summer of Code 2020</i>
2558
2559 <p>As a part of Google summer code 2020, I have been working on <a href="https://wiki.netbsd.org/projects/project/syzkaller/">Enhance the Syzkaller support for NetBSD</a>. This post summarises the work done in the past month.</p>
2560
2561 <p>For work done in the first coding period, you can take a look at the <a href="https://blog.netbsd.org/tnf/entry/gsoc_reports_enhancing_syzkaller_support">previous post</a>.</p>
2562
2563 <h2>Automation for enhancement</h2>
2564 <p>With an aim of increasing the number of syscalls fuzzed, we have decided to automate the addition of descriptions for syscalls as well as ioctl device drivers in a customised way for NetBSD.</p>
2565
2566 <h2>Design</h2>
2567 <p>All the ioctl commands for a device driver in NetBSD are stored inside the <q>/src/sys/dev/&ltdriver_name&gt/</q> folder. The idea is to get information related to a particular ioctl command by extracting required information from the source code of drivers. To achieve the same, we have broken down our project into majorly three phases.</p>
2568 <ol>
2569 <li>Generating preprocessed files</li>
2570 <li>Extracting information required for generating descriptions</li>
2571 <li>Conversion to syzkaller’s grammar</li>
2572 </ol>
2573
2574 <img src="//netbsd.org/~kamil/gsoc_2020/sys2syz.png" alt="Design" style="border:10px solid white;">
2575
2576
2577 <h2>Generating Preprocessed files</h2>
2578 <p>For a given preprocessed file, c2xml tool outputs the preprocessed C code in xml format. Further, the intermediate xml format descriptions would help us to smoothly transform the c code to syzkaller specific descriptions, in the last stage of this tool. We have used <a href=https://github.com/rizsotto/Bear>Bear</a> as an aid for fetching commands to preprocess files for a particular driver. Bear generates a file called compile_commands.json which stores the commands used for compiling a file in json format. We then run these commands with ‘-E’ gcc flag to fetch the preprocessed files.These preprocessed files then serve as an input to the c2xml program.</p>
2579
2580
2581 <h2>Extractor</h2>
2582 <p>Definition of <a href="//man.NetBSD.org/ioctl.9">ioctl</a> calls defined in header files of device driver in NetBSD can be broken down to:</p>
2583
2584 <img src="//netbsd.org/~kamil/gsoc_2020/ioctl_def.png" alt="ioctl" >
2585
2586 <p>When we see it from syzkaller’s perspective, there are basically three significant parts we need to extract for adding description to syzkaller.</p>
2587
2588 <p>Description of a particular ioctl command acc to syzkaller’s grammar:</p>
2589
2590 <p>ioctl$FOOIOCTL(fd &ltfd_driver&gt, cmd const[FOOIOCTL], pt ptr[DIR, &ltptr_type&gt])
2591
2592 <br>
2593 <img src="//netbsd.org/~kamil/gsoc_2020/ioctl_desc_1.png" alt="ioctl description">
2594 <br>
2595 <img src="//netbsd.org/~kamil/gsoc_2020/ioctl_desc_2.png" alt="ioctl description">
2596
2597 <p>These definitions can be grepped from a device’s header files. The type information or description for pointer can then be extracted from the output files generated by c2xml. If the third argument is a struct, the direction of the pointer is determined with the help of fun() macros.
2598
2599
2600 <h2>To-Do</h2>
2601 <p>The extracted descriptions have to be converted into syzkaller-friendly grammer. We plan to add support for syscalls too , which would ease the addition of complex compat syscalls. This would help us to increase the syzkaller’s coverage significantly.
2602
2603 <h2>Stats</h2>
2604 Along with this, We have continued to add support for few more syscalls these include:
2605 <ul>
2606 <li>ksem(2) family</li>
2607 <li>mount(2) family</li>
2608 </ul>
2609 Syscalls related to sockets have also been added. This has increased syscall coverage percentage to 50.35.
2610
2611 <p>Atlast, I would like to thank my mentors - Cryo, Siddharth Muralee and Santhosh along with Kamil for their guidance and support. I am thankful to NetBSD community too along with Google for providing me such an amazing opportunity. </content>
2612 </entry>
2613 <entry>
2614 <id>https://blog.netbsd.org/tnf/entry/the_gnu_gdb_debugger_and2</id>
2615 <title type="html">The GNU GDB Debugger and NetBSD (Part 3)</title>
2616 <author><name>Kamil Rytarowski</name></author>
2617 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/the_gnu_gdb_debugger_and2"/>
2618 <published>2020-08-04T16:45:37+00:00</published>
2619 <updated>2020-08-04T16:45:37+00:00</updated>
2620 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
2621 <category term="gdb" scheme="http://roller.apache.org/ns/tags/" />
2622 <summary type="html">The NetBSD team of developers maintains two copies of GDB:
2623 <ul>
2624 <li>One in the base-system with a stack of local patches.</li>
2625 <li>One in pkgsrc with mostly build fix patches.</li>
2626 </ul>
2627 <p>
2628 The base-system version of GDB (GPLv3) still relies on a set of local patches.
2629 I set a goal to reduce the local patches to bare minimum, ideally reaching no local modifications at all.</summary>
2630 <content type="html">The NetBSD team of developers maintains two copies of GDB:
2631 <ul>
2632 <li>One in the base-system with a stack of local patches.</li>
2633 <li>One in pkgsrc with mostly build fix patches.</li>
2634 </ul>
2635 <p>
2636 The base-system version of GDB (GPLv3) still relies on a set of local patches.
2637 I set a goal to reduce the local patches to bare minimum, ideally reaching no local modifications at all.
2638 <p>
2639 <h1>GDB changes</h1>
2640 <p>
2641 I've written an integration of GDB with fork(2) and vfork(2) events.
2642 Unfortunately, this support (present in a local copy of GDB in the base-system) had not been merged so far, because
2643 there is a generic kernel regression with the pg_jobc variable. This variable can be called
2644 a reference counter of the number of processes within a process group that has a parent with control over a terminal.
2645 The semantics of this variable are not very well defined and in the result the number can become negative.
2646 This unexpected state of pg_jobc resulted in spurious crashes during kernel fuzzing. As a result
2647 new kernel assertions checking for non-negative pg_jobc values were introduced in order to catch the anomalies quickly.
2648 GDB as a ptrace(2)-based application happened to reproduce negative pg_jobc values quickly and reliably and this stopped
2649 the further adoption of the fork(2) and vfork(2) patch in GDB, until the pg_jobc behavior is enhanced.
2650 I was planning to include support for posix_spawn(3) events as well, as they are implemented as a first-class
2651 operation through a syscall, however this is also blocked by the pg_jobc blocker.
2652 <p>
2653 A local patch for GDB is stored
2654 <a href="//netbsd.org/~kamil/patch-00276-gdb-fork-vfork-events.txt">here</a>
2655 for the time being.
2656 <p>
2657 I've enable multi-process mode in the NetBSD native target.
2658 This enabled proper support for multiple inferiors and ptrace(2)
2659 assisted management of the inferior processes and their threads.
2660 <p>
2661 <pre>
2662 (gdb) info inferior
2663 Num Description Connection Executable
2664 * 1 process 14952 1 (native) /usr/bin/dig
2665 2 &lt;null&gt; 1 (native)
2666 3 process 25684 1 (native) /bin/ls
2667 4 &lt;null&gt; 1 (native) /bin/ls
2668 </pre>
2669 <p>
2670 Without this change, additional inferiors could be already added, but not properly controlled.
2671 <p>
2672 I've implemented the xfer_partial TARGET_OBJECT_SIGNAL_INFO support for NetBSD.
2673 NetBSD implements reading and overwriting siginfo_t received by the
2674 tracee. With TARGET_OBJECT_SIGNAL_INFO signal information can be
2675 examined and modified through the special variable $_siginfo.
2676 Currently NetBSD uses an identical siginfo type on
2677 all architectures, so there is no support for architecture-specific fields.
2678 <pre>
2679 (gdb) b main
2680 Breakpoint 1 at 0x71a0
2681 (gdb) r
2682 Starting program: /bin/ps
2683
2684 Breakpoint 1, 0x00000000002071a0 in main ()
2685 (gdb) p $_siginfo
2686 $1 = {si_pad = {5, 0, 0, 0, 1, 0 <repeats 19 times>, 1, 0 <repeats 103 times>}, _info = {_signo = 5,
2687 _code = 1, _errno = 0, _pad = 0, _reason = {_rt = {_pid = 0, _uid = 0, _value = {sival_int = 1,
2688 sival_ptr = 0x1}}, _child = {_pid = 0, _uid = 0, _status = 1, _utime = 0, _stime = 0},
2689 _fault = {_addr = 0x0, _trap = 1, _trap2 = 0, _trap3 = 0}, _poll = {_band = 0, _fd = 1},
2690 _syscall = {_sysnum = 0, _retval = {0, 1}, _error = 0, _args = {0, 0, 0, 0, 0, 0, 0, 0}},
2691 _ptrace_state = {_pe_report_event = 0, _option = {_pe_other_pid = 0, _pe_lwp = 0}}}}}
2692 </pre>
2693 <p>
2694 NetBSD, contrary to Linux and other BSDs, supports a ptrace(2) operation to
2695 generate a core(5) file from a running process. This operation is used in the
2696 base-system gcore(1) program. The gcore functionality is also delivered by GDB, and
2697 I have prepared new code for GDB to wire PT_DUMPCORE into the GDB code for NetBSD,
2698 and thus support GDB's gcore functionality.
2699 This patch is still waiting in upstream review.
2700 A local copy of the patch is
2701 <a href="//netbsd.org/~kamil/patch-00277-gdb-dumpcore.txt">here</a>.
2702 <p>
2703 <pre>
2704 (gdb) r
2705 Starting program: /bin/ps
2706
2707 Breakpoint 1, 0x00000000002071a0 in main ()
2708 (gdb) gcore
2709 Saved corefile core.4378
2710 (gdb) !file core.4378
2711 core.4378: ELF 64-bit LSB core file, x86-64, version 1 (SYSV), NetBSD-style, from 'ps', pid=4378, uid=1000, gid=100, nlwps=1, lwp=4378 (signal 5/code 1)
2712 </pre>
2713 <p>
2714 <h1>Plan for the next milestone</h1>
2715 <p>
2716 Rewrite the gdbserver support and submit upstream.
2717 </content>
2718 </entry>
2719 <entry>
2720 <id>https://blog.netbsd.org/tnf/entry/gsoc_reports_benchmarking_netbsd_first</id>
2721 <title type="html">GSoC Reports: Benchmarking NetBSD, first evaluation report</title>
2722 <author><name>Leonardo Taccari</name></author>
2723 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_reports_benchmarking_netbsd_first"/>
2724 <published>2020-07-16T09:38:58+00:00</published>
2725 <updated>2020-07-17T16:00:11+00:00</updated>
2726 <category term="/General" label="General" />
2727 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
2728 <category term="benchmarking" scheme="http://roller.apache.org/ns/tags/" />
2729 <category term="pkgsrc" scheme="http://roller.apache.org/ns/tags/" />
2730 <summary type="html"><p>This report was written by Apurva Nandan as part of Google Summer of Code 2020.</p>
2731
2732 <p>My GSoC project under NetBSD involves developing an automated
2733 regression and performance test framework for NetBSD that offers
2734 reproducible benchmarking results with detailed history and logs across
2735 various hardware &amp; architectures.</p>
2736
2737 <p>To achieve this performance testing framework, I am using the
2738 <a href="https://www.phoronix-test-suite.com/">Phoronix Test Suite (PTS)</a>
2739 which is an open-source, cross-platform automated testing/benchmarking
2740 software for Linux, Windows and BSD environments. It allows the
2741 creation of new tests using simple XML files and shell scripts and
2742 integrates with revision control systems for per-commit regression
2743 testing.</p></summary>
2744 <content type="html"><p>This report was written by Apurva Nandan as part of Google Summer of Code 2020.</p>
2745
2746 <p>My GSoC project under NetBSD involves developing an automated
2747 regression and performance test framework for NetBSD that offers
2748 reproducible benchmarking results with detailed history and logs across
2749 various hardware &amp; architectures.</p>
2750
2751 <p>To achieve this performance testing framework, I am using the
2752 <a href="https://www.phoronix-test-suite.com/">Phoronix Test Suite (PTS)</a>
2753 which is an open-source, cross-platform automated testing/benchmarking
2754 software for Linux, Windows and BSD environments. It allows the
2755 creation of new tests using simple XML files and shell scripts and
2756 integrates with revision control systems for per-commit regression
2757 testing.</p>
2758
2759 <h2>About PTS</h2>
2760
2761 <h3>PTS core</h3>
2762
2763 <p>PTS core is the engine of the Phoronix Test Suite and handles the following jobs:</p>
2764
2765 <ul>
2766 <li>Regularly updating the test profiles, test suites, and repository index.</li>
2767 <li>Downloading, compilation, installation and evaluation of test packages.</li>
2768 <li>Test result management and uploading results and user-defined
2769 test-profiles/suites to OpenBenchmarking.org</li>
2770 </ul>
2771
2772
2773 <h3>Test-profiles/Suites &amp; OpenBenchmarking</h3>
2774
2775 <p>Test-profiles are light-weight XMLs and shell scripts that allow easy
2776 installation of the benchmarking packages and their evaluation.
2777 Test-profiles generally contains the following files:</p>
2778
2779 <ul>
2780 <li><code>downloads.xml</code>: Stores the links of the benchmarking packages,
2781 required additional packages, patches to be applied, etc. with their
2782 hash sums.</li>
2783 <li><code>install.sh</code>: Actual compilation, installation, and test
2784 evaluation shell script. Also handles the task of applying patches.</li>
2785 <li><code>results-definition.xml</code>: Meta-data to define the information for
2786 test result data (e.g. result data units, LIB or HIB, etc.)</li>
2787 <li><code>test-definition.xml</code>: Meta-data to specify test-profile details,
2788 such as compatible OS, external dependencies, test arguments, etc.</li>
2789 </ul>
2790
2791
2792 <p>A simple test-profile
2793 <a href="https://openbenchmarking.org/innhold/91db3ffff901d12dabd732bc568a44d02e5c6387">C-Ray-1.2.0</a>
2794 can be seen to get an idea of the XMLs and shell scripts.</p>
2795
2796 <p>Test-suites are bundles of related test-profiles or more suites,
2797 focusing on a subsystem or certain category of tests e.g. Disk Test
2798 Suite, Kernel, CPU suite, etc.</p>
2799
2800 <p><a href="https://openbenchmarking.org/">OpenBenchmarking.org</a> serves as a
2801 repository for storing test profiles, test suites, hence allowing
2802 new/updated tests to be seamlessly obtained via PTS.
2803 OpenBenchmarking.org also provides a platform to store the test result
2804 data openly and do a comparison between any test results stored in the
2805 OpenBenchmarking.org cloud.</p>
2806
2807 <h2>Usage</h2>
2808
2809 <h3>Test installation</h3>
2810
2811 <p>The command:</p>
2812
2813 <p><code>$ phoronix-test-suite install test-profile-name</code></p>
2814
2815 <p>Fetches the sources of the tests related to the the test-profile in
2816 <code>~/.phoronix-test-suite/installed-tests</code>, applies patches and
2817 carries out compilation of test sources for generating the executables
2818 to run the tests.</p>
2819
2820 <h3>Test execution</h3>
2821
2822 <p>The command:</p>
2823
2824 <p><code>$ phoronix-test-suite run test-profile-name</code></p>
2825
2826 <p>Performs installation of the test (similar to <code>$ phoronix-test-suite
2827 install test-profile-name</code>) followed by exectution the binary from
2828 the compiled sources of the test in
2829 <code>~/.phoronix-test-suite/installed-tests</code> and finally reports the
2830 tests results/outcome to the user and provides an option to upload
2831 results to OpenBenchmarking.org.</p>
2832
2833 <h2>Progress in the first phase of GSoC</h2>
2834
2835 <h3>pkgsrc-wip</h3>
2836
2837 <p>The first task performed by me was upgrading the Phoronix Test Suite
2838 from version 8.8 to the latest stable version 9.6.1 in <code>pkgsrc-wip</code>
2839 and is available as
2840 <a href="https://pkgsrc.se/wip/phoronix-test-suite">wip/phoronix-test-suite</a>.
2841 You can have a look at the
2842 <a href="https://github.com/phoronix-test-suite/phoronix-test-suite/blob/master/ChangeLog">PTS Changelog</a>
2843 to know about the improvements between these two versions.</p>
2844
2845 <h4>Major Commits:</h4>
2846
2847 <ul>
2848 <li><a href="https://github.com/NetBSD/pkgsrc-wip/commit/0073e18af14a97e33542a15d5a2940ed0b353897">wip/phoronix-test-suite: update phoronix-test-suite to 9.6.1</a></li>
2849 <li><a href="https://github.com/NetBSD/pkgsrc-wip/commit/959a9a0821fb155d11a2a68d2271233135375df1">Added required PHP dependencies &amp; removed TODO file</a></li>
2850 </ul>
2851
2852
2853 <p>Currently, the PTS upgrade to 9.6.1 is subject to more modifications
2854 and fixes before it gets finally merged to the <code>pkgsrc</code> upstream.
2855 To test the Phoronix Test Suite 9.6.1 on NetBSD till then, you can
2856 setup <code>pkgsrc-wip</code> on your system via:</p>
2857
2858 <pre>
2859 $ cd /usr/pkgsrc
2860 $ git clone git://wip.pkgsrc.org/pkgsrc-wip.git wip
2861 </pre>
2862
2863 <p>To learn more about pkgsrc-wip please see
2864 <a href="https://pkgsrc.org/wip/">The pkgsrc-wip project homepage</a>.</p>
2865
2866 <p>After setting up <code>pkgsrc-wip</code>, use the following command for
2867 installation of PTS 9.6.1:</p>
2868
2869 <pre>
2870 $ cd /usr/pkgsrc/wip/phoronix-test-suite
2871 $ make install
2872 </pre>
2873
2874 <p>If any new build/installation errors are encountered, please document
2875 them in wip/phoronix-test-suite/TODO file and/or contact me.</p>
2876
2877 <h3>Testing &amp; Debugging</h3>
2878
2879 <p>As we now know, having a look over OpenBenchmarking.org&rsquo;s available
2880 test-profiles section or using
2881 <code>$ phoronix-test-suite list-available-tests</code>,
2882 there are 309 test-profiles available on PTS for Linux, and only 166 of
2883 309 tests have been ported to NetBSD (can be differentiated by a
2884 thunder symbol on the test profile on the website). These 166
2885 test-profiles can be fetch, build and executed on NetBSD using just a
2886 single command <code>$ phoronix-test-suite run test-profile-name</code>. I am
2887 ignoring the graphics ones in both Linux &amp; NetBSD as GPU benchmarking
2888 wasn&rsquo;t required in the project.</p>
2889
2890 <p>Many of the test profiles available on NetBSD have installation, build,
2891 or runtime errors i.e. they don&rsquo;t work out of the box using the command
2892 <code>$ phoronix-test-suite run test-profile-name</code>. I ran 90 of these
2893 test profiles on a NetBSD-current x86_64 QEMU VM (took a lot of time
2894 due to the heavy tests) and have reported the status in the sheet:
2895 <a href="https://drive.google.com/file/d/1gW76JI7W-Jpeczns49k1bBIVr8bb6QuX/view?usp=sharing">NetBSD GSoC: Test Porting Progress Report</a></p>
2896
2897 <p>You can have a look at how a PTS test-profile under action looks like!</p>
2898
2899 <h4>Aircrack-NG test-profile demonstration</h4>
2900
2901 <p>Aircrack-ng is a tool for assessing WiFi/WLAN network security.</p>
2902
2903 <p>The PTS test-profile is available at:
2904 <a href="https://openbenchmarking.org/test/pts/aircrack-ng">https://openbenchmarking.org/test/pts/aircrack-ng</a></p>
2905
2906 <p><img src="//www.NetBSD.org/~leot/blog-posts/imgs/pts_aircrack_ng_test.png" alt="Screenshot of aircrack-ng PTS test-profile results" width="800" /></p>
2907
2908 <p>For further information, complete results can be seen at
2909 <a href="https://openbenchmarking.org/result/2007116-NI-AIRCRACKN51">https://openbenchmarking.org/result/2007116-NI-AIRCRACKN51</a></p>
2910
2911 <h4>AOBench test-profile demonstration</h4>
2912
2913 <p>AOBench is a lightweight ambient occlusion renderer, written in C.</p>
2914
2915 <p>The PTS test-profile is available at:
2916 <a href="https://openbenchmarking.org/test/pts/aircrack-ng">https://openbenchmarking.org/test/pts/aircrack-ng</a></p>
2917
2918 <p><img src="//www.NetBSD.org/~leot/blog-posts/imgs/pts_aobench_test.png" alt="Screenshot of aobench PTS test-profile results" width="800" /></p>
2919
2920 <p>For further information, complete results can be seen at:
2921 <a href="https://openbenchmarking.org/result/2007148-NI-AOBENCHTE94">https://openbenchmarking.org/result/2007148-NI-AOBENCHTE94</a></p>
2922
2923 <h4>Debugging and fixing non-working test-profiles</h4>
2924
2925 <p>After testing these test-profiles, I debugged the following build
2926 errors in the following test-profiles:</p>
2927
2928 <ul>
2929 <li>pts/t-test1-1.0.1: <code>memalign()</code> not available on NetBSD</li>
2930 <li>pts/coremark-1.0.0: calling bmake instead of gmake</li>
2931 <li>pts/apache-siege-1.0.4: Missing <code>signal.h</code> header</li>
2932 <li>pts/mbw-1.0.0: <code>mempcpy()</code> not available on NetBSD</li>
2933 </ul>
2934
2935
2936 <p>Fixes to the above bugs can be found in the sheet or in the GitHub
2937 repositories shared in the next paragraph.</p>
2938
2939 <p>The modified test-profiles have been pushed to
2940 <a href="https://github.com/apurvanandan1997/pts-test-profiles-dev">pts-test-profiles-dev</a>
2941 and the fix patches to
2942 <a href="https://github.com/apurvanandan1997/pts-test-profiles-patches">pts-test-profiles-patches</a>.
2943 These patches are automatically downloaded by the debugged
2944 test-profiles and automatically applied before building of tests. The
2945 steps to install the debugged test-profiles have been added in the
2946 <code>README.md</code> of
2947 <a href="https://github.com/apurvanandan1997/pts-test-profiles-dev">pts-test-profiles-dev</a>.</p>
2948
2949 <p>These patches have been added in the <code>downloads.xml</code> of the
2950 modified test-profiles, and hence they get fetched during the test
2951 installation. The <code>install.sh</code> script in these modified
2952 test-profiles applies them on the benchmarking packages if the
2953 operating system is detected as NetBSD, thereby removing the build
2954 errors.</p>
2955
2956 <h4>coremark test-profile demonstration</h4>
2957
2958 <p>You can have a look at the patched coremark-1.0.0 test-profile under
2959 execution:</p>
2960
2961 <p>The patched PTS test-profile is available at:
2962 <a href="https://github.com/apurvanandan1997/pts-test-profiles-dev/tree/master/coremark-1.0.0">https://github.com/apurvanandan1997/pts-test-profiles-dev/tree/master/coremark-1.0.0</a></p>
2963
2964 <p>This is a test of EEMBC CoreMark processor benchmark.</p>
2965
2966 <p><img src="//www.NetBSD.org/~leot/blog-posts/imgs/pts_coremark_test.png" alt="Screenshot of patched coremark PTS test-profile results" width="800" /></p>
2967
2968 <p>For further information, complete results can be seen at:
2969 <a href="https://openbenchmarking.org/result/2007148-NI-LOCALCORE64">https://openbenchmarking.org/result/2007148-NI-LOCALCORE64</a></p>
2970
2971 <h4>Porting more test-profiles to NetBSD</h4>
2972
2973 <p>Attempts were made to port new test-profiles from Linux to NetBSD, but
2974 the major incompatibility issue was missing external dependencies in
2975 NetBSD. Hence, this may reduce the number of test-profiles we can
2976 actually port, but more sincere efforts will be made in this direction
2977 in the next phase.</p>
2978
2979 <h2>Future Plans</h2>
2980
2981 <p>My next steps would involve porting the non-available tests to NetBSD
2982 i.e. the non-graphics ones available on Linux but unavailable on
2983 NetBSD, and fix the remaining test-profiles for NetBSD.</p>
2984
2985 <p>After gaining an availability of a decent number of test-profiles on
2986 NetBSD, I will use Phoromatic, a remote tests management system for the
2987 PTS (allows the automatic scheduling of tests, remote installation of
2988 new tests, and the management of multiple test systems) to host the
2989 live results of the automated benchmarking framework on
2990 benchmark.NetBSD.org, thereby delivering a functional performance and
2991 regression testing framework.</p>
2992 </content>
2993 </entry>
2994 <entry>
2995 <id>https://blog.netbsd.org/tnf/entry/gsoc_reports_enhancing_syzkaller_support</id>
2996 <title type="html">GSoC Reports: Enhancing Syzkaller support for NetBSD, Part 1</title>
2997 <author><name>Kamil Rytarowski</name></author>
2998 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_reports_enhancing_syzkaller_support"/>
2999 <published>2020-07-13T22:18:21+00:00</published>
3000 <updated>2020-07-13T22:18:21+00:00</updated>
3001 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
3002 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
3003 <summary type="html"><i>This report was prepared by Ayushi Sharma as a part of Google Summer of Code 2020</i>
3004
3005 <p>I have been working on the project - <a href="https://wiki.netbsd.org/projects/project/syzkaller/">Enhance the Syzkaller support for NetBSD</a>, as a part of GSoc’20. Past two months have given me quite an enriching experience, pushing me to comprehend more knowledge on fuzzers. This post would give a peek into the work which has been done so far.</p></summary>
3006 <content type="html"><i>This report was prepared by Ayushi Sharma as a part of Google Summer of Code 2020</i>
3007
3008 <p>I have been working on the project - <a href="https://wiki.netbsd.org/projects/project/syzkaller/">Enhance the Syzkaller support for NetBSD</a>, as a part of GSoc’20. Past two months have given me quite an enriching experience, pushing me to comprehend more knowledge on fuzzers. This post would give a peek into the work which has been done so far.</p>
3009
3010 <h2>Syzkaller</h2>
3011 <p>Syzkaller is a coverage guided fuzzer developed by Google, to fuzz the system calls mainly keeping linux in mind. However, the support has been extended to fuzz the system calls of other Operating Systems as well for eg. Akaros, FreeBSD, NetBSD, OpenBSD, Windows etc.</p>
3012
3013 <p> An automated system Syzbot continuously runs the syzkaller fuzzer on NetBSD kernel and reports the crashes <p>
3014
3015 <img src="//netbsd.org/~kamil/gsoc_2020/syzbot.png" alt="Syzbot" height="333">
3016
3017
3018 <h2>Increasing syscall support</h2>
3019 <p>Initially, the syscall support for <a href="https://gist.github.com/ais2397/1bed83535b7b65a7d488deb310a0dd78">Linux</a> as well as <a href="https://gist.github.com/ais2397/b8886661c698be83fcc757858a2184b4">FreeBSD</a> was analysed by an automated script. Also <a href="https://gist.github.com/ais2397/b6a737b9ad0836301194478549e733c8">coverage of NetBSD syscalls</a> was looked over. This helped us to easily port a few syscalls descriptions for NetBSD. The necessary tweaks were made according to the documentation which describes rules for writing syscall descriptions.</p>
3020
3021 <p>Major groups of syscalls which have been added:
3022 <ul>
3023 <li>statfs</li>
3024 <li>__getlogin
3025 <li>getsid</li>
3026 <li>mknod</li>
3027 <li>utimes</li>
3028 <li>wait4</li>
3029 <li>seek</li>
3030 <li>setitimer</li>
3031 <li>setpriority</li>
3032 <li>getrusage</li>
3033 <li>clock_settime</li>
3034 <li>nanosleep</li>
3035 <li>getdents </li>
3036 <li>acct </li>
3037 <li>dup</li>
3038
3039 </ul>
3040 </p>
3041
3042 <h2>Bugs Found</h2>
3043
3044 There were a few bugs reported as a result of adding the descriptions for syscalls of the mentioned syscall families. Few of them are yet to be fixed.
3045 <ul>
3046 <li><a href="https://syzkaller.appspot.com/bug?id=e70e6b077e9dac9807c86fd0aa418aa837180598"> compat_20_getfstat</a></li>
3047 <li><a href="https://syzkaller.appspot.com/bug?id=ed011128934a1410452457bcebfe634fcf84b9a2">clock_settime50</a></li>
3048 <li><a href="https://syzkaller.appspot.com/bug?id=6d4983b443f3b9ec458313601e468b9cd4bf781e">ioctl</a></li>
3049 </ul>
3050
3051 <h2>Stats</h2>
3052 <p>Syscall coverage percent for NetBSD has now increased from nearly 30 to 44.96. Addition of compat syscalls resulted in getting a few new bugs.</p>
3053 <p> Percentage of syscalls covered in few of the other Operating Systems:
3054 <ul>
3055 <li>Linux: 82</li>
3056 <li>FreeBSD: 37</li>
3057 <li>OpenBSD: 61</li>
3058 </ul>
3059 </p>
3060 <h2>Conclusion</h2>
3061 <p>In the next phase I would be working on generating the syscall descriptions using automation and adding ioctl device drivers with it’s help.</p>
3062
3063 <p>Atlast, I would like to thank my mentors Cryo, Siddharth and Santhosh for their constant support and guidance.I am also thankful to NetBSD community for being kind to give me this opportunity of having an amazing summer this year.</p></content>
3064 </entry>
3065 <entry>
3066 <id>https://blog.netbsd.org/tnf/entry/gsoc_reports_extending_the_functionality</id>
3067 <title type="html">GSoC Reports: Extending the functionality of NetPGP, Part 1</title>
3068 <author><name>Kamil Rytarowski</name></author>
3069 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_reports_extending_the_functionality"/>
3070 <published>2020-07-13T22:05:18+00:00</published>
3071 <updated>2020-07-13T22:20:52+00:00</updated>
3072 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
3073 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
3074 <summary type="html"><i>This report was prepared by Jason High as a part of Google Summer of Code 2020</i>
3075 <p>NetPGP is a library and suite of tools implementing OpenPGP under a BSD license. As part of Google Summer of Code 2020, we are working to extend its functionality and work towards greater parity with similar tools. During the first phase, we have made the following contributions</p>
3076 <ol>
3077 <li>Added the Blowfish block cipher</li>
3078 <li>ECDSA key creation</li>
3079 <li>ECDSA signature and verification</li>
3080 <li>Symmetric file encryption/decryption</li>
3081 <li>S2K Iterated+Salt for symmetric encryption</li>
3082 </ol></summary>
3083 <content type="html"><i>This report was prepared by Jason High as a part of Google Summer of Code 2020</i>
3084 <p>NetPGP is a library and suite of tools implementing OpenPGP under a BSD license. As part of Google Summer of Code 2020, we are working to extend its functionality and work towards greater parity with similar tools. During the first phase, we have made the following contributions</p>
3085 <ol>
3086 <li>Added the Blowfish block cipher</li>
3087 <li>ECDSA key creation</li>
3088 <li>ECDSA signature and verification</li>
3089 <li>Symmetric file encryption/decryption</li>
3090 <li>S2K Iterated+Salt for symmetric encryption</li>
3091 </ol>
3092 <p>ECDSA key generation is done using the '--ecdsa' flag with netpgpkeys or the 'ecdsa' property if using libnetpgp</p>
3093 <pre><code>[jhigh@gsoc2020nb gsoc]$ netpgpkeys --generate-key --ecdsa --homedir=/tmp
3094 signature secp521r1/ECDSA a0cdb04e3e8c5e34 2020-06-25
3095 fingerprint d9e0 2ae5 1d2f a9ae eb96 ebd4 a0cd b04e 3e8c 5e34
3096 uid jhigh@localhost
3097 Enter passphrase for a0cdb04e3e8c5e34:
3098 Repeat passphrase for a0cdb04e3e8c5e34:
3099 generated keys in directory /tmp/a0cdb04e3e8c5e34
3100 [jhigh@gsoc2020nb gsoc]$
3101
3102 [jhigh@gsoc2020nb gsoc]$ ls -l /tmp/a0cdb04e3e8c5e34
3103 total 16
3104 -rw------- 1 jhigh wheel 331 Jun 25 16:03 pubring.gpg
3105 -rw------- 1 jhigh wheel 440 Jun 25 16:03 secring.gpg
3106 [jhigh@gsoc2020nb gsoc]$
3107 </code></pre>
3108 <p>Signing with ECDSA does not require any changes</p>
3109 <pre><code>[jhigh@gsoc2020nb gsoc]$ netpgp --sign --homedir=/tmp/a0cdb04e3e8c5e34 --detach --armor testfile.txt
3110 signature secp521r1/ECDSA a0cdb04e3e8c5e34 2020-06-25
3111 fingerprint d9e0 2ae5 1d2f a9ae eb96 ebd4 a0cd b04e 3e8c 5e34
3112 uid jhigh@localhost
3113 netpgp passphrase:
3114 [jhigh@gsoc2020nb gsoc]$
3115
3116 [jhigh@gsoc2020nb gsoc]$ cat testfile.txt.asc
3117 -----BEGIN PGP MESSAGE-----
3118
3119 wqcEABMCABYFAl71EYwFAwAAAAAJEKDNsE4+jF40AAAVPgIJASyzuZgyS13FHHF/9qk6E3pYra2H
3120 tDdkqxYzNIqKnWHaB+a4J+/R7FkZItbC/EyXH5YA68AC1dJ7tRN/tJNIWfYjAgUb75SvM2mLHk13
3121 qmBo48S0Ai8C82G4nT7/16VF2OOUn7F/3XICghoQOyS1nxJilj8u2uphLOoy9VayL1ErORIZVw==
3122 =p30e
3123 -----END PGP MESSAGE-----
3124 [jhigh@gsoc2020nb gsoc]$
3125 </code></pre>
3126 <p>Verification remains the same, as well.</p>
3127 <pre><code>[jhigh@gsoc2020nb gsoc]$ netpgp --homedir=/tmp/a0cdb04e3e8c5e34 --verify testfile.txt.asc
3128 netpgp: assuming signed data in "testfile.txt"
3129 Good signature for testfile.txt.asc made Thu Jun 25 16:05:16 2020
3130 using ECDSA key a0cdb04e3e8c5e34
3131 signature secp521r1/ECDSA a0cdb04e3e8c5e34 2020-06-25
3132 fingerprint d9e0 2ae5 1d2f a9ae eb96 ebd4 a0cd b04e 3e8c 5e34
3133 uid jhigh@localhost
3134 [jhigh@gsoc2020nb gsoc]$
3135 </code></pre>
3136 <p>Symmetric encryption is now possible using the '--symmetric' flag with netpgp or the 'symmetric' property in libnetpgp</p>
3137 <pre><code>[jhigh@gsoc2020nb gsoc]$ netpgp --encrypt --symmetric --armor testfile.txt
3138 Enter passphrase:
3139 Repeat passphrase:
3140 [jhigh@gsoc2020nb gsoc]$
3141
3142 [jhigh@gsoc2020nb gsoc]$ cat testfile.txt.asc
3143 -----BEGIN PGP MESSAGE-----
3144
3145 wwwEAwEIc39k1V6xVi3SPwEl2ww75Ufjhw7UA0gO/niahHWK50DFHSD1lB10nUyCTgRLe6iS9QZl
3146 av5Nji9BuQFcrqo03I1jG/L9s/4hww==
3147 =x41O
3148 -----END PGP MESSAGE-----
3149 [jhigh@gsoc2020nb gsoc]$
3150 </code></pre>
3151 <p>Decryption of symmetric packets requires no changes</p>
3152 <pre><code>[jhigh@gsoc2020nb gsoc]$ netpgp --decrypt testfile.txt.asc
3153 netpgp passphrase:
3154 [jhigh@gsoc2020nb gsoc]$
3155 </code></pre>
3156 <p>We added two new flags to support s2k mode 3: '--s2k-mode' and '--s2k-count'. See RFC4880 for details.</p>
3157 <pre><code>[jhigh@gsoc2020nb gsoc]$ netpgp --encrypt --symmetric --s2k-mode=3 --s2k-count=96 testfile.txt
3158 Enter passphrase:
3159 Repeat passphrase:
3160 [jhigh@gsoc2020nb gsoc]$
3161
3162
3163 [jhigh@gsoc2020nb gsoc]$ gpg -d testfile.txt.gpg
3164 gpg: CAST5 encrypted data
3165 gpg: encrypted with 1 passphrase
3166 this
3167 is
3168 a
3169 test
3170 [jhigh@gsoc2020nb gsoc]$
3171 </code></pre></content>
3172 </entry>
3173 <entry>
3174 <id>https://blog.netbsd.org/tnf/entry/gsoc_reports_curses_library_automated</id>
3175 <title type="html">GSoC Reports: Curses Library Automated Testing, Part 1</title>
3176 <author><name>Kamil Rytarowski</name></author>
3177 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_reports_curses_library_automated"/>
3178 <published>2020-07-13T21:40:13+00:00</published>
3179 <updated>2020-07-13T22:21:34+00:00</updated>
3180 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
3181 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
3182 <summary type="html"><i>This report was prepared by Naman Jain as a part of Google Summer of Code 2020</i>
3183 <h2><a id="user-content-introduction" class="anchor" aria-hidden="true" href="#introduction"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Introduction</h2>
3184 <p>My GSoC project under NetBSD involves the development of test framework of curses library. Automated Test Framework (ATF) was introduced in 2007 but ATF cannot be used directly for curses testing for several reasons most important of them being curses has functions which do timed reads/writes which is hard to do with just piping characters to test applications. Also, stdin is not a tty device and behaves differently and may affect the results. A lot of work regarding this has been done and we have a separate test framework in place for testing curses.</p>
3185 <p>The aim of project is to build a robust test suite for the library and complete the SUSv2 specification. This includes writing tests for the remaining functions and enhancing the existing ones. Meanwhile, the support for complex character function has to be completed along with fixing some bugs, adding features and improving the test framework.</p></summary>
3186 <content type="html"><i>This report was prepared by Naman Jain as a part of Google Summer of Code 2020</i>
3187 <h2><a id="user-content-introduction" class="anchor" aria-hidden="true" href="#introduction"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Introduction</h2>
3188 <p>My GSoC project under NetBSD involves the development of test framework of curses library. Automated Test Framework (ATF) was introduced in 2007 but ATF cannot be used directly for curses testing for several reasons most important of them being curses has functions which do timed reads/writes which is hard to do with just piping characters to test applications. Also, stdin is not a tty device and behaves differently and may affect the results. A lot of work regarding this has been done and we have a separate test framework in place for testing curses.</p>
3189 <p>The aim of project is to build a robust test suite for the library and complete the SUSv2 specification. This includes writing tests for the remaining functions and enhancing the existing ones. Meanwhile, the support for complex character function has to be completed along with fixing some bugs, adding features and improving the test framework.</p>
3190 <h2><a id="user-content-why-did-i-chose-this-project" class="anchor" aria-hidden="true" href="#why-did-i-chose-this-project"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Why did I chose this project?</h2>
3191 <p>I am a final year undergraduate at Indian Institute of Technology, Kanpur. I have my majors in Computer Science and Engineering, and I am specifically interested in algorithms and computer systems. I had worked on building and testing a library on Distributed Tracing at an internship and understand the usefulness of having a test suite in place. Libcurses being very special in itself for the testing purpose interested me. Knowing some of the concepts of compiler design made my interest a bit more profound.</p>
3192 <h2><a id="user-content-test-framwork" class="anchor" aria-hidden="true" href="#test-framwork"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Test Framwork</h2>
3193 <p>The testframework consists of 2 programs, director and slave. The framework provides its own simple language for writing tests. The slave is a curses application capable of running any curses function, while the director acts as a coordinator and interprets the test file and drives the slave program. The director can also capture slave's output which can be used for comparison with desired output.</p>
3194 <p><a target="_blank" rel="noopener noreferrer" href="//netbsd.org/~kamil/gsoc_2020/director-slave.jpeg"><img src="//netbsd.org/~kamil/gsoc_2020/director-slave.jpeg" alt="slave-director model" title="Slave-Director model" style="max-width:100%;"></a></p>
3195 <p>The director forks a process operating in pty and executes a slave program on that fork. The master side of pty is used for getting the data stream that the curses function call produces which can be futher used to check the correctness of behaviour. Director and slave communicate via pipes; command pipe and slave pipe. The command pipe carries the function name and arguments, while slave pipe carries return codes and values from function calls.</p>
3196 <p>Let's walk through a sample test to understand how this works. Consider a sample program:</p>
3197 <pre><code>include start
3198 call win newwin 2 5 2 5
3199 check win NON_NULL
3200 call OK waddstr $win "Hello World!"
3201 call OK wrefresh $win
3202 compare waddstr_refresh.chk
3203 </code></pre>
3204 <p>This is a basic program which initialises the screen, creates new window, checks if the window creation was successful, adds as string "Hello World!" on the window, refreshes the window, and compares it with desired output stored in check file. The details of the language can be accessed at <a href="https://github.com/NetBSD/src/blob/trunk/tests/lib/libcurses/testframe.txt">libcurses testframe</a>.</p>
3205 <p>The test file is interpreted by the language parser and the correponding actions are taken. Let's look how line #2 is processed. This command creates a window using <code>newwin()</code>. The line is ultimately parsed as <a href="https://github.com/NetBSD/src/blob/1d30657e76c9400c15eb4e4cfcdff2fea6c65a5a/tests/lib/libcurses/director/testlang_parse.y#L237"><code>call: CALL result fn_name args eol</code></a> grammar rule and executes the function <a href="https://github.com/NetBSD/src/blob/1d30657e76c9400c15eb4e4cfcdff2fea6c65a5a/tests/lib/libcurses/director/testlang_parse.y#L1035"><code>do_funtion_call()</code></a>). Now, this function <a href="https://github.com/NetBSD/src/blob/1d30657e76c9400c15eb4e4cfcdff2fea6c65a5a/tests/lib/libcurses/director/testlang_parse.y#L1048">sends</a> function name and arguments using command pipe to the slave. The slave, who is waiting to get command from the director, reads from the pipe and <a href="https://github.com/NetBSD/src/blob/1d30657e76c9400c15eb4e4cfcdff2fea6c65a5a/tests/lib/libcurses/slave/slave.c#L144">executes</a> the command. This executes the correponding curses function from the <a href="https://github.com/NetBSD/src/blob/1d30657e76c9400c15eb4e4cfcdff2fea6c65a5a/tests/lib/libcurses/slave/command_table.h#L40">command table</a> and the pointer to new window is <a href="https://github.com/NetBSD/src/blob/1d30657e76c9400c15eb4e4cfcdff2fea6c65a5a/tests/lib/libcurses/slave/curses_commands.c#L3582">returned</a> via the slave pipe (<a href="https://github.com/NetBSD/src/blob/1d30657e76c9400c15eb4e4cfcdff2fea6c65a5a/tests/lib/libcurses/slave/commands.c#L167">here</a>) after passing wrappers of functions. The director <a href="https://github.com/NetBSD/src/blob/1d30657e76c9400c15eb4e4cfcdff2fea6c65a5a/tests/lib/libcurses/director/testlang_parse.y#L1140">recieves</a> them, and returned value is assigned to a variable(<code>win</code> in line#2) or compared (<code>OK</code> in line#4). This is the typical life cycle of a certain function call made in tests.</p>
3206 <p>Along with these, the test framework provides capability to <code>include</code> other test (line#1), <code>check</code> the variable content (line#3), <code>compare</code> the data stream due to function call in pty with desired stream (line#6). Tester can also provide inputs to functions via <code>input</code> directive, perform delay via <code>delay</code> directive, assign values to variables via <code>assign</code> directive, and create a wide or complex charater via <code>wchar</code> and <code>cchar</code> directives respectively. The framework supports 3 kind of strings; null terminated string, byte string, and string of type chtype, based on the quotes enclosing it.</p>
3207 <h2><a id="user-content-progress-till-the-first-evaluation" class="anchor" aria-hidden="true" href="#progress-till-the-first-evaluation"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Progress till the first evaluation</h2>
3208 <h3><a id="user-content-improvements-in-the-framework" class="anchor" aria-hidden="true" href="#improvements-in-the-framework"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Improvements in the framework:</h3>
3209 <ol>
3210 <li>Automated the checkfile generation that has to be done manually earlier.</li>
3211 <li>Completed the support for complex chacter tests in director and slave.</li>
3212 <li>Added features like variable-variable comparison.</li>
3213 <li>Fixed non-critical bugs in the framework.</li>
3214 <li>Refactored the code.</li>
3215 </ol>
3216 <h3><a id="user-content-testing-and-bug-reports" class="anchor" aria-hidden="true" href="#testing-and-bug-reports"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Testing and bug reports</h3>
3217 <ol>
3218 <li>Wrote tests for wide character routines.</li>
3219 <li>Reported bugs (and possible fixes if I know):
3220 <ul>
3221 <li><a href="https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55433" rel="nofollow">lib/55433</a> Bug in special character handling of ins_wstr() of libcurses</li>
3222 <li><a href="https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55434" rel="nofollow">lib/55434</a> Bug in hline() in libcurses [fixed]</li>
3223 <li><a href="https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55443" rel="nofollow">lib/55443</a> setcchar() incorrectly sets the number of elements in cchar [fixed]</li>
3224 </ul>
3225 </li>
3226 </ol>
3227 <h2><a id="user-content-project-proposal-and-references" class="anchor" aria-hidden="true" href="#project-proposal-and-references"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Project Proposal and References:</h2>
3228 <ul>
3229 <li>Proposal: <a href="https://github.com/NamanJain8/curses/blob/master/reports/proposal.pdf">https://github.com/NamanJain8/curses/blob/master/reports/proposal.pdf</a></li>
3230 <li>Project Repo: <a href="https://github.com/NamanJain8/curses">https://github.com/NamanJain8/curses</a></li>
3231 <li>Test Language Details: <a href="https://github.com/NetBSD/src/blob/trunk/tests/lib/libcurses/testframe.txt">https://github.com/NetBSD/src/blob/trunk/tests/lib/libcurses/testframe.txt</a></li>
3232 <li>Wonderful report by Brett Lymn: <a href="https://github.com/NamanJain8/curses/blob/master/reports/curses-testframe.pdf">https://github.com/NamanJain8/curses/blob/master/reports/curses-testframe.pdf</a></li>
3233 </ul></content>
3234 </entry>
3235 <entry>
3236 <id>https://blog.netbsd.org/tnf/entry/gsoc_reports_fuzzing_the_netbsd</id>
3237 <title type="html">GSoC Reports: Fuzzing the NetBSD Network Stack in a Rumpkernel Environment, Part 1</title>
3238 <author><name>Kamil Rytarowski</name></author>
3239 <link rel="alternate" type="text/html" href="https://blog.netbsd.org/tnf/entry/gsoc_reports_fuzzing_the_netbsd"/>
3240 <published>2020-07-13T14:58:58+00:00</published>
3241 <updated>2020-07-13T22:22:24+00:00</updated>
3242 <category term="/The NetBSD Foundation" label="The NetBSD Foundation" />
3243 <category term="gsoc" scheme="http://roller.apache.org/ns/tags/" />
3244 <summary type="html"><i>This report was prepared by Nisarg Joshi as a part of Google Summer of Code 2020</i>
3245 <p><strong>Introduction:</strong></p>
3246 <p>The objective of this project is to fuzz the various protocols and layers of the network stack of NetBSD using rumpkernel. This project is being carried out as a part of GSoC 2020. This blog post is regarding the project, the concepts and tools involved, the objectives and the current progress and next steps.</p>
3247 <p><strong>Fuzzing:</strong></p>
3248 <p>Fuzzing or fuzz testing is an automated software testing technique in which a program is tested by passing unusual, unexpected or semi-random input generated data to the input of the program and repeatedly doing so, trying to crash the program and detect potential bugs or undealt corner cases.</p>
3249 <p>There are several tools available today that enable this which are known as fuzzers. An effective fuzzer generates semi-valid inputs that are "valid enough" in that they are not directly rejected by the parser, but do create unexpected behaviors deeper in the program and are "invalid enough" to expose corner cases that have not been properly dealt with.&nbsp;</p>
3250 <p>Fuzzers can be of various types like dumb vs smart, generation-based vs mutation-based and so on. A dumb fuzzer generates random input without looking at the input format or model but it can follow some sophisticated algorithms like in AFL, though considered a dumb fuzzer as it just flips bits and replaces bytes, still uses a genetic algorithm to create new test cases, where as a smart fuzzer will follow an input model to generate semi-random data that can penetrate well in the code and trigger more edge cases. Mutation and generation fuzzers handle test case generation differently. Mutation fuzzers mutate a supplied seed input object, while generation fuzzers generate new test cases from a supplied model.</p>
3251 <p>Some examples of popular fuzzers are: AFL(American Fuzzy Lop), Syzkaller, Honggfuzz.</p></summary>
3252 <content type="html"><i>This report was prepared by Nisarg Joshi as a part of Google Summer of Code 2020</i>
3253 <p><strong>Introduction:</strong></p>
3254 <p>The objective of this project is to fuzz the various protocols and layers of the network stack of NetBSD using rumpkernel. This project is being carried out as a part of GSoC 2020. This blog post is regarding the project, the concepts and tools involved, the objectives and the current progress and next steps.</p>
3255 <p><strong>Fuzzing:</strong></p>
3256 <p>Fuzzing or fuzz testing is an automated software testing technique in which a program is tested by passing unusual, unexpected or semi-random input generated data to the input of the program and repeatedly doing so, trying to crash the program and detect potential bugs or undealt corner cases.</p>
3257 <p>There are several tools available today that enable this which are known as fuzzers. An effective fuzzer generates semi-valid inputs that are "valid enough" in that they are not directly rejected by the parser, but do create unexpected behaviors deeper in the program and are "invalid enough" to expose corner cases that have not been properly dealt with.&nbsp;</p>
3258 <p>Fuzzers can be of various types like dumb vs smart, generation-based vs mutation-based and so on. A dumb fuzzer generates random input without looking at the input format or model but it can follow some sophisticated algorithms like in AFL, though considered a dumb fuzzer as it just flips bits and replaces bytes, still uses a genetic algorithm to create new test cases, where as a smart fuzzer will follow an input model to generate semi-random data that can penetrate well in the code and trigger more edge cases. Mutation and generation fuzzers handle test case generation differently. Mutation fuzzers mutate a supplied seed input object, while generation fuzzers generate new test cases from a supplied model.</p>
3259 <p>Some examples of popular fuzzers are: AFL(American Fuzzy Lop), Syzkaller, Honggfuzz.</p>
3260 <p><strong>RumpKernel</strong></p>
3261 <p>Kernels can have several different architectures like monolithic, microkernel, exokernel etc. An interesting architecture is the &ldquo;anykernel&rdquo; architecture, according to wikipedia, &ldquo;The "anykernel" concept refers to an architecture-agnostic approach to drivers where drivers can either be compiled into the monolithic kernel or be run as a userspace process, microkernel-style, without code changes.&rdquo; Rumpkernel is an implementation of this anykernel architecture. In case of the NetBSD rumpkernel, all the NetBSD subsystems like file system, network stack, drivers etc are compiled into standalone libraries that can be linked into any application process to utilize the functionalities of the kernel, like the file system or the drivers. This allows us to run and test various components of NetBSD kernel as a library linked to programs running in the user space.</p>
3262 <p>This idea of rumpkernel is really helpful in fuzzing the components of the kernel. We can fuzz separate subsystems and allow it to crash without having to manage the crash of a running Operating System. Also the fact that context switching has an overhead in case syscalls are made to the kernel, Rumpkernel running in the userspace can eliminate this and save time.(Also since the spectre-meltdown vulnerabilities, system calls have become more costly due to the security reasons)</p>
3263 <p><strong>HonggFuzz + Rumpkernel Network Stack:</strong></p>
3264 <p>In this project we will use the outlined Rumpkernel&rsquo;s network stack and a fuzzer called the honggfuzz. Honggfuzz is a security oriented, feedback-driven, evolutionary, easy-to-use fuzzer. It is maintained by google.(<a href="https://github.com/google/honggfuzz">https://github.com/google/honggfuzz</a>)</p>
3265 <p>The project is hosted on github at: <a href="https://github.com/NJnisarg/fuzznetrump/">https://github.com/NJnisarg/fuzznetrump/</a> .The Readme can help in setting it up. We first require NetBSD installed either on a physical machine or on a virtual machine like qemu. Then we will build the NetBSD distribution by grabbing the latest sources(<a href="https://github.com/NetBSD/src">https://github.com/NetBSD/src</a>). We will enable fuzzer coverage by using MKSANITIZER and MKLIBCSANITIZER flags and using the ASan(Address) and UBSan(Undefined Behavior) sanitizers. These sanitizers will help the fuzzer in catching bugs related to undefined behavior and address and memory leaks. After that we will grab one of the fuzzer programs(example: src/hfuzz_ip_output_fuzz.c) and chroot into the newly built distribution from the host NetBSD OS. Then we will compile it using hfuzz-clang by linking the required rumpkernel libraries (for example in our case: rump, rumpnet, rumpnet_netinet and so on). This is where we use the rumpkernel as libraries linked to our program. The program will access the network stack of the linked rumpkernel and the fuzzer will fuzz those components of the kernel. The compiled binary will be run with honggfuzz. Detailed steps are outlined in the Readme of the linked repository.</p>
3266 <p><strong>Our Approach for network stack fuzzing:</strong></p>
3267 <p>We have planned to fuzz various protocols at different layers of the TCP/IP stack. We have started with mostly widely used yet simple protocols like IP(v4), UDP etc. Along the progress of the project, we will be adding support for more L3(and above) protocols like ICMP, IP(v6), TCP as well as L2 protocols like Ethernet as a bit later phase.</p>
3268 <p>The network stack has 2 paths:&nbsp;</p>
3269 <ol>
3270 <li>Input/ingress path</li>
3271 <li>Output/egress path</li>
3272 </ol>
3273 <p>A packet is sent down the network stack via a socket from an application from the output path, whereas a packet is said to be received on a network interface into the network stack via the input path. Each network protocol has major input and output APIs for the packet processing. Example IP protocol has an ip_input() function to process an incoming packet and an ip_output() function to process an outgoing packet. We are planning to fuzz each protocol&rsquo;s output and input APIs by sending the packet via the output path and receiving the packet via input path respectively.&nbsp;</p>
3274 <p>In order to fuzz the output and input path, the network stack setup and configuration we have is as follows:</p>
3275 <ul>
3276 <li>We have a TUN device to which we can read and write a packet.</li>
3277 <li>We have a socket that is bound to the TUN device, which can send and receive packets</li>
3278 <li>In order to fuzz the input path, we &ldquo;write&rdquo; a packet to the TUN interface, which emulates a received packet on the network stack.</li>
3279 <li>In order to fuzz the output path, we send a packet via the socket to the TUN interface to fuzz the output path.</li>
3280 </ul>
3281 <p>For carrying out all the above setup, we have separated out the common function for creating and configuring the TUN device and socket into a file called &ldquo;net_config.c&rdquo;</p>
3282 <p>Also in order to reduce the rejection of packets carrying random data for trivial cases like checksum or header len, we have created functions that create/forge semi-random packets using the input data from honggfuzz. We manipulate certain fields in the packet to ensure that it does not get rejected trivially by the network stack and hence can reach and trigger deeper parts of the code. These functions for packet creations are located in the &ldquo;pkt_create.c&rdquo; file. For each protocol we fuzz, we add these functions to forge the headers and the packet. Currently we have support from UDP and IP(v4).</p>
3283 <p>With these building blocks we have written programs like hfuzz_ip_output_fuzz.c, hfuzz_ip_input_fuzz.c etc, which setup the TUN device and socket using net_config.c and after taking the random data from honggfuzz, use it to forge a packet and send it down or up the stack. We compile these programs using hfuzz-clang as mentioned above and run it under honggfuzz to fuzz the network stack&rsquo;s particular APIs.</p>
3284 <p><strong>Current Progress:</strong></p>
3285 <p>Following things were worked upon in the first phase:</p>
3286 <ul>
3287 <li>Getting honggfuzz functional for NetBSD(thanks to Kamil for those patches)</li>
3288 <li>Coming up with the strategy for network configuration and packet creation. Writing utilities for the same.</li>
3289 <li>Adding fuzzing code for protocols like IP(v4) and UDP.</li>
3290 <li>Carrying out fuzzing for those protocols.</li>
3291 </ul>
3292 <p><strong>Next Steps:</strong></p>
3293 <p>As next steps following things are planned for upcoming phase:</p>
3294 <ul>
3295 <li>Making changes and improvements by taking suggestions from the mentors.</li>
3296 <li>Adding support for ICMP, IP(v6), TCP and later on for Ethernet.</li>
3297 <li>Analyze and come up with effective ways to improve the fuzzing by focusing on the packet creation part.</li>
3298 <li>Standardize the code to be extensible for adding future protocols.</li>
3299 </ul></content>
3300 </entry>
3301 </feed>
3302