• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Révision70a8c7aef01d843eb390e744243667e1af6c5615 (tree)
l'heure2016-07-16 04:34:10
AuteurMark Salyzyn <salyzyn@goog...>
CommiterSteve Kondik

Message de Log

libcutils: ashmem print error message for invalid fd

NB: We decided to not sniff for the constant saved ashmem_rdev in
the early error path; requiring either the use of atomic operations,
or acquiring a lock to do it correctly. The heroics are not worth it.

Bug: 26871259
Change-Id: I46249838850ae32063eb5b7d08c731c5bb0fbf6b

Change Summary

Modification

--- a/libcutils/ashmem-dev.c
+++ b/libcutils/ashmem-dev.c
@@ -19,6 +19,7 @@
1919 * ashmem-enabled kernel. See ashmem-sim.c for the "fake" tmp-based version,
2020 * used by the simulator.
2121 */
22+#define LOG_TAG "ashmem"
2223
2324 #include <errno.h>
2425 #include <fcntl.h>
@@ -32,6 +33,7 @@
3233 #include <linux/ashmem.h>
3334
3435 #include <cutils/ashmem.h>
36+#include <log/log.h>
3537
3638 #define ASHMEM_DEVICE "/dev/ashmem"
3739
@@ -92,6 +94,7 @@ static int __ashmem_is_ashmem(int fd)
9294 return -1;
9395 }
9496
97+ rdev = 0; /* Too much complexity to sniff __ashmem_rdev */
9598 if (S_ISCHR(st.st_mode) && st.st_rdev) {
9699 pthread_mutex_lock(&__ashmem_lock);
97100 rdev = __ashmem_rdev;
@@ -114,6 +117,17 @@ static int __ashmem_is_ashmem(int fd)
114117 }
115118 }
116119
120+ if (rdev) {
121+ ALOGE("illegal fd=%d mode=0%o rdev=%d:%d expected 0%o %d:%d",
122+ fd, st.st_mode, major(st.st_rdev), minor(st.st_rdev),
123+ S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IRGRP,
124+ major(rdev), minor(rdev));
125+ } else {
126+ ALOGE("illegal fd=%d mode=0%o rdev=%d:%d expected 0%o",
127+ fd, st.st_mode, major(st.st_rdev), minor(st.st_rdev),
128+ S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IRGRP);
129+ }
130+
117131 errno = ENOTTY;
118132 return -1;
119133 }