HOME > RSS > TECHNOLOGY > hack a day

R S S : hack a day


PageRank : 4 %

VoteRank :
(0 - 0 vote)





tagsTags: , , , , , , ,


English

RSS FEED READER



Linux Fu: Tracing System Calls

7 April, by Al Williams[ —]

One of the nice things about Linux and similar operating systems is that you can investigate something to any level you wish. If a program has a problem you can decompile it, debug it, trace it, and — if necessary — even dig into the source code for the kernel and most of the libraries the program is probably using. However, the tools to do this aren’t ones you use every day. One very interesting tool is strace. Using it you can see what system calls any program makes and that can sometimes give you important clues about how the program works or, probably more often, why it doesn’t work.

Let’s consider the least complex use of the command. Suppose you want to make symlink from testxmit.grc to the /tmp directory. That command is simple:

ln -sf testxmit.grc /tmp

But if you tell strace to run it, the command becomes:

strace ln -sf testxmit.grc /tmp

You might want to redirect the output to a file using the shell or the -o option, though. Some commands generate a lot and often the first page or two of output isn’t really what you care about anyway.

Let’s Look

Let’s look at the output:

execve("/bin/ln", ["ln", "-sf", "testxmit.grc", "/tmp"], 0x7fff51ddf6f8 /* 91 vars */) = 0
brk(NULL) = 0x562301ce6000
... 
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=3004096, ...}) = 0
mmap(NULL, 3004096, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f7c45298000
close(3) = 0
stat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=1360, ...}) = 0
lstat("/tmp/testxmit.grc", 0x7fff7ae555d0) = -1 ENOENT (No such file or directory)
symlinkat("testxmit.grc", AT_FDCWD, "/tmp/testxmit.grc") = 0
lseek(0, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
close(0) = 0
close(1) = 0
close(2) = 0
exit_group(0) = ?
+++ exited with 0 +++

At the top, shortened here, are 25 lines dealing with loading shared libraries into the memory space and four lines dealing with locales. I put the first “real” line in bold, where the program calls stat on /tmp and then makes sure the file doesn’t already exist. Finally, you get to the real system call (symlinkat) followed by a few things to close the program out. A lot of work to get to one system call.

You can probably figure out that the part on the left of the equal sign is the return value of the call. Usually, zero is success and other numbers mean different things. However, the openat call, for example, returns a file descriptor (3) and you can see it sent to fstat in the next line.

In Practice

Of course, the ln command works, but humor me and say we were wanting to understand what arguments passed to symlinkat. You could use the -e option to cut the output down to size:

strace -e symlinkat ln -sf testxmit.grc /tmp

You’ll notice something strange if you did the examples in order. The second time you run the command you get two calls to symlinkat. The first one fails because the file already exists. The second one is to some random file name. Taking off the -e lets you see everything (I’m only showing the interesting part):

symlinkat("testxmit.grc", AT_FDCWD, "/tmp/testxmit.grc") = -1 EEXIST (File exists)
openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 3
read(3, "\337\336\10\324\254\233", 6)   = 6
close(3)                                = 0
getpid()                                = 29340
getppid()                               = 29338
getuid()                                = 1000
getgid()                                = 1000
symlinkat("testxmit.grc", AT_FDCWD, "/tmp/CuzoNWnv") = 0
renameat(AT_FDCWD, "/tmp/CuzoNWnv", AT_FDCWD, "/tmp/testxmit.grc") = 0

Notice that the random part comes from reading some data from /dev/urandom. If you don’t want all that output, try:

strace -e synlinkat,renameat ln -sf testxmit.grc /tmp

Other Options

The -p option lets you supply a PID of a running program. Sending the output to a file and then monitoring the file with a tail -f is a good trick. By default, you only see 32 bytes of the call data and that might not be enough. You can adjust that size with the -s option.

So far we’ve only looked at simple programs. But if you want to trace multiple threads, check out the -f and -ff options.

If you want a survey of what the program is calling, the -c option will give you a summary.

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
  0.00    0.000000           0         2           read
  0.00    0.000000           0         7           close
  0.00    0.000000           0         2           stat
  0.00    0.000000           0         3           fstat
  0.00    0.000000           0         1           lstat
  0.00    0.000000           0         1         1 lseek
  0.00    0.000000           0         6           mmap
  ...
  0.00    0.000000           0         4           openat
  0.00    0.000000           0         1           renameat
  0.00    0.000000           0         2         1 symlinkat
------ ----------- ----------- --------- --------- ----------------
100.00    0.000000                    46         5 total

Of Course, There’s More…

This is just one of many tools you can use to examine Linux programs. Debuggers are often useful, especially if you have the source. There are other tools to examine symbol tables and dump executables. But those are topics for another time.

What’s your favorite Linux reverse engineering tool? Let us know in the comments.


Nixie Clock Turns Boombox

7 April, by Moritz Sivers[ —]

With all the Nixie Clock projects out there, it is truly difficult to come up with something new and unique. Nevertheless, [TheJBW] managed to do so with his Ultimate Nixie Internet Alarm Clock (UNIAC) which definitely does not skimp on cool features.

Although the device does tell time, it is actually a portable boombox that streams music from Spotify using a Raspberry Pi Zero running Mopidy. The housing made from smoked acrylic, together with the IN-12A Nixie Tubes, an IN-13 VU meter, and illuminated pushbuttons give this boombox kind of a 70s/90s mashup retro look. The acrylic housing is special since it consists of only two plates which were bent into shape, resulting in smooth edges in contrast to the often used finger or T-slot design.

For his project [TheJBW] designed a general-purpose Nixie display that can not only show time and date but also the elapsed or remaining track time. He also came up with a Python generated artificial voice that reads you the current playlist. The only problem [TheJBW] has run into was when trying to design a suitable battery system for the device, as the high current draw during start-up can easily cause brownouts. Due to time constraints, he ended up with a MacGyver-style solution by taping a 12 V battery pack from Amazon to the back of the unit.

Among the large variety of Nixie projects we don’t think we have ever seen them in an audio player before except for some attempts of using them as an amplifier. However, it is known that IN-13 tubes make a great VU meter.

 


3D Printering: When Resin Printing Gets Smelly

7 April, by Donald Papp[ —]

Nowadays, resin printers are highly accessible and can do some great stuff. But between isopropyl alcohol for part rinsing and the fact that some resins have a definite smell to them, ventilation can get important fast. The manufacturers don’t talk much about this part of the resin printing experience, but it’s there nevertheless. So what can be done when smells become a problem?

I recently had to deal with this when I printed several liters of resin worth of parts. That’s a lot of resin, and a lot of alcohol for part washing. Smells — which had never been much of a problem in my work area — suddenly became an issue.

Where Odors Come From

Smells come from two sources: the resin itself, and the isopropyl alcohol used for cleanup and part washing.

Most Resins Have a Smell

It’s an odor I describe as “raw plastic, with solvent undertones” and some are worse than others.

The variety of resins in my workshop doesn’t even come close to representing everything on the market, but I have given the sniff test to the ones I have on hand. The Elegoo brand resins (White, Translucent, and Grey) all have a distinct odor, with their Black resin smelling strongest overall. Monocure Flex100 resin definitely smells, and ApplyLabwork Modeling resin (advertised as being compatible with Formlabs printers) also clearly smells.

In my experience Formlabs standard resins (white, grey, and clear in particular) are standouts in that they have no particular odor to them, but Formlabs Durable does, and [Bunnie Huang] also noted that the Formlabs Draft resin had a very strong smell to it during his Form 3 teardown. There are many more out there.

Alcohol Loves Evaporation

Isopropyl alcohol is the usual choice for rinsing uncured resin from finished prints during post-processing, and alcohol also happens to rapidly evaporate at normal room temperature. This makes it easy to dry off finished prints, but it also means alcohol jumps at the chance to fill a work area with fumes.

Quantity Can Tip the Scales

What isn’t a problem as a small job may cross the line once quantities go up. Opening and pouring smelly resins, having them sit in an build tank, and the print process itself (which agitates the resin) all contribute to smelling up the immediate area. A small print job might be dealt with by taking a break and airing out the work area, but extended printing means those smells just keep coming.

With alcohol, the more drying and pouring and agitating is going on, the more evaporation and therefore the more smelly the area becomes. For larger jobs, automatic part washing starts to look attractive but there is a side effect. Machines like Formlabs’ Form Wash, Prusa’s CW1, and Anycubic’s upcoming Wash & Cure Machine all aim to make part washing more controlled and convenient, but they do not eliminate odors. Not only are these units not airtight while in use, but the agitation and part drying involves more evaporation than doing small jobs by hand, which is more easily done with sealed containers.

Ways to Deal With Odors

A typical inline fan, duct, and filter combo from Amazon.

When I started a large and extended print job, frequent part washing combined with extended print times led to resin and alcohol smells dominating my work area. Odors were never an issue before, but It was clear I had to make some changes. Here are some options for doing smell control:

  • Crack a window, or banish printing related stuff to somewhere like a garage. A simple and obvious solution, but not always an option.
  • Add a fan and ducting to send the exhaust somewhere inoffensive. There is also the option to add an activated carbon filter into the mix. Amazon has plenty of combos and options for inline fans for this kind of ventilation, usually aimed at hydroponics or other indoor plant growers. If you go this route I suggest getting a speed control for the fan, otherwise you’ll be stuck at full speed (and full volume.)
  • Dollar Store frosted plastic table covers are effective at closing off an area.

    Cover a part washer in a plastic bag when not in active use. If a part washing machine isn’t sealed, it’s always allowing some amount of alcohol to evaporate unless it’s empty. If the part washer is on standby (not being actively used but also not ready for storage) I found that covering it with a small plastic garbage bag between uses reduced the amount of alcohol smell that it gave off.

  • Hang plastic sheets to close off the printing area. I found that sectioning off a part of the room with plastic sheeting was remarkably effective at containing smells. It doesn’t eliminate them, but it makes them much more controllable. Cardboard, a staple gun, Dollar Store frosted plastic table covers, and an unfinished ceiling are friends in this venture. Cut the plastic just above floor level, and overlap the seams to provide a curtained way in and out.
  • Filter the enclosed area with an air purifier. This will recirculate the air, filtering it to remove smells in the process. I found this to be extremely effective when combined with curtaining the print area off with plastic sheets. Make sure the filter has an activated carbon (also called activated charcoal) component to it. A term that may show up when shopping for filters is whether it handles VOCs, or volatile organic compounds. The air purifier I bought also had a timer function, which came in unexpectedly handy for intermittent use. Kijiji or craigslist is a good source for second hand air purifiers.
  • Air purifier inside print area.

    Wear a mask with VOC filter when working directly with smelly materials, such as filling or emptying an automatic part washer. All that alcohol pouring puts a lot of fumes into the air, and while a mask won’t change that, it will make the hands-on part of the job a more pleasant one. The mask I use is an inexpensive 3M half-face mask, for which the VOC filters are standardized and don’t cost much. If possible it’s best to just do this job outside, but If pouring around a bunch of alcohol must be done indoors in the work area, wear the mask while doing it and let the air filter or fan take care of the rest.

If smells are a problem for you, one or more of these should help get you back in control over your work area.

Keeping Your Nose Happy

Getting surprised by smells can happen, and if it does, there are tools that can be used to mitigate it and keep the work area livable. Are there better options for extracting or otherwise handling smells or fumes? What have you done to handle them yourself? Know of any particularly nasty (or friendly) resins? Chime in with the comment section to let us know.

As a final note, there are now some newer resins advertised as water-washable, which sounds promising. Do you have experience with them? Do they smell less, or not at all? We’d love to hear from you in the comments.


Real Engineering Behind Ventilators

7 April, by Al Williams[ —]

Experts on cognition tell us that most people think they know more than they really do. One particular indicator for that is if someone is an expert in one field and they feel like all other fields relate to theirs (everything boils down to math or chemistry or physics, for example). This causes them to be overconfident on things they don’t actually know about. When it became clear that the current virus crisis might lead to a shortage of ventilators, many electronic experts set about to design low-cost easy to replicate ventilators. How hard is it, after all, to squeeze a bag once every few seconds? But it turns out, there are a lot of details you need to know to do it right. [Real Engineering] and [Real Science] joined to create an excellent video that covers a lot of what you need to know. You can see the video below. The video shows a few designs that — while motivated by altruism — would probably do more harm than good if used on real patients.

The video’s creator is a biomedical engineer who worked in the past for Medtronic — a maker of ventilators who, by the way, recently open-sourced one of their designs. They also had [Dr. Rohin Francis], who has a medical YouTube channel, fact check the video. and provide some on-screen background We learned a few new medical terms and found that a high-end ventilator made in one factory gets built at about 225 per week. They think they can increase to 500.

There are actually two different issues. First, the medical capabilities of the ventilator are important, of course. The bag that is at the heart of nearly all the recent “emergency designed” ventilators use, in some cases, can actually work against the body’s breathing mechanism. Too much pressure can cause barotrauma — injury to delicate lung cells due to overpressure.

The other concern is reliability. If my Arduino clock needs to reboot once or twice a day, that’s not ideal, but it won’t bother anyone. If the machine breathing for me hangs up ever, that’s a very serious problem.

[Real Engineering] thinks many of the commercial entities using ventilator designs to grab publicity are appropriating work from MIT that has been around for a few years. There are subtle features in the design that are not always obvious to people who might be copying or trying to simplify the design.

If you want to try your hand and making a simplified emergency ventilator, you really should watch this video. It mostly focuses on the medical side of things. For more on the safety-critical problems, we’ve talked about others raising awareness of that topic, as well.

We are all for hacking ventilators. However, we need to be sure we understand the problem isn’t just an electromechanical one.


Reliability Check: Consumer and Research-Grade Wrist-Worn Heart Rate Monitors

7 April, by Orlando Hoilett[ —]

Wearables are ubiquitous in today’s society. Such devices have evolved in their capabilities from step counters to devices that measure calories burnt, sleep, and heart rate. It’s pretty common to meet people using a wearable or two to track their fitness goals. However, a big question remains unanswered. How accurate are these wearable devices? Researchers from the Big Ideas Lab evaluated a group of wearables to assess their accuracy in measuring heart rate.

Unlike other studies with similar intentions, the Big Ideas Lab specifically wanted to address whether skin color had an effect on the accuracy of the heart rate measurements, and an FDA-cleared Bittium Faros 180 electrocardiogram was used as the benchmark. Overall, the researchers found that there was no difference in accuracy across skin tones, meaning that the same wearable will measure heart rate on a darker skin-toned individual the same as it would on a lighter skin-toned. Phew!

However, that may be the only good news for those wanting to use their wearable to accurately monitor their heart rate. The researchers found the overall accuracy of the devices relative to ECG was a bit variable with average errors of 7.2 beats per minute (BPM) in the consumer-grade wearables and 13.9 BPM in the research-grade wearables at rest. During activity, errors in the consumer-grade wearables climbed to an average of 10.2 BPM and 15.9 in the research-grade wearables. It’s interesting to see that the research-grade devices actually performed worse than the consumer devices.

And there’s a silver lining if you’re an Apple user. The Apple Watch performed consistently better than all other devices with mean errors between 4-5 BPM during rest and during activity, unless you’re breathing deeply, which threw the Apple for a loop.

So, it seems as if wrist-worn heart rate monitors still have some work to do where accuracy is concerned. Although skin tone isn’t a worry, they all become less accurate when the subject is moving around.

If you’d like to try your own hand with fitness trackers, have a look at this completely open project, or go for the gold standard with a wearable DIY ECG.


Help Save The National Videogame Museum

7 April, by Jenny List[ —]

The National Videogame Museum in Sheffield, UK, houses a unique collection celebrating all decades of video games and their culture, and as the lockdown has brought with it a crisis threatening its very existence, has launched a crowdfunding campaign with a video we’ve placed below the break. As a relatively young organisation, they have yet to build up the financial buffer that a more established one would have. It’s important that this and other heritage sites live to open again another day, so we’d urge you to take a look.

On their website they’re providing a page of activities for the bored youngster in your life, but to whet your appetite should you wish to visit them in the future they also have a selection of pages about the rest of their exhibition.

One of the sad features of living through  a pandemic comes in knowing that some of the businesses and organisations we hold dear might not make it through the crisis. We’ve put in a few orders to smaller suppliers over the last week or two to shove a bit of extra business their way, and no doubt you have too. What is not so easy however, is when the threatened organisation is a visitor attraction; we can’t make the trip during a lockdown. The NVM is unlikely to be the only such attraction facing the pinch, so we’d urge you to look out for those that are close to you as well.

Thanks [Tom] for the tip.


Compiling C to PowerPoint

7 April, by Al Williams[ —]

If you have worked for a large company — or even a small one — it might seem that you spend more time writing PowerPoint charts than programming. [Tom Widenhain’s] video asks the question: Can we compile C into PowerPoint? Watch the video below to find out the answer. Would it surprise you to know that [Tom] wanted to simulate the x86? It surprised us, too, and we had to note the video appeared on April 1. It does look workable, though, other than it is a bit unwieldy.

Instead of a Turing machine, this builds a set of clever logic gates. Unsurprisingly, [Tom] is the guy who put together a Turing machine in Excel. Surprisingly, he isn’t the first one to attempt a C to PPT compiler. The University of Chicago had a similar idea over a year ago, based on [Tom’s] earlier work and executed program using inefficient Turing machines.

Ironically, the code on GitHub uses Python to pull off the feat, even though the implementation is incomplete. Using the adder wasn’t very obvious to us, so here’s how it works. First, you have to be in slide show mode, of course. The top two rows of the adder (the first slide in the PowerPoint file) are the inputs. Click on the 1s or 0s. This fills in the middle section. Orange blocks are outputs and red blocks are those you have to click on in that middle section to populate the answer at the bottom. Kind of reminds of the paperclip computer.

So while the effort isn’t complete, we were impressed with the ingenuity of the logic gates. The use of the mouse position for data transfer made us nervous. As [Tom] points out, though, you are welcome to fork his repository and continue the project. We have to admit that we are more likely to abuse spreadsheets than presentation slides.











mirPod.com is the best way to tune in to the Web.

Search, discover, enjoy, news, english podcast, radios, webtv, videos. You can find content from the World & USA & UK. Make your own content and share it with your friends.


HOME add podcastADD PODCAST FORUM By Jordi Mir & mirPod since April 2005....
ABOUT US SUPPORT MIRPOD TERMS OF USE BLOG OnlyFamousPeople MIRTWITTER