When the FD is put() but not freed while O_DISCONNECTED, its "ops"
and "vnode" are cleared. Thus it is entirely valid for a non-NULL
file FD to have a NULL vnode, so we should just treat such FDs
as if the locks had already been cleared (which they should have.)
Fixes #14294.
Since these do not go through get_fd, which would check for them,
we need to do these checks manually in the relevant locations.
Some of these changes were broken out from axeld's original commit,
and some were found by my own auditing.
axeld's solution from 2015 worked in that it solved the panics and
problems with leaking FDs ... but only if nobody actually tried to
use the FDs again. As you can see in the diff of the previous commit,
in allowing closed FDs (which have NULL "ops") to be returned by get_fd,
all consumers of the get_fd API (so, pretty much most functions in
vfs.cpp and fd.cpp) have to check *both* that (1) the fd is not NULL,
and (2) the fd does not have O_DISCONNECT set.
Besides missing a large majority of consumers of get_fd (which caused
ticket #14532 and also the first half of ticket #14756, probably among
others, as I haven't reviewed all NULL-dereference-in-VFS tickets yet)
this solution missed the fact that calling get_fd increments the reference
count, but then exiting the exact same way as if the FD was NULL
(without putting it) when it is disconnected *also* leaks the FD.
As it turns out, a not insignificant number of applications try
to do this, which (depending on whether you went through one of the
'lucky' functions axeld's commit touched) either (1) leaked the FD,
or (2) caused a kernel panic.
Now, we could go through and add O_DISCONNECT checks to every single
consumer of get_fd followed by put_fd to get the proper behavior ...
but that would be the same thing as just returning NULL here and not
incrementing the reference count.
So it seems the first part of axeld's solution (don't set open_count
or ref_count to -1 but leave them as-is) is the only change necessary.
A few places where there were legitimately missing O_DISCONNECT checks
(some originally added by axeld) are (re-)added in the next commit.
Otherwise this seems to be the more robust solution. (But I wonder why
nobody caught this in the code review axeld asked for in the commit
and the ticket back in 2015? Did nobody notice the unbalanced get/put?)
Fixes #14532, part of #14756, and probably any other NULL dereferences
in VFS I/O functions (XHCI is especially good at exposing these)
that are lingering around on the bugtracker.
There was no synchronization of the check of the done flag and the
waiting thread suspending to wait for it. It was therefore possible that
the new team both set the flag and triggered the wakeup of the waiting
thread in that time window, causing it to miss both the set flag and the
thread resumption.
Use a condition variable instead.
Fixes #13081.
Change-Id: I93c45db8dd773fe42b45c4b67153bcd39e200d3b
Reviewed-on: https://review.haiku-os.org/803
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
(cherry picked from commit 919185caba)
Reviewed-on: https://review.haiku-os.org/804
Previously we didn't need to care about threading in here, as it
was used only up to the point where the application's _start was called
and then libroot's heap would take over. But with the introduction of TLS
support by pdziepak in 2014, we also handle TLS bookkeeping inside
runtime_loader, and so this heap needs to be thread-safe.
Properly fixes the JVM crashes korli was attempting to fix in hrev52658,
and fixes #13154, #14129, #14304, #14342 for real.
Change-Id: Ia3398ab47c4f7f290aef41982775bfea05230589
Reviewed-on: https://review.haiku-os.org/777
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Fixes #6423 and helps with #14626.
In BringUpInterfaces, line 772 creates an error which only adds a missing
interface if one does not already exist (i.e., !_testInterface()). This can lead to
a missing WiFi interface if an Ethernet connection has been configured and set in
the /boot/system/settings/network/interfaces before the WiFi has had a chance to
be added to /dev/net. To properly configure a missing device, such as a WiFi
connection, and allow the user to choose amongst configured interfaces (i.e.,
add it to the list of devices in /dev/net and e.g., see WiFi as an option),
removing the 'if' statement on line 772 is necessary.
Two edge cases may arise:
1. A user may disable an interface -- don't add device
Solution: The code currently handles this. _ConfigureInterfacesFromSettings, called
at line 746, checks for interfaces in fSettings to see if they are disabled (706-711).
If so, they are disabled and not set as a missingDevice if the interface is disabled
(709). The next interface is checked... etc.
2. Devices must not be added twice (i.e., Checking for An Existing configured Network)
Solution: The code currently checks for this. On lines 716-720, a device that is found
in fSettings (missingDevice), is set to the interface which is later added to the
/dev/net within that (unnecessary?) if statement (772). The missingDevice will only
be set and added to /dev/net if an entry does not exist in the settings already (716)
(hence the identifier missingDevice).
Change-Id: Ifc303371b88f18c30141a651a7d97a3c860e864f
Reviewed-on: https://review.haiku-os.org/767
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
(cherry picked from commit def61273ed)
Reviewed-on: https://review.haiku-os.org/772
I need this to use loopers in WebKit, which spawns threads and expects
to be able to turn them into event loops later on.
This is the pattern already used in BApplication, we may as well make it
available elsewhere.
Change-Id: I5939ca89d33cb3bcc92567b302c2038d976af598
Reviewed-on: https://review.haiku-os.org/735
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
(cherry picked from commit e6b4b94513)
Reviewed-on: https://review.haiku-os.org/749
The buffers were allocated with B_ANY_KERNEL_ADDRESS and the buffer plus
header block would produce uneven sizes. This lead to some buffers
crossing page boundaries. The call to get_memory_map() is only supplied
with a single entry, which in such a situation may not be enough if the
physical pages are not contiguous. Due to missing result checks this was
not noticed.
Use B_ANY_KERNEL_BLOCK_ADDRESS and align the size of the total buffer
to avoid such page boundary crossing.
Fixes randomly truncated frames in the receive path.
Change-Id: I78fb3a6db8e16b88c4191d504cf6454f084afb36
Reviewed-on: https://review.haiku-os.org/723
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Previously the frame length was set to the allocation size of the buffer
itself, which is constant. Use the length returned on dequeing instead,
which tells how much of the buffer was actually filled.
Fixes overly long frames that lead to various problems along the receive
path.
Change-Id: I2f4641bdf9508f1adc6d2736243366ecf32986ea
Reviewed-on: https://review.haiku-os.org/722
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
The size was in fact the count of physical entries that were used. That
number must necessarily be the same as the number given when adding to
the queue, so that number isn't really interesting. Consequently none
of the users of that API made use of it.
Return the used length instead, which is the way virtio signals how much
valid data resides in the dequeued buffer. This is for example important
to know the frame length of incoming packets in virtio_net.
Change-Id: I00af89d391c7df4dd8b3b39c22a4505e593af938
Reviewed-on: https://review.haiku-os.org/721
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
We reuse the incoming request buffer to send our reply. We did however
not trim that buffer to the length we actually filled out, allowing
any extraneous incoming data to remain in that buffer and be sent back.
Change-Id: Idcc8a7da8dfb433b2d2ed6a47e65ded42426fb01
Reviewed-on: https://review.haiku-os.org/720
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Change-Id: I1ca852f16e2b8d5d22ebed25b682e56fd934c46c
Reviewed-on: https://review.haiku-os.org/640
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
(cherry picked from commit c02c4653c2)
Reviewed-on: https://review.haiku-os.org/719
Reviewed-by: Alexander von Gluck IV <kallisti5@unixzen.com>
Otherwise, create_area fails with "Invalid Argument." Should fix the
"empty directory in userlandfs mount" bug that has been appearing
since the cloneable-area fixes.
Change-Id: I26e73539a9f345e76b22a34a68fe4b49c63683c2
Reviewed-on: https://review.haiku-os.org/707
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
(cherry picked from commit f18658aa3a)
Reviewed-on: https://review.haiku-os.org/708
- Enlarge the window's width so a larger part of the path will fit in the TextBox.
- Apply the existing path to the BFilePanel before browsing. It improve
usability when you paste a path or type a new one in the TextBox
then click on the browse button to choose the application
or fine tune the directory.
Please not that it is a best effort feature : if the file or the directory does
not exist, the BFilePanel will fallback to the old behavior :
showing the previously selected file/directory in the session
(or home directory).
Change-Id: I504a1ec72f9f7a236e2e37039961fddc58218eae
Reviewed-on: https://review.haiku-os.org/672
Reviewed-by: Rene Gollent <rene@gollent.com>
(cherry picked from commit 7c96721b51)
Reviewed-on: https://review.haiku-os.org/698
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Using BDateFimeFormat avoids going through libroot and up again to ICU
throuhg the locale add-on. Moreover, it uses the Locale settings
directly instead of relying on the LC_* environment variables.
Fixes day names in Web+ history menu always showing in english. Tnaks to
Oco for noticing!
Change-Id: I0c7f321a6147e8f5ab31f82de836c5ad23bb321b
Reviewed-on: https://review.haiku-os.org/650
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
(cherry picked from commit ffd9d565d2)
Reviewed-on: https://review.haiku-os.org/697
This just confuses users. Let's re-add it when we have implemented it.
(cherry picked from commit c4bb4fbb7e)
Change-Id: I690920b3743098f27263346a774049446eb5cee3
Reviewed-on: https://review.haiku-os.org/696
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit resolves a problem where a user would be
unable to rate an installed packge.
fixes #14554
Change-Id: I3141eaebbdf531f17eb05302a536c6e0d722a164
Reviewed-on: https://review.haiku-os.org/611
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
(cherry picked from commit 9fa0d70f99)
Reviewed-on: https://review.haiku-os.org/615
Performance improvements for the application updating
lists of packages when the user is operating with the
locale set to Russian.
fixes #14513
Change-Id: I1e2514a2afbd43503ac0edfe280a856411738026
Reviewed-on: https://review.haiku-os.org/612
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
(cherry picked from commit 871ec42d4c)
Reviewed-on: https://review.haiku-os.org/614
Changes the logic flow around reverting the position of
the request / response buffers when the buffer is logged
during trace logging.
Change-Id: I025ca9988b32447e225e3ad1b1d4da1174d2d122
Reviewed-on: https://review.haiku-os.org/599
Reviewed-by: Rene Gollent <rene@gollent.com>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
(cherry picked from commit 66f8dcb1f1)
Reviewed-on: https://review.haiku-os.org/603
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Corrections to some areas where the 'position' of a
data stream was not being set correctly before reading.
Change-Id: I0030a113008028d5480dc36d034cf06915d928de
Reviewed-on: https://review.haiku-os.org/588
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
(cherry picked from commit 88575af1d2)
Reviewed-on: https://review.haiku-os.org/602
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This is the first userguide export on the Postgres-based translation tool
(previously it used MySQL), so please double-check it extra carefully.
(I spotted a few minor problems in the export and fixed the relevant
bugs already.)
Change-Id: Icbe2a3e5bb016ed178ddca6b9f27a048c8d603e5
Reviewed-on: https://review.haiku-os.org/598
Reviewed-by: Alexander von Gluck IV <kallisti5@unixzen.com>
Previously only the "effective revision", i.e. the hrev by itself,
was used. Now we include the "commits ahead" count and the "dirty" flag,
if they're there, using _ instead of - of course.
Change-Id: I5238d01926c2cca242bffbdef30bff606a173a06
Reviewed-on: https://review.haiku-os.org/596
Reviewed-by: waddlesplash <waddlesplash@gmail.com>