Skip to content

Commit

Permalink
Move platform_handle_security_util_win to public mojo directory.
Browse files Browse the repository at this point in the history
This file will shortly be needed by tests in //content so this CL
exposes the file up to the mojo embedder.

This CL contains no functional changes.

BUG=1418101

Change-Id: Ie2741cae0c0537f4a7af0f73ec725477fa562b79
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4289771
Reviewed-by: Ken Rockot <rockot@google.com>
Commit-Queue: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1110708}
  • Loading branch information
wfh-chromium authored and Chromium LUCI CQ committed Feb 28, 2023
1 parent 638c8f2 commit 78f983d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
2 changes: 0 additions & 2 deletions mojo/core/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ template("core_impl_source_set") {
sources += [
"broker_win.cc",
"channel_win.cc",
"platform_handle_security_util_win.cc",
"platform_handle_security_util_win.h",
]
}

Expand Down
2 changes: 1 addition & 1 deletion mojo/core/ipcz_driver/transport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "third_party/ipcz/include/ipcz/ipcz.h"

#if BUILDFLAG(IS_WIN)
#include "mojo/core/platform_handle_security_util_win.h"
#include "mojo/public/cpp/platform/platform_handle_security_util_win.h"
#endif

namespace mojo::core::ipcz_driver {
Expand Down
2 changes: 1 addition & 1 deletion mojo/core/platform_handle_in_transit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "base/win/nt_status.h"
#include "base/win/scoped_handle.h"
#include "mojo/core/platform_handle_security_util_win.h"
#include "mojo/public/cpp/platform/platform_handle_security_util_win.h"
#endif

namespace mojo {
Expand Down
5 changes: 5 additions & 0 deletions mojo/public/cpp/platform/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ component("platform") {
sources += [ "socket_utils_posix.cc" ]
}

if (is_win) {
public += [ "platform_handle_security_util_win.h" ]
sources += [ "platform_handle_security_util_win.cc" ]
}

public_deps = [
"//base",
"//mojo/public/c/system:headers",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "mojo/core/platform_handle_security_util_win.h"
#include "mojo/public/cpp/platform/platform_handle_security_util_win.h"

#include <windows.h>
#include <winternl.h>
Expand All @@ -18,7 +18,7 @@
#include "base/win/scoped_handle.h"
#include "third_party/abseil-cpp/absl/types/optional.h"

namespace mojo::core {
namespace mojo {

namespace {

Expand Down Expand Up @@ -108,4 +108,4 @@ void DcheckIfFileHandleIsUnsafe(HANDLE handle) {
#endif // DCHECK_IS_ON();
}

} // namespace mojo::core
} // namespace mojo
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MOJO_CORE_PLATFORM_HANDLE_SECURITY_UTIL_WIN_H_
#define MOJO_CORE_PLATFORM_HANDLE_SECURITY_UTIL_WIN_H_
#ifndef MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_HANDLE_SECURITY_UTIL_WIN_H_
#define MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_HANDLE_SECURITY_UTIL_WIN_H_

#include "base/component_export.h"
#include "base/win/windows_types.h"

namespace mojo::core {
namespace mojo {

// This function DCHECKs if `handle` is to a writeable file that can be mapped
// executable. If so, this is a security risk. Does nothing in non-DCHECK
// builds.
COMPONENT_EXPORT(MOJO_CPP_PLATFORM)
void DcheckIfFileHandleIsUnsafe(HANDLE handle);

} // namespace mojo::core
} // namespace mojo

#endif // MOJO_CORE_PLATFORM_HANDLE_SECURITY_UTIL_WIN_H_
#endif // MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_HANDLE_SECURITY_UTIL_WIN_H_

0 comments on commit 78f983d

Please sign in to comment.