[Devel] [PATCH RHEL7 COMMIT] fs/fuse kio: add a sanity check on statistic inc
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Aug 22 13:34:44 MSK 2019
The commit is pushed to "branch-rh7-3.10.0-957.27.2.vz7.107.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.27.2.vz7.107.5
------>
commit 30cdbaaaf33953b919ba2bc4c2c172a62dc7f2f5
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date: Wed Aug 21 13:31:47 2019 +0300
fs/fuse kio: add a sanity check on statistic inc
As there are still possible cases when we expect code to work without
statistic inited, it's theoretically possible some day we again get an
update request for non-inited stat struct, and corrupt stack-protector
cookie and who knows what alse.
So add a sanity check to prevent it.
https://jira.sw.ru/browse/PSBM-96128
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
fs/fuse/kio/pcs/fuse_stat.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/fs/fuse/kio/pcs/fuse_stat.c b/fs/fuse/kio/pcs/fuse_stat.c
index b57be607f5e1..c91bfe8b3bf7 100644
--- a/fs/fuse/kio/pcs/fuse_stat.c
+++ b/fs/fuse/kio/pcs/fuse_stat.c
@@ -31,6 +31,12 @@ static u64 lat_oreder_list[] = {
static inline void fuse_val_stat_update(struct fuse_val_stat *s, u64 val)
{
+ /*
+ * Sanity check. In case s == NULL, stack protector cookie is
+ * corrupted, quite difficult to debug.
+ */
+ BUG_ON(!s);
+
preempt_disable();
if (!__this_cpu_read(s->events)) {
__this_cpu_write(s->val_min, val);
@@ -48,6 +54,11 @@ void fuse_latency_update(struct fuse_lat_stat *s, u64 val)
{
int i;
+ /*
+ * Sanity check. In case s == NULL, stack protector cookie is
+ * corrupted, quite difficult to debug.
+ */
+ BUG_ON(!s);
this_cpu_inc(s->count);
for (i = LAT_ORDER1; i <= LAT_ORDER5; i++) {
if (likely(val <= lat_oreder_list[i])) {
More information about the Devel
mailing list