History log of /haiku/src/system/kernel/messaging/KMessage.cpp
Revision Date Author Comments
# c0de5f6a 02-Oct-2020 Jérôme Duval <jerome.duval@gmail.com>

KMessage: panic is valid for kernel and bootloader code

Change-Id: I4473160d809c490cc8862dfd42b41290238e22e3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3274
Reviewed-by: Rene Gollent <rene@gollent.com>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>


# 44c3f5c1 10-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Clean up the mess added in hrev43461 and solve it differently.

* Define a MEMALIGN macro that is either just defined to malloc() or
to the actual memalign() depending on where KMessage is used. We only
use memalign() inside the kernel and libroot.
* Add a comment to the macro explaining that this allows the use of
special heap implementations that might return unaligned buffers for
debugging purposes.


# 5585262b 10-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Revert hrev43455 and instead just align the size.

While this isn't really correct, it works for the use case it is
intended and doesn't open the can of worms we get when trying to do
memalign() across platforms (due to build tools use of KMessage).


# 9a876461 10-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Only free the old buffer if we owned it and set owning flag.

* If we cloned the buffer due to misalignment, only free the old buffer
if we actually own it (i.e. if it was allocated by us).
* Set the KMESSAGE_OWNS_BUFFER flag after cloning the buffer. Previously
the buffer was leaked in the clone case.


# d0aa0748 10-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Ensure proper alignment instead of just checking for it.

* If there is an alignment requirement then better use memalign() to
make sure that it is met.
* Since the BMessageAdapter possibly sets a buffer directly, make a
properly aligned copy of the buffer if it happens to be misaligned.


# ee87d51d 07-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Build fix


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43218 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 40287cba 07-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add opt-in panic for KMessage buffer overflow


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43215 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa088830 14-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Use a more portable cast.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42173 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f31ab90a 16-Nov-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

KMessage::Dump(): Fixed broken format.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39452 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0d1fab52 20-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added flag KMESSAGE_CLONE_BUFFER, which will cause buffer passed to SetTo()
to be cloned.
* Added "flags" parameter to the SetTo(const void*,...) version.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34155 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 395fb089 20-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Style cleanup. No functional change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34152 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dd84bf1d 12-Sep-2008 Ryan Leavengood <leavengood@gmail.com>

Reverting r27437 as per Axel's advice. The variable size is initialized by the
call to ElementAt. Marked CID 1306 as false.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27451 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52a542ad 12-Sep-2008 Ryan Leavengood <leavengood@gmail.com>

Fixed CID 1306: initialize size to 0.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27437 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a1209343 10-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Moved KMessage field printing from vfs_boot.cpp::get_boot_partitions() into
KMessage::Dump().
* Improved message dump output a bit (more concise).
* get_boot_partitions() now simply calls KMessage::Dump() instead.
* Added a KMessage::IsEmpty() method.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26365 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d79c7db 09-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Made Dump() const.
* Removed superfluous whitespace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26347 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5839058a 24-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Memory leak in error cases. CID 737.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25646 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d9a4022 17-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

ReceiveFrom() can now return the message_port_info for the received
message, if desired.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25004 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e09769a9 17-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added Dump() method. It prints some general info and a list of the
message fields, no data, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25001 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4bef3723 29-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

* Followed Ingo's suggestion and send the message manually in the runtime loader;
therefore, we could remove the ugly defines from KMessage again, and compile it
with KMESSAGE_CONTAINER_ONLY.
* Added KMessage::SetDeliveryInfo() to be able to send messages with a correct
header.
* Fixed a bug in KMessage::SendTo() that would not send the senderTeam when passing
a negative value for the parameter, but override it when passing in a valid
value.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21740 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74c0424a 26-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

* Added a mechanism to retrieve a BMessage with eventual error descriptions
for _kern_load_image().
* Added KMessage to the runtime_loader (a bit hacky, though) - it will use
it to deliver the above mentioned functionality.
* load_dependencies() did return the wrong status code in case a library
was missing; now it returns B_MISSING_LIBRARY.
* load_dependencies() will now try to load all dependencies when a report
message is requested; therefore, all missing libraries are listed.
* Renamed uspace_program_args to user_space_program_args.
* The kernel filled in various members of the user_space_program_args structure
unsafely, ie. was not using user_memcpy().
* Renamed some local variables in team.c to better fit our style guide (ie.
uargs to userArgs).
* Changed Tracker to use the new _kern_load_image() variant on Haiku to retrieve
and report all missing libraries. This fixes bug #1324.
* Adapted kernel_cpp.cpp to the runtime loader as well; the latter will now
compile with _LOADER_MODE defined.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dad63129 14-Jul-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Made header includable by C code. In this case a KMessage structure
with the same size as the class is defined.
* The SetTo() methods do now accept an unspecified (negative) bufferSize
in case of being told to initialize from the given buffer.
* Added handy Get*() methods returning a field element value or a
supplied default value, if the field element doesn't exist.
* Added also handy Set*() methods setting the value of first element of
a field, i.e. adding it, if it didn't exist before, otherwise
replacing the old value. Only for fixed size types.
* Moved _FindType() inline template method into the header.
* Made the source file fit for use in the boot loader. If the macro
KMESSAGE_CONTAINER_ONLY is defined, the message sending/receiving part
is omitted.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21605 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d35f0da7 29-Jul-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Aesthetical change.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13854 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 685645f9 28-Jul-2005 Philippe Houdoin <philippe.houdoin@gmail.com>

USER == ! _KERNEL_MODE, right (!?).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13845 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d690920 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed system/core to system/kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12360 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 44c3f5c18843a98ba881efb7e0d71145db705b31 10-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Clean up the mess added in hrev43461 and solve it differently.

* Define a MEMALIGN macro that is either just defined to malloc() or
to the actual memalign() depending on where KMessage is used. We only
use memalign() inside the kernel and libroot.
* Add a comment to the macro explaining that this allows the use of
special heap implementations that might return unaligned buffers for
debugging purposes.


# 5585262bb1db89f5fccc05f8db09299ef4b4b855 10-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Revert hrev43455 and instead just align the size.

While this isn't really correct, it works for the use case it is
intended and doesn't open the can of worms we get when trying to do
memalign() across platforms (due to build tools use of KMessage).


# 9a87646122bb87e350f8c1886d47db0d466c0868 10-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Only free the old buffer if we owned it and set owning flag.

* If we cloned the buffer due to misalignment, only free the old buffer
if we actually own it (i.e. if it was allocated by us).
* Set the KMESSAGE_OWNS_BUFFER flag after cloning the buffer. Previously
the buffer was leaked in the clone case.


# d0aa07489c022f98519a79cbd5ceea5ac060d4d6 10-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Ensure proper alignment instead of just checking for it.

* If there is an alignment requirement then better use memalign() to
make sure that it is met.
* Since the BMessageAdapter possibly sets a buffer directly, make a
properly aligned copy of the buffer if it happens to be misaligned.


# ee87d51d97e2c78bef810c8a09fd2eb5991a15b3 07-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Build fix


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43218 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 40287cba78abb133856ca2b893a4e6f82676c15b 07-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add opt-in panic for KMessage buffer overflow


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43215 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa088830697649a506d2e1b1aaae4cded520552a 14-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Use a more portable cast.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42173 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f31ab90a8dd215b2dd7b6599572e0edf20274cb9 16-Nov-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

KMessage::Dump(): Fixed broken format.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39452 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0d1fab522bfcb2635a8071761cebf28963a6bb40 20-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added flag KMESSAGE_CLONE_BUFFER, which will cause buffer passed to SetTo()
to be cloned.
* Added "flags" parameter to the SetTo(const void*,...) version.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34155 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 395fb0895f9242f1099faec8f797f97b24c74d16 20-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Style cleanup. No functional change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34152 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dd84bf1de8c5308a4ca45e430c486b1b24a57945 12-Sep-2008 Ryan Leavengood <leavengood@gmail.com>

Reverting r27437 as per Axel's advice. The variable size is initialized by the
call to ElementAt. Marked CID 1306 as false.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27451 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52a542adfc165745e9942c3414447dfef355364f 12-Sep-2008 Ryan Leavengood <leavengood@gmail.com>

Fixed CID 1306: initialize size to 0.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27437 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a1209343884e1b6d0c1bfa79c30e40fdc52bd28b 10-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Moved KMessage field printing from vfs_boot.cpp::get_boot_partitions() into
KMessage::Dump().
* Improved message dump output a bit (more concise).
* get_boot_partitions() now simply calls KMessage::Dump() instead.
* Added a KMessage::IsEmpty() method.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26365 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d79c7db810628cc4ceb2ebc63e38086f7b703c2 09-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Made Dump() const.
* Removed superfluous whitespace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26347 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5839058aa9b793b3693422562f663a9147c25ca7 24-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Memory leak in error cases. CID 737.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25646 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d9a40222fccb7e7e1461d40cb4b0e39003a3b8e 17-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

ReceiveFrom() can now return the message_port_info for the received
message, if desired.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25004 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e09769a94c99f86740a654b5cc6973bb96893fff 17-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added Dump() method. It prints some general info and a list of the
message fields, no data, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25001 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4bef3723a183cc1989f8d90308e427243e309d02 29-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

* Followed Ingo's suggestion and send the message manually in the runtime loader;
therefore, we could remove the ugly defines from KMessage again, and compile it
with KMESSAGE_CONTAINER_ONLY.
* Added KMessage::SetDeliveryInfo() to be able to send messages with a correct
header.
* Fixed a bug in KMessage::SendTo() that would not send the senderTeam when passing
a negative value for the parameter, but override it when passing in a valid
value.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21740 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74c0424a43b550536d4b55b8fc13631ca4edfcb0 26-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

* Added a mechanism to retrieve a BMessage with eventual error descriptions
for _kern_load_image().
* Added KMessage to the runtime_loader (a bit hacky, though) - it will use
it to deliver the above mentioned functionality.
* load_dependencies() did return the wrong status code in case a library
was missing; now it returns B_MISSING_LIBRARY.
* load_dependencies() will now try to load all dependencies when a report
message is requested; therefore, all missing libraries are listed.
* Renamed uspace_program_args to user_space_program_args.
* The kernel filled in various members of the user_space_program_args structure
unsafely, ie. was not using user_memcpy().
* Renamed some local variables in team.c to better fit our style guide (ie.
uargs to userArgs).
* Changed Tracker to use the new _kern_load_image() variant on Haiku to retrieve
and report all missing libraries. This fixes bug #1324.
* Adapted kernel_cpp.cpp to the runtime loader as well; the latter will now
compile with _LOADER_MODE defined.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dad631290cc197343ef4dcb3065fdfae08b4c6bc 14-Jul-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Made header includable by C code. In this case a KMessage structure
with the same size as the class is defined.
* The SetTo() methods do now accept an unspecified (negative) bufferSize
in case of being told to initialize from the given buffer.
* Added handy Get*() methods returning a field element value or a
supplied default value, if the field element doesn't exist.
* Added also handy Set*() methods setting the value of first element of
a field, i.e. adding it, if it didn't exist before, otherwise
replacing the old value. Only for fixed size types.
* Moved _FindType() inline template method into the header.
* Made the source file fit for use in the boot loader. If the macro
KMESSAGE_CONTAINER_ONLY is defined, the message sending/receiving part
is omitted.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21605 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d35f0da76d97db2d9b4b646b6d8ef1d04f95865b 29-Jul-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Aesthetical change.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13854 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 685645f9bc6adb601fcd5cf6347f6fa9d319d2ab 28-Jul-2005 Philippe Houdoin <philippe.houdoin@gmail.com>

USER == ! _KERNEL_MODE, right (!?).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13845 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d690920ac4d0cd27eb3c118fb2b0862615869e0 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed system/core to system/kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12360 a95241bf-73f2-0310-859d-f6bbb57e9c96