[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openvz-devel
Subject:    [Devel] [PATCH RHEL7 COMMIT] fs/fuse kio: add a sanity check on statistic inc
From:       Konstantin Khorenko <khorenko () virtuozzo ! com>
Date:       2019-08-22 10:34:44
Message-ID: 201908221034.x7MAYgQ6011270 () finist-ce7 ! sw ! ru
[Download RAW message or body]

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@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@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@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])) {

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic