lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211107031721.4734-1-ajaygargnsit@gmail.com>
Date:   Sun,  7 Nov 2021 08:47:21 +0530
From:   Ajay Garg <ajaygargnsit@...il.com>
To:     gregkh@...uxfoundation.org, jirislaby@...nel.org,
        andriy.shevchenko@...ux.intel.com, kernel@...il.dk,
        linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     paskripkin@...il.com, Ajay Garg <ajaygargnsit@...il.com>
Subject: [PATCH v4] tty: vt: keyboard: add default switch-case, to handle smatch-warnings in method vt_do_kdgkb_ioctl

smatch-kchecker gives the following warnings when run on keyboard.c :

vt_do_kdgkb_ioctl() error: uninitialized symbol 'kbs'.
vt_do_kdgkb_ioctl() error: uninitialized symbol 'ret'.

This usually happens when switch has no default case and static 
analyzers and even sometimes compilers can’t prove that all possible 
values are covered.


Thus, the default switch-case has been added, which sets the values 
for the two variables :

        * kbs as NULL, which also nicely fits in with kfree.

        * ret as -ENOIOCTLCMD (on same lines if there is no cmd
                               match in "vt_do_kdskled" method).


Many thanks to the following for review of previous versions :

	* Pavel Skripkin <paskripkin@...il.com> 
	* Andy Shevchenko <andy.shevchenko@...il.com> 


Signed-off-by: Ajay Garg <ajaygargnsit@...il.com>
---


There were discussions previously, and the current patch is the 
result.

v1 :
https://lore.kernel.org/linux-serial/YYZN30qfaKMskVwE@kroah.com/T/#t

v2 :
https://lore.kernel.org/linux-serial/CAHP4M8Vdj4Eb8q773BeHvsW9n6t=3n1WznuXAR4fZCNi1J6rOg@mail.gmail.com/T/#m18f45676feaba6b1f01ddd5fe607997b190ef4b9

v3 :
https://lore.kernel.org/linux-serial/20211106220315.392842-1-ajaygargnsit@gmail.com/T/#u

Changes in v2 :

        * Changes as required by scripts/checkpatch.pl

        * Checking whether kbs is not NULL before kfree is not required,
          as kfree(NULL) is safe. So, dropped the check.

Changes in v3 :

        * Using default-switch case, and setting the variables 
          when there is no matching cmd.

Changes in v4 :

        * Removed braces for the default switch-case.


 drivers/tty/vt/keyboard.c | 6 ++++++
 1 file changed, 6 insertions(+)


diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index c7fbbcdcc346..f66c32fe7ef1 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -2090,6 +2090,10 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
 
 		ret = 0;
 		break;
+	default:
+		kbs = NULL;
+		ret = -ENOIOCTLCMD;
+		break;
 	}
 
 	kfree(kbs);

-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ