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: <20160222153552.6f318bcb@recife.lan>
Date:	Mon, 22 Feb 2016 15:35:52 -0300
From:	Mauro Carvalho Chehab <mchehab@....samsung.com>
To:	Dan Carpenter <dan.carpenter@...cle.com>
Cc:	LKML <linux-kernel@...r.kernel.org>
Subject: Troubles with smatch and jiffies

Hi Dan,

I'm having some things that look like false positives when testing the media
drivers against smatch. This is bothering me for some time, but, as this was
harder to debug (as I needed to do a build with -j1), I postponed trying to
fix it for a while.

Basically, smatch is complaining for things like:

	time_before(jiffies, jiffies + msecs_to_jiffies(var));

I noticed the very same behavior on two places:
	drivers/media/pci/ivtv/ivtv-mailbox.c
	drivers/media/rc/ati_remote.c

The enclosed patch makes smatch to shut up for ivtv build, but, IMHO,
we should make it stop making it complain about it globalwide, as the
same warning may also be appearing on other places.

FYI, I'm using here gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2) and the
very latest version of smatch from git://repo.or.cz/smatch.git.

Regards,
Mauro

-- 
Thanks,
Mauro
commit 6a4d1872a94ba8450c9aff6599d1e86b515fd2a9
Author: Mauro Carvalho Chehab <mchehab@....samsung.com>
Date:   Mon Feb 22 14:55:14 2016 -0300

    ivtv-mailbox: avoid confusing smatch
    
    The current logic causes smatch to be confused:
    	include/linux/jiffies.h:359:41: error: strange non-value function or array
    	include/linux/jiffies.h:361:42: error: strange non-value function or array
    	include/linux/jiffies.h:359:41: error: strange non-value function or array
    	include/linux/jiffies.h:361:42: error: strange non-value function or array
    
    Use a different logic.
    
    Signed-off-by: Mauro Carvalho Chehab <mchehab@....samsung.com>

diff --git a/drivers/media/pci/ivtv/ivtv-mailbox.c b/drivers/media/pci/ivtv/ivtv-mailbox.c
index e3ce96763785..4d6a3ad265a5 100644
--- a/drivers/media/pci/ivtv/ivtv-mailbox.c
+++ b/drivers/media/pci/ivtv/ivtv-mailbox.c
@@ -177,8 +177,10 @@ static int get_mailbox(struct ivtv *itv, struct ivtv_mailbox_data *mbdata, int f
 
 		/* Sleep before a retry, if not atomic */
 		if (!(flags & API_NO_WAIT_MB)) {
-			if (time_after(jiffies,
-				       then + msecs_to_jiffies(10*retries)))
+			unsigned int timeout;
+
+			timeout = msecs_to_jiffies(10 * retries);
+			if (time_after(jiffies, then + timeout))
 			       break;
 			ivtv_msleep_timeout(10, 0);
 		}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ