cryptohome / secure_erase_file : bogus "Failed to drop cache." log on v3.14 kernel. |
|||
Issue descriptionLook at the following piece of code: https://chromium.googlesource.com/chromiumos/platform2/+/cf54d499e5b9314e4d1810bdc08ff6af25dafcef/cryptohome/platform.cc#1421 https://chromium.googlesource.com/chromiumos/platform2/+/cf54d499e5b9314e4d1810bdc08ff6af25dafcef/secure_erase_file/secure_erase_file.cc#289 constexpr char kData[] = "3\n"; if (base::WriteFile(FilePath(FILE_PATH_LITERAL( "/proc/sys/vm/drop_caches")), kData, sizeof(kData)) != sizeof(kData)) { LOG(ERROR) << "Failed to drop all caches."; return false; } sizeof(kData) is 3 here, including the trailing \0 character. Since /proc/sys/vm/drop_caches is configured to hold only one integer, it reads only 2 bytes: the integer '3' and the trailing spaces '\n'. When write() returned 2, base::WriteFile() tries to write the remaining 1 byte. 3.14 kernel returns EINVAL here because '\0' is not a valid integer. Newer kernel https://chromium.googlesource.com/chromiumos/third_party/kernel/+/chromeos-3.18/kernel/sysctl.c#2061 just ignores the write to any non-zero file position.
,
Dec 14 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform2/+/e11f6bcc44dffb4a7a03c03708b447b96dbcc50e commit e11f6bcc44dffb4a7a03c03708b447b96dbcc50e Author: Kazuhiro Inaba <kinaba@chromium.org> Date: Thu Dec 14 10:02:44 2017 cryptohome: Fix bogus error log "failed to drop cache". When the code is executed on 3.14 kernel it always produces this error, but in fact it is not failing. The unintenionalily written trailing '\0' is handled as invalid. The important value '3' is written and processed by the sysctl handler. BUG= chromium:794826 TEST=Modified to let DropMountCaches() fail and tested on Samus (3.14) and Kevin (4.4). Change-Id: Iaf465d22e176501eedfdc54d9664c80f14d7dbf5 Reviewed-on: https://chromium-review.googlesource.com/826523 Commit-Ready: Kazuhiro Inaba <kinaba@chromium.org> Tested-by: Kazuhiro Inaba <kinaba@chromium.org> Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org> [modify] https://crrev.com/e11f6bcc44dffb4a7a03c03708b447b96dbcc50e/cryptohome/platform.cc
,
Dec 15 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform2/+/1de176b1fb81c45c227bdb92cc84482f5ea52467 commit 1de176b1fb81c45c227bdb92cc84482f5ea52467 Author: Kazuhiro Inaba <kinaba@chromium.org> Date: Fri Dec 15 02:11:52 2017 secure_erase_file: Do not write \0 to /proc/sys/vm/drop_caches The previous code writes '3', '\n', and '\0' to drop_caches because sizeof("3\n") is defined to be 3. Since '\0' is nether a digit nor a whitespace character, it is invalid for this sysctl entry. Actually, on the 3.14 kernel this WriteFile() only writes the first 2 bytes. This CL changes the code to write just a single character '3'. Note that there is no practical or observable problem in the old code. The first two bytes were always written and triggered the cache drop as intented. BUG= chromium:794826 TEST=`strace secure_erase_file` not getting EINVAL on veyron_minnie (3.14) TEST=`secure_erase_file` still triggers "kernel drop_caches:3" kernel log Change-Id: Ie78624ee8bb7c97ee3019a66af56958bfd691db9 Reviewed-on: https://chromium-review.googlesource.com/826205 Commit-Ready: Kazuhiro Inaba <kinaba@chromium.org> Tested-by: Kazuhiro Inaba <kinaba@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org> [modify] https://crrev.com/1de176b1fb81c45c227bdb92cc84482f5ea52467/secure_erase_file/secure_erase_file.cc
,
Dec 15 2017
,
Jul 30
|
|||
►
Sign in to add a comment |
|||
Comment 1 by kinaba@chromium.org
, Dec 14 2017