From 3a3df404b4a2f8025ddacb674572fd0a1e7eb14a Mon Sep 17 00:00:00 2001 From: Luis Hector Chavez Date: Fri, 9 Mar 2018 10:14:01 -0800 Subject: [PATCH] adb: Open FunctionFS files with more restrictive access modes This change opens the control, bulk-in, and bulk-out FunctionFS endpoints with O_RDONLY or O_WRONLY. Bug: 70349025 Test: Android on Chrome OS can still use ADB Test: aosp_sailfish-userdebug can still use ADB Change-Id: I3895b626cf7cec8437c36bdc6c6e6055aaf3777c --- adb/daemon/usb.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp index 20fb6a3d1..87cca2966 100644 --- a/adb/daemon/usb.cpp +++ b/adb/daemon/usb.cpp @@ -274,7 +274,7 @@ bool init_functionfs(struct usb_handle* h) { if (h->control < 0) { // might have already done this before LOG(INFO) << "opening control endpoint " << USB_FFS_ADB_EP0; - h->control = adb_open(USB_FFS_ADB_EP0, O_RDWR); + h->control = adb_open(USB_FFS_ADB_EP0, O_WRONLY); if (h->control < 0) { PLOG(ERROR) << "cannot open control endpoint " << USB_FFS_ADB_EP0; goto err; @@ -305,13 +305,13 @@ bool init_functionfs(struct usb_handle* h) { android::base::SetProperty("sys.usb.ffs.ready", "1"); } - h->bulk_out = adb_open(USB_FFS_ADB_OUT, O_RDWR); + h->bulk_out = adb_open(USB_FFS_ADB_OUT, O_RDONLY); if (h->bulk_out < 0) { PLOG(ERROR) << "cannot open bulk-out endpoint " << USB_FFS_ADB_OUT; goto err; } - h->bulk_in = adb_open(USB_FFS_ADB_IN, O_RDWR); + h->bulk_in = adb_open(USB_FFS_ADB_IN, O_WRONLY); if (h->bulk_in < 0) { PLOG(ERROR) << "cannot open bulk-in endpoint " << USB_FFS_ADB_IN; goto err;