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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 5 May 2015 15:40:13 -0500
From:	Scott Wood <scottwood@...escale.com>
To:	Rivera Jose-B46482 <German.Rivera@...escale.com>
CC:	Dan Carpenter <dan.carpenter@...cle.com>,
	"devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
	Yoder Stuart-B08248 <stuart.yoder@...escale.com>,
	Hamciuc Bogdan-BHAMCIU1 <bhamciu1@...escale.com>,
	"arnd@...db.de" <arnd@...db.de>,
	"Sharma Bhupesh-B45370" <bhupesh.sharma@...escale.com>,
	"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"agraf@...e.de" <agraf@...e.de>,
	"Erez Nir-RM30794" <nir.erez@...escale.com>,
	katz Itai-RM05202 <itai.katz@...escale.com>,
	Marginean Alexandru-R89243 <R89243@...escale.com>,
	Schmitt Richard-B43082 <richard.schmitt@...escale.com>
Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support

On Tue, 2015-05-05 at 15:22 -0500, Rivera Jose-B46482 wrote:
> 
> 
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Tuesday, May 05, 2015 2:57 PM
> > To: Dan Carpenter
> > Cc: Rivera Jose-B46482; devel@...verdev.osuosl.org; Yoder Stuart-B08248;
> > Hamciuc Bogdan-BHAMCIU1; arnd@...db.de; Sharma Bhupesh-B45370;
> > gregkh@...uxfoundation.org; linux-kernel@...r.kernel.org; agraf@...e.de;
> > Erez Nir-RM30794; katz Itai-RM05202; Marginean Alexandru-R89243; Schmitt
> > Richard-B43082
> > Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support
> > 
> > On Tue, 2015-05-05 at 19:40 +0300, Dan Carpenter wrote:
> > > On Tue, May 05, 2015 at 04:08:49PM +0000, Jose Rivera wrote:
> > > > > Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support
> > > > >
> > > > > On Mon, May 04, 2015 at 10:09:08PM +0000, Jose Rivera wrote:
> > > > > > > > +		WARN_ON((int16_t)irq_count < 0);
> > > > > > >
> > > > > > > This code is doing "WARN_ON(test_bit(15, (unsigned long
> > > > > *)&irq_count));".
> > > > > > > That seems like nonsense.  Anyway, just delete the WARN_ON().
> > > > > > >
> > > > > > I disagree. This WARN_ON is checking that irq_count is in the
> > > > > > expected range (it fits in int16_t as a positive number). The
> > > > > > dprc_scan_objects() function expects irq_count to be of type
> > > > > > "unsigned int" (which is 32-bit unsigned)
> > > > > >
> > > > >
> > > > > You're not allowed to disagree because it's a testable thing and
> > > > > not an opinion about style or something.  :P  What you want is:
> > > > >
> > > > > 	WARN_ON(irq_count > SHRT_MAX);
> > > > >
> > > > I see your point now. The check "(int16_t)irq_count < 0)" will not
> > > > be able to catch 0x10000 > 0x7fff, but "irq_count > SHRT_MAX) will.
> > > > So I'll make the suggested change, but I would prefer to use S16_MAX
> > > > rather than SHRT_MAX.
> > > >
> > >
> > > Huh?  I didn't even know about the S16_MAX definition.  There are
> > > literally no users of it in the kernel.  It's not very fair because
> > > there are few users of SHRT_MAX.  But there are literally no users of
> > > S32_MAX in the kernel and 358 users of INT_MAX.
> > >
> > > Don't insist that you must be special and different from everyone else.
> > 
> > There are some users of U16_MAX, U32_MAX, and U64_MAX.  Why use a limit
> > for a different type than is being used?  Why have s16/s32 at all if
> > you're going to conflate it with short/int elsewhere?
> > 
> > That said, I don't see where this code is actually using s16 (or
> > int16_t) for irq_count except in these weird error checks.  German, why
> > do you need to check against 0x7fff (whatever you call it) at all?
> > Won't comparing to a promoted-to-unsigned-int .max_count (as you do
> > immediately after the WARN_ON) suffice?
> > 
> mc_bus->resource_pools[FSL_MC_POOL_IRQ].max_count is of type int16_t
> (and is so, because its value comes from an MC API that returns
> an int16_t). The reason for checking irq_count against 0x7ffff is to 
> catch the case in which irq_count is out of range (irq_count originates
> from values coming from the MC device, so we should do some validation
> before using it)

Comparing irq_count with max_count will catch any condition that
comparing irq_count with 0x7fff will catch.

-Scott


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ