Method for determining the state data of a message buffer, as well as application software, program library, control unit for a motor vehicle and motor vehicle
A shared memory and program library method coordinates message buffer status updates to prevent overflows, ensuring stable operation in motor vehicle control systems by managing message transmission effectively.
Patent Information
- Application Number
- DE102023104424
- Authority / Receiving Office
- DE · DE
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2023-02-23
- Publication Date
- 2024-12-05
- Estimated Expiration
- 2043-02-23
AI Technical Summary
Existing technologies fail to provide a method to check the status of a message buffer, leading to potential buffer overflows that can cause program crashes, data compromise, and unscheduled privileges, particularly in critical systems like motor vehicle control units.
A method using a shared memory and a program library to update status data of a message buffer, allowing application software to coordinate message transmission and avoid buffer overflows by implementing countermeasures such as reducing transmission rates or terminating faulty processes.
Prevents buffer overflows by ensuring coordinated message handling, maintaining system stability and preventing crashes or data corruption in application software, especially in motor vehicle control systems.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
[0001] The invention relates to a method for determining the state data of a message buffer of an operating system. The message buffer is used by an application software for communication with another application software by sending messages to the operating system via a socket provided by the operating system, and the sent messages are temporarily stored in the message buffer, and the other application software receives the temporarily stored messages from the message buffer via the socket.
[0002] A potential "buffer overflow" is a frequently occurring and often exploited security vulnerability, as well as a cause of unstable application software operation. A buffer overflow occurs when more messages are written to memory than the designated message buffer can hold. A message buffer is a memory for temporarily storing messages. Depending on their function, message buffers can have various properties, such as buffer size, and can be structured differently. They are used to compensate for temporarily differing processing speeds of application software that needs to communicate with each other, thus ensuring continuous data processing. Such continuity can be particularly important in a vehicle's control unit, because a vehicle must be able to maintain its driving operation.
[0003] A message, or messages, refers specifically to a data packet sent from a sender to a receiver. A message contains one or more pieces of information, such as the current temperature and / or the current rotational speed. For example, application software sends messages to another application software so that the latter can select and / or execute software code. Message transmission is advantageous in computer software and is used to enable application software to work and / or interact with each other. Therefore, message transmission is a method of communication between software components or application software.
[0004] The consequences of a buffer overload can include program crashes, data compromise, unauthorized privilege escalation, or shellcode execution. A buffer overload can also affect a control unit, causing it to fail or malfunction, thus degrading system performance. Therefore, it is desirable to monitor the capacity of message buffers for application software connected to the operating system in order to implement countermeasures that prevent buffer overloads.
[0005] US patent 2007 / 050777 A1 discloses a method for monitoring data traffic for an electronic control network with a monitoring server.
[0006] US patent 2009 / 228970 A1 discloses a Linux-based gateway device with a socket library for monitoring communication data.
[0007] US 2015 / 319246 A1 discloses a data transfer device with a function for checking data traffic that occurs when a program library is called.
[0008] The producer-consumer problem is also well-known (https: / / en.wikipedia.org / wiki / Producer%E2%80%93consumer_problem).
[0009] A revelation concerning a buffer overflow can be found at https: / / stackoverflow.com / questions / 49648017 / what-happens-in-tcp-when-theinternal-buffer-fills-up.
[0010] The current state of the art does not offer a way to check a message buffer for buffer overload.
[0011] The invention is based on the objective of avoiding the loss of messages resulting from a buffer overload.
[0012] The problem is solved by the subject matter of the independent patent claims. Advantageous embodiments of the invention are described by the dependent patent claims, the following description, and the figures.
[0013] The invention provides a method for determining the state data of a message buffer. An application software sends messages to the operating system via a socket provided by the operating system for communication with another application software. The sent messages are temporarily stored in a message buffer of the operating system, and the other application software receives the temporarily stored messages from the message buffer via the socket. In the prior art, the problem can arise that the two application software programs (i.e., the application software and the other application software) do not know the current state of the message buffer, e.g.,its fill level is unknown, so that uncoordinated actions of the application software can cause a buffer overflow or a buffer underflow, which can disrupt the execution or operation of the application software.
[0014] Status data therefore shows, in particular, the number (message count) of messages currently stored in the message buffer and / or the total storage requirement of the messages in the message buffer. However, determining this would require a modification of the operating system, which can be associated with an undesirably large amount of effort.
[0015] The terms "application software" and "application" are also commonly used. A socket is a digital object or digital logic provided by the operating system that serves as a communication endpoint. A program or application software uses sockets to exchange messages with other application software. Communication via sockets is generally bidirectional, meaning that messages can both be received and sent via the socket. In other words, an exchange of messages between application software and another application software takes place via the socket of an operating system. However, application software typically cannot access the internal state of a socket's message buffer.
[0016] To perform a buffer overload check of the message buffer, the application software and other application software update the aforementioned state data during sending and receiving via a shared memory, separate from the operating system. In a shared memory, at least two application software processes jointly use a specific portion of the main memory or RAM. A process refers to application software executed by an operating system in the main memory of a processor circuit. Thus, a process encompasses all the state information of a running program. For all participating processes, the shared memory area resides in their address space and can be read and / or modified using normal memory access operations.
[0017] The shared memory counts sent and / or received status data from the application software. This offers the advantage that the application software is informed about the size and / or extent of messages from other application software via the shared memory. Furthermore, messages from the application software and / or other application software can be deferred (i.e., their transmission delayed or prevented) when the shared memory indicates that the message buffer capacity has been reached (i.e., the number of messages and / or the total memory requirement of the messages exceeds a predetermined threshold). This means that messages can be retained and / or are not deleted.
[0018] By enabling application software to determine the capacity state of the message buffer via shared memory, crashes of the application software and / or data corruption / loss and / or damage to data structures in the runtime environment are avoided. This can be prevented if the currently remaining capacity state of the message buffer is determined, particularly with regard to the number and / or total memory requirement of the messages, so that, for example, a countermeasure to reduce data, i.e., a reduction in the number of messages, can be initiated if otherwise an impairment of the operation of the application software is to be expected.
[0019] Shared memory can provide protected mutexes (mutex - mutual exclusion). A protected mutex has a lock and unlock method, and its function is to prevent its lock call from returning as long as another thread in the other application software holds the mutex locked. When the thread that held the protected mutex lock calls the unlock method, the lock call returns in the first thread. This ensures that only one thread holds the mutex lock and accesses the state data at any given time. Thus, protected mutex synchronizes access to shared memory. It is a synchronization basic type that grants exclusive access to shared memory to only one thread at a time.
[0020] The invention provides that a monitoring module, distinct from one of the application software programs and the other application software, initiates a predefined countermeasure when the status data signals a predefined buffer overload. This countermeasure involves data reduction in response to the buffer overload. In other words, a monitoring module can execute a predefined countermeasure when a predefined buffer overload is indicated. The monitoring module can, in particular, be a software system and / or a computer network device configured to read status data relating to the number of messages and / or the total memory requirement of the messages in the message buffer.
[0021] The invention provides that buffer overload in the message buffer comprises situations where a predetermined percentage of the maximum number of messages and / or the maximum number of bytes that may be stored in the message buffer is reached, exceeded, or has been reached, and / or where the rate of increase of the number of messages and / or the number of bytes is greater than a predetermined threshold. In other words, the message buffer includes a limit that indicates when a certain number of messages and / or a maximum number of bytes has been reached. Based on the predetermined percentage, the countermeasure can be triggered even before an actual impairment of message transmission occurs, i.e., before the operating system reacts to a completely full message buffer, thus preventing the operating system's reaction or intervention.The percentage value is specifically less than 100%, for example, in a range of 70% to less than 100%. The percentage can also be expressed as a specific number of messages (e.g., 6 messages) and / or bytes (e.g., 1024 bytes or 1 kB).
[0022] The invention provides that the countermeasure includes reducing the message transmission rate by prompting the monitoring module to reduce the transmission rate of the sending application software. In other words, the monitoring module prompts the application software to decrease the message transmission rate (number of messages per unit of time). This aligns the sending application software with the processing speed of the receiving application software. This prevents buffer overload of the message buffer.
[0023] One advanced implementation provides for the shared memory to use a program library to increment at least one variable, which is part of the state data, with respect to the messages in the message buffer when a message is sent by the application software, and decrement it when a message is received from the other application software. In other words, the shared memory can, via the program library, increase at least one state variable by a specific value when a message is sent by the application software, or decrease its size by a specific value when a message is received from the other application software.By having the two communicating application software programs each use a copy of the program library, it can be ensured, via the program code present in both application software programs and thus coordinated, that both application software programs access the same variable in shared memory.
[0024] One advanced implementation involves the program library using a pointer operation to read a variable from shared memory that indicates the number of messages currently stored in the message buffer. A pointer operation allows reference to a location (e.g., memory position or address) within shared memory. The pointer value thus represents a memory address in shared memory. In other words, the program library can use a pointer operation to read a variable from shared memory that indicates the number of messages currently stored in the message buffer. This allows the application software to determine, using the program library, whether the message buffer is overloaded or, conversely, whether messages can be sent to and / or received from other application software.It should be noted that the checked “buffer overload” does not necessarily have to be an actual “buffer overflow”; it could also be a state of the message buffer that indicates an impending buffer overflow or, conversely, an impending emptying of the message buffer.
[0025] The message buffer capacity can be limited, for example, to a maximum number of stored messages. This maximum number can range from 1 to 256; a common value is 8. The program library can be developed in the C programming language and / or Java, for example. In particular, the program library can be a function library used by multiple application software programs. It can be integrated into one application software program using a linker. Therefore, the memory address and / or the data structure in the shared memory do not need to be provided in the other application software.
[0026] One advanced feature provides for the program library to read a variable from shared memory using a pointer operation. This variable indicates the amount of memory used by messages in the message buffer. In other words, the program library is configured to use a pointer operation to read a value from shared memory that represents the total amount of memory used (e.g., in kilobytes and / or megabytes) by messages in the message buffer. This allows the application software to determine, for example, whether the message buffer is overloaded and / or whether messages can be sent to and / or received from other application software.The total storage capacity of the message buffer can be limited, in addition to or as an alternative to the maximum number of storable messages, by a maximum storage volume (maximum storable data amount). The value of the maximum storage volume can range from 256 bytes to 8 kilobytes, to give examples.
[0027] One advanced approach stipulates that, for both the application software and subsequent application software, access to the socket is handled exclusively through the program library via a system call from the operating system. In other words, an intermediate layer is created, meaning there is a kind of intermediary step where the application software and / or subsequent application software use a method from the program library to execute functionalities provided by the operating system, namely writing to and reading from the socket. Thus, the updating of the state data and the actual system call for accessing the socket are executed in a coordinated manner within the program library. Only during the system call is control of the application software transferred to the kernel (operating system kernel). The operating system itself then does not need to know the memory address of the state data in shared memory.This eliminates the need to modify the operating system itself. This ensures that the status data received by the application software and / or other application software is up-to-date.
[0028] Further training stipulates that the countermeasure involves the monitoring module terminating and / or restarting the application software whose messages are causing the message buffer overload. This prevents a message buffer overload if it is caused by uncontrolled or faulty transmission behavior, such as a faulty infinite loop.
[0029] Further training suggests that the countermeasure involves reducing the data size of messages by having the monitoring module request the sending application software to reduce the data size of the messages. In other words, the monitoring module instructs the application software to reduce the data size (for example, kilobytes or megabytes) of the messages to be sent. The sent messages thus become shorter. This prevents buffer overload in the message buffer when the messages are too large.
[0030] A further development process stipulates that when the message buffer reaches its maximum capacity, the oldest message stored in the buffer is overwritten and / or deleted, or the newest message is discarded. Such a reaction or intervention by the operating system should be avoided.
[0031] As a further solution, the invention also includes a program library. In programming, a program library is a collection of subroutines that offer solutions to thematically related problems. A program library is thus a collection of classes and methods for application software. Possible access to functions of a program library is defined by a programming interface, the memory address of which (jump address) is entered into the address space of the respective application software by a linker.
[0032] As a further solution, the invention includes application software comprising the program library. The application software, or computer software, performs a specific function directly for an end user and / or for another application, e.g., reading a temperature value or a rotational speed value from a respective sensor. Depending on the technical implementation, it can be executed in batch processing mode or in dialog mode.
[0033] The invention has proven particularly advantageous in use in motor vehicles to ensure reliable and / or stable operation. As one solution, the invention comprises a control unit for a motor vehicle, wherein the control unit includes a processor unit containing program instructions which, when executed by the processor unit, cause it to perform an embodiment of the method according to the invention and / or to provide the described program library. For this purpose, the processor unit can include at least one microprocessor and / or at least one microcontroller and / or at least one FPGA (Field Programmable Gate Array) and / or at least one DSP (Digital Signal Processor). Furthermore, the processor unit can include program code configured to perform the embodiment of the method according to the invention when executed by the processor unit.The program code can be stored in a data memory of the processor device. The processor device can, for example, include at least a circuit board and / or at least a SoC (System on Chip).
[0034] As a further solution, the invention also includes a computer-readable storage medium comprising program code which, when executed by a processor circuit of a computer or a computer network, causes it to execute an embodiment of the method according to the invention. The storage medium can, for example, be provided at least partially as a non-volatile data storage medium (e.g., as flash memory and / or as an SSD - solid state drive) and / or at least partially as a volatile data storage medium (e.g., as RAM - random access memory). The storage medium can be located within the processor circuit's data storage. Alternatively, the storage medium can also be operated, for example, as an app store server on the internet. The computer or computer network can provide a processor circuit with at least one microprocessor.The program code can be provided as binary code or assembler and / or as source code of a programming language (e.g. C) and / or as a program script (e.g. Python).
[0035] As a further solution, the invention comprises a motor vehicle comprising an embodiment of the described control unit. The motor vehicle is, in particular, designed as a passenger car or truck, or more generally as a road vehicle.
[0036] The invention also includes combinations of the features of the described embodiments. The invention therefore also includes realizations that each exhibit a combination of the features of several of the described embodiments, provided that the embodiments have not been described as mutually exclusive.
[0037] The following are exemplary embodiments of the invention described. This is illustrated by: Fig. 1 an exemplary graphic representation illustrating features associated with the process according to the present disclosure; Fig. 2 a flowchart of an embodiment of the method according to the invention; Fig. 3 an exemplary graphical representation of a message exchange between two processes of different control units according to the invention; Fig. 4 an exemplary graphical representation of a message exchange between several processes according to the invention; and Fig. 5 an exemplary graphical representation of a message exchange between several processes within several sockets according to the invention.
[0038] The exemplary embodiments described below are preferred embodiments of the invention. In these exemplary embodiments, the described components each represent individual features of the invention, which can be considered independently of one another and each further develops the invention independently. Therefore, the disclosure is intended to include combinations of features of the embodiments other than those shown. Furthermore, the described embodiments can also be supplemented by further features of the invention already described.
[0039] In the figures, identical reference symbols denote functionally equivalent elements.
[0040] Fig. Figure 1 shows a control unit 10, which comprises an operating system 3, application software 5, further application software 6, shared memory 8, and a monitoring module 9. The operating system 3 includes a message buffer 1 and a socket 2. The message buffer 1 contains cached messages 4 from the application software 5 and / or the further application software 6. The application software 5 and the further application software 6 each comprise a program library 7.
[0041] Fig. Figure 1 shows that messages 4 can be sent from application software 5 to operating system 3 and received via socket 2 of operating system 3. In operating system 3, the messages 4 can be temporarily stored in message buffer 1. In particular, messages 4 that cannot be processed immediately can be temporarily stored in message buffer 1. Socket 2 can then send the messages 4, which were intended, for example, for further application software 6, to that further application software 6. The program library 7 of application software 5 and / or further application software 6 allows sent and / or received messages 4 to be incremented and / or decremented via shared memory 8 with respect to their number 12 and / or their total memory requirement 13.The shared memory 8 can then indicate state data 11, which specifies the state of the message buffer 1 with respect to the number 12 of messages 4 and / or the total memory requirement 13 of the messages 4 located in the message buffer 1, and send this data to the respective program library 7 of the application software 5 and / or the other application software 6. If the state data 11 indicates a predefined buffer overload, the monitoring module 9 can initiate a predefined countermeasure via the program library 7, which reacts to the buffer overload by reducing the data volume.
[0042] Fig. In process step S10, application software 5 represents how application software 5 sends messages 4 to operating system 3 via socket 2, which is provided by operating system 3, to communicate with other application software 6. In S20, the sent messages 4 are temporarily stored in the message buffer 1 of operating system 3. In S30, the other application software 6 receives the temporarily stored messages 4 from message buffer 1 via socket 2. To perform a buffer overload check of message buffer 1, application software 5 and the other application software 6 update the state data 11 during sending or receiving in S40 using a shared memory 8, which is distinct from that of operating system 3.
[0043] Fig. 3 represents a message exchange and / or a determination of status data 11 between two control units (control unit 10 and another control unit 14). In a particular embodiment, the method can therefore be carried out between and / or within several control units, in particular by RPC (Remote Procedure Call) and / or Ethernet. This means that the respective control unit 10, 14 can have at least one application software 5, which may include the program library 7. Additionally or alternatively, the respective control unit 10, 14 can include an operating system 3, which has a message buffer 1. Additionally or alternatively, the respective control unit 10, 14 can include a shared memory 8 and / or a monitoring module 9. Fig. 3. ProcA (Process A) and ProcB (Process B) can exchange messages 4. via RPC and / or interact with each other. RPC allows multiple processes to communicate with each other over a network. It can be used for both local and remote applications and is frequently employed in distributed computing systems. ProcA and ProcB can be used to refer to processes, among other things.
[0044] Fig. Figure 4 shows an active loop (L) in process ProcA, a control structure used in programming languages that can perform a false operation (minus symbol) or a true operation (plus symbol). When a true operation is performed, the function OsReceive(SocketA) can display messages 4 from message buffer 1, with respect to their number 12 and / or their total memory requirement 13, from socket 2 via a pointer operation in program library 7. In contrast, when a false operation is performed, no messages 4 can be received (e.g., if state data 11 indicates a buffer overload of message buffer 1).
[0045] Fig. Figure 4 also shows that other processes (ProcB, ProcC, and ProcD) can execute the function OsSend(SocketA) via program library 7, so that messages 4 from the respective processes are sent to socket 2. The respective functions, written in the C programming language, can be executed by program library 7. The function OsGetSocketMsgStat(*len, *mem) uses a pointer operation to read a variable from shared memory 8, which indicates the number 12 of messages 4 and / or the total memory requirement 13 of messages 4 in message buffer 1.
[0046] Fig.Figure 5 shows that any number of processes (Proc1, Proc2, Proc3, ... Procm) can each perform a false operation (branch with minus symbol) or a true operation (branch with plus symbol) using a loop L and access the shared memory 8 via the program library 7. For example, Proc1 can receive messages 4 via socket 1 and send them to socket x. The diagram shows that the shared memory 8, via the program library 7, displays the number 12 of all messages 4 from the m processes and / or the total memory usage 13 of all messages 4 from the m processes. The monitoring module 9 can use the function void OsGetSocketMsgStat(*len, *mem) from the program library 7 to display the number 12 and / or the total memory usage 13, in order to implement countermeasures for data reduction if necessary.
[0047] Overall, the examples show how a buffer overload check can be provided by a program library. Reference symbol list 1 message buffer 2 Socket 3 Operating system 4 news items 5 Application software 6 more application software 7 Program Library 8 Shared Memory 9 Monitoring module 10 Control unit 11 Status data 12 Number 13 Total storage requirement 14 additional control units ProcA Process A ProcB Process B ProcC Process C ProcD Process D Proc1 Process 1 Proc2 Process 2 Proc3 Process 3 Procm process m L loop
Claims
[1] Method for determining status data (11) of a message buffer (1), executed by a processor device of a control unit of a motor vehicle, wherein an application software (5) for communication with another application software (6) sends messages (4) to the operating system (3) to a socket (2) provided by an operating system (3), wherein the sent messages (4) are buffered in a message buffer (1) of the operating system (3) and the other application software (5) receives the buffered messages (4) from the message buffer (1) via the socket (2), characterized by , that to carry out a buffer overload test of the message buffer (1), the application software (5) and the further application software (6) update the status data (11) during sending and receiving by means of a common shared memory (8) which is different from the operating system (3), wherein a monitoring module (9) different from the application software (5) and the further application software (6) starts a predetermined countermeasure in the event that the status data (11) signal a predefined buffer overload, by which countermeasure the buffer overload is reacted to with a data reduction, where the buffer overload in the message buffer (1) occurs when a) a predetermined percentage of a maximum number of messages and / or a maximum number of bytes that may be stored in the message buffer (1) is given or reached or exceeded and b) the rate of increase in the number of messages and / or the number of bytes is greater than a predetermined threshold, and to ensure continuous data processing for maintaining driving operation of the motor vehicle, the countermeasure comprises reducing a transmission rate of the messages (4) by the monitoring module (9) requesting the transmitting application software (5) to reduce the message transmission in relation to the transmission rate. [2] Method according to claim 1, wherein the shared memory (8) increments at least one variable with respect to a number (12) and / or a total memory requirement (13) of the messages (4) located in the message buffer (1) by means of a program library (7) if messages (4) are sent from the application software (5) and / or decrements if messages (4) are received from the further application software (6). [3] Method according to one of the preceding claims 2, wherein the program library (7) reads a variable from the shared memory (8) by means of a pointer operation, which variable indicates the number (12) of messages (4) currently stored in the message buffer (1). [4] Method according to claim 2 or 3, wherein the program library (7) reads a variable from the shared memory (8) by means of a pointer operation, which variable indicates the total memory requirement (13) of the messages (4) in the message buffer (1). [5] Method according to one of claims 2 to 4, wherein in the application software (5) and the further application software (6) access to a system call of the operating system (3) for accessing the socket (2) is effected exclusively by the program library (7). [6] Method according to one of the preceding claims, wherein the countermeasure comprises that the application software (5, 6) whose messages (4) cause the buffer overload in the message buffer (1) is terminated and / or restarted by the monitoring module (9). [7] Method according to one of the preceding claims, wherein the countermeasure comprises reducing a data volume of the messages (4) by the monitoring module (9) requesting the reduction of the data volume with respect to the messages (4) of the sending application software (5, 6). [8] Method according to one of the preceding claims, wherein of the messages (4), the oldest message (4) stored in the message buffer (1) is overwritten and / or deleted or the most recent message (4) to be stored in the message buffer (1) is discarded when a maximum capacity of the message buffer (1) is reached. [9] Program code which, when executed by a processor circuit of a computer or a computer network, causes the computer or computer network to carry out an embodiment of the method according to one of the preceding claims. [10] Control device for a motor vehicle, wherein the control device has a processor device which has program instructions which, when executed by the processor device, cause it to carry out a method according to one of the preceding method claims. [11] Motor vehicle comprising a control device according to claim 10.
Citation Information
Patent Citations
Duration of alerts and scanning of large data stores
US20070050777A1
Gateway device having socket library for monitoring, communication method of gateway device having socket library for monitoring, and communication program of gateway device having socket library for monitoring
US20090228970A1
Data transmission device, data transmission method, and storage medium
US20150319246A1
