Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: util/mach/mach_message.h

Issue 1001943002: handler/mac: Log a warning when an exception message has a suspicious (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: MACH_MSG_TYPE_MAKE_SEND_ONCE Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « util/mach/exception_ports_test.cc ('k') | util/mach/mach_message.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #ifndef CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_ 15 #ifndef CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_
16 #define CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_ 16 #define CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_
17 17
18 #include <mach/mach.h> 18 #include <mach/mach.h>
19 #include <stdint.h> 19 #include <stdint.h>
20 #include <sys/types.h>
20 21
21 namespace crashpad { 22 namespace crashpad {
22 23
24 //! \brief A Mach message option specifying that an audit trailer should be
25 //! delivered during a receive operation.
26 //!
27 //! This constant is provided because the macros normally used to request this
28 //! behavior are cumbersome.
29 const mach_msg_option_t kMachMessageReceiveAuditTrailer =
30 MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) |
31 MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT);
32
23 //! \brief Special constants used as `mach_msg_timeout_t` values. 33 //! \brief Special constants used as `mach_msg_timeout_t` values.
24 enum : mach_msg_timeout_t { 34 enum : mach_msg_timeout_t {
25 //! \brief When passed to MachMessageDeadlineFromTimeout(), that function will 35 //! \brief When passed to MachMessageDeadlineFromTimeout(), that function will
26 //! return #kMachMessageDeadlineNonblocking. 36 //! return #kMachMessageDeadlineNonblocking.
27 kMachMessageTimeoutNonblocking = 0, 37 kMachMessageTimeoutNonblocking = 0,
28 38
29 //! \brief When passed to MachMessageDeadlineFromTimeout(), that function will 39 //! \brief When passed to MachMessageDeadlineFromTimeout(), that function will
30 //! return #kMachMessageDeadlineWaitIndefinitely. 40 //! return #kMachMessageDeadlineWaitIndefinitely.
31 kMachMessageTimeoutWaitIndefinitely = 0xffffffff, 41 kMachMessageTimeoutWaitIndefinitely = 0xffffffff,
32 }; 42 };
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 //! for sending do not contain trailers. 151 //! for sending do not contain trailers.
142 //! 152 //!
143 //! \param[in] header A pointer to a received Mach message. 153 //! \param[in] header A pointer to a received Mach message.
144 //! 154 //!
145 //! \return A pointer to the trailer following the received Mach message’s body. 155 //! \return A pointer to the trailer following the received Mach message’s body.
146 //! The contents of the trailer depend on the options provided to 156 //! The contents of the trailer depend on the options provided to
147 //! `mach_msg()` or a similar function when the message was received. 157 //! `mach_msg()` or a similar function when the message was received.
148 const mach_msg_trailer_t* MachMessageTrailerFromHeader( 158 const mach_msg_trailer_t* MachMessageTrailerFromHeader(
149 const mach_msg_header_t* header); 159 const mach_msg_header_t* header);
150 160
161 //! \brief Returns the process ID of a Mach message’s sender from its audit
162 //! trailer.
163 //!
164 //! For the audit trailer to be present, the message must have been received
165 //! with #kMachMessageReceiveAuditTrailer or its macro equivalent specified in
166 //! the receive options.
167 //!
168 //! If the kernel is the message’s sender, a process ID of `0` will be returned.
169 //!
170 //! \param[in] trailer The trailer received with a Mach message.
171 //!
172 //! \return The process ID of the message’s sender, or `-1` on failure with a
173 //! message logged. It is considered a failure for \a trailer to not contain
174 //! audit information.
175 pid_t AuditPIDFromMachMessageTrailer(const mach_msg_trailer_t* trailer);
176
151 } // namespace crashpad 177 } // namespace crashpad
152 178
153 #endif // CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_ 179 #endif // CRASHPAD_UTIL_MACH_MACH_MESSAGE_H_
OLDNEW
« no previous file with comments | « util/mach/exception_ports_test.cc ('k') | util/mach/mach_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698