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>] [day] [month] [year] [list]
Message-ID: <202209111308.tUVWzQJe-lkp@intel.com>
Date:   Tue, 13 Sep 2022 12:14:46 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, Thomas Gleixner <tglx@...utronix.de>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        Ammar Faizi <ammarfaizi2@...weeb.org>,
        GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
        linux-kernel@...r.kernel.org
Subject: [ammarfaizi2-block:tglx/devel/printk 16/29]
 kernel/printk/printk.c:759 devkmsg_read() warn: variable dereferenced before
 check 'user' (see line 754)

tree:   https://github.com/ammarfaizi2/linux-block tglx/devel/printk
head:   f6339cd6dc7f812f822e86bd78d1edbf2bfc730b
commit: 4984141cc2064cdf4e4a122fa0d895bd93943e4e [16/29] printk: Use struct cons_text_buf
config: x86_64-randconfig-m001
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>

smatch warnings:
kernel/printk/printk.c:759 devkmsg_read() warn: variable dereferenced before check 'user' (see line 754)

vim +/user +759 kernel/printk/printk.c

e11fea92e13fb9 kernel/printk.c        Kay Sievers        2012-05-03  749  static ssize_t devkmsg_read(struct file *file, char __user *buf,
e11fea92e13fb9 kernel/printk.c        Kay Sievers        2012-05-03  750  			    size_t count, loff_t *ppos)
e11fea92e13fb9 kernel/printk.c        Kay Sievers        2012-05-03  751  {
e11fea92e13fb9 kernel/printk.c        Kay Sievers        2012-05-03  752  	struct devkmsg_user *user = file->private_data;
896fbe20b4e233 kernel/printk/printk.c John Ogness        2020-07-09  753  	struct printk_record *r = &user->record;
4984141cc2064c kernel/printk/printk.c Thomas Gleixner    2022-09-03 @754  	char *outbuf = user->txtbuf.ext_text;
                                                                                               ^^^^^^
Dereference

4984141cc2064c kernel/printk/printk.c Thomas Gleixner    2022-09-03  755  	const int maxlen = sizeof(user->txtbuf.ext_text);
e11fea92e13fb9 kernel/printk.c        Kay Sievers        2012-05-03  756  	size_t len;
e11fea92e13fb9 kernel/printk.c        Kay Sievers        2012-05-03  757  	ssize_t ret;
e11fea92e13fb9 kernel/printk.c        Kay Sievers        2012-05-03  758  
e11fea92e13fb9 kernel/printk.c        Kay Sievers        2012-05-03 @759  	if (!user)
                                                                                    ^^^^^
Checked too late.

e11fea92e13fb9 kernel/printk.c        Kay Sievers        2012-05-03  760  		return -EBADF;
e11fea92e13fb9 kernel/printk.c        Kay Sievers        2012-05-03  761  
4a77a5a06ec66e kernel/printk.c        Yuanhan Liu        2012-06-16  762  	ret = mutex_lock_interruptible(&user->lock);
4a77a5a06ec66e kernel/printk.c        Yuanhan Liu        2012-06-16  763  	if (ret)
4a77a5a06ec66e kernel/printk.c        Yuanhan Liu        2012-06-16  764  		return ret;
de6fcbdb68b29b kernel/printk/printk.c Sergey Senozhatsky 2016-12-27  765  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ