--- components/named_mojo_ipc_server/named_mojo_server_endpoint_connector_linux.cc.orig	2026-03-24 16:59:08 UTC
+++ components/named_mojo_ipc_server/named_mojo_server_endpoint_connector_linux.cc
@@ -8,6 +8,10 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#if BUILDFLAG(IS_FREEBSD)
+#include <sys/un.h>
+#endif
+
 #include <memory>
 #include <utility>
 
@@ -86,12 +90,20 @@ void NamedMojoServerEndpointConnectorLinux::OnSocketRe
 
   auto info = std::make_unique<ConnectionInfo>();
   socklen_t len = sizeof(info->credentials);
+#if BUILDFLAG(IS_FREEBSD)
+  if (getsockopt(connection_fd.get(), SOL_SOCKET, LOCAL_PEERCRED,
+#else
   if (getsockopt(connection_fd.get(), SOL_SOCKET, SO_PEERCRED,
+#endif
                  &info->credentials, &len) != 0) {
     PLOG(ERROR) << "getsockopt failed.";
     return;
   }
+#if BUILDFLAG(IS_FREEBSD)
+  info->pid = info->credentials.cr_pid;
+#elif !BUILDFLAG(IS_OPENBSD)
   info->pid = info->credentials.pid;
+#endif
 
   mojo::PlatformChannelEndpoint endpoint(
       mojo::PlatformHandle(std::move(connection_fd)));
