[Devel] [PATCH RHEL7 COMMIT] rh/sysfs/blk-sysfs: fix uninitialized var usage

Konstantin Khorenko khorenko at virtuozzo.com
Sat Jan 23 05:04:49 PST 2016


The commit is pushed to "branch-rh7-3.10.0-327.3.1-vz7.10.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.3.1.vz7.10.3
------>
commit 4d24505af475b044a9f27a157991d72c4903a95d
Author: Dmitry Safonov <dsafonov at odin.com>
Date:   Sat Jan 23 17:04:49 2016 +0400

    rh/sysfs/blk-sysfs: fix uninitialized var usage
    
    One may write some shit to unpriv_sgio file (introduced by
    import RHEL7 kernel-3.10.0-229.7.2.el7), which will result in corectness
    check by function queue_var_store returning -EINVAL. Since return value
    of this function is not checked in queue_store_unpriv_sgio, function may
    result in random QUEUE_FLAG_UNPRIV_SGIO flag value.
    Since it's all done under CAP_SYS_ADMIN, it's not too critical.
    
    Found by warning:
    block/blk-sysfs.c: In function ‘queue_store_unpriv_sgio’:
    block/blk-sysfs.c:211:5: warning: ‘val’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      if (val)
    
    Signed-off-by: Dmitry Safonov <dsafonov at odin.com>
---
 block/blk-sysfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 7b99f7e..f4c6917 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -207,6 +207,9 @@ queue_store_unpriv_sgio(struct request_queue *q, const char *page, size_t count)
 		return -EPERM;
 
 	ret = queue_var_store(&val, page, count);
+	if (ret < 0)
+		return ret;
+
 	spin_lock_irq(q->queue_lock);
 	if (val)
 		queue_flag_set(QUEUE_FLAG_UNPRIV_SGIO, q);


More information about the Devel mailing list