From d6df2edb89026a676c6e0cc609dd5a8cac62fd7c Mon Sep 17 00:00:00 2001 From: Serdar Kocdemir Date: Tue, 1 Aug 2023 18:17:29 +0100 Subject: Duplicate the file descriptors for shellCommand Fixes the fdsan issues regarding the ownership of the file descriptors when running adb gpu commands. Bug: b/293209452 Test: adb shell cmd gpu vkjson Change-Id: Ifb624b888706759cf3689dbc34040e08e3d2d70b --- libs/graphicsenv/IGpuService.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libs/graphicsenv/IGpuService.cpp') diff --git a/libs/graphicsenv/IGpuService.cpp b/libs/graphicsenv/IGpuService.cpp index 4c070aec01..1c0439ec1e 100644 --- a/libs/graphicsenv/IGpuService.cpp +++ b/libs/graphicsenv/IGpuService.cpp @@ -180,9 +180,9 @@ status_t BnGpuService::onTransact(uint32_t code, const Parcel& data, Parcel* rep return reply->writeUtf8AsUtf16(driverPath); } case SHELL_COMMAND_TRANSACTION: { - int in = data.readFileDescriptor(); - int out = data.readFileDescriptor(); - int err = data.readFileDescriptor(); + int in = dup(data.readFileDescriptor()); + int out = dup(data.readFileDescriptor()); + int err = dup(data.readFileDescriptor()); std::vector args; data.readString16Vector(&args); @@ -195,6 +195,9 @@ status_t BnGpuService::onTransact(uint32_t code, const Parcel& data, Parcel* rep status = shellCommand(in, out, err, args); if (resultReceiver != nullptr) resultReceiver->send(status); + ::close(in); + ::close(out); + ::close(err); return OK; } -- cgit v1.2.3-59-g8ed1b