linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>,
	Andy Walls <awalls@md.metrocast.net>,
	Bluecherry Maintainers <maintainers@bluecherrydvr.com>,
	Anton Sviridenko <anton@corp.bluecherry.net>,
	Andrey Utkin <andrey.utkin@corp.bluecherry.net>,
	Ismael Luceno <ismael@iodev.co.uk>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	Kukjin Kim <kgene@kernel.org>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Stanimir Varbanov <stanimir.varbanov@linaro.org>,
	Andy Gross <agross@kernel.org>,
	Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Kamil Debski <kamil@wypas.org>,
	Jeongtae Park <jtp.park@samsung.com>,
	Andrzej Hajda <a.hajda@samsung.com>,
	Hans Verkuil <hverkuil@xs4all.nl>, Antti Palosaari <crope@iki.fi>,
	Mike Isely <isely@pobox.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Richard Fontana <rfontana@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Kate Stewart <kstewart@linuxfoundation.org>,
	Colin Ian King <colin.king@canonical.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Ezequiel Garcia <ezequiel@collabora.com>,
	"Lad, Prabhakar" <prabhakar.csengg@gmail.com>,
	Steve Longerbeam <slongerbeam@gmail.com>,
	Nathan Chancellor <natechancellor@gmail.com>,
	Tomasz Figa <tfiga@chromium.org>,
	Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	Boris Brezillon <boris.brezillon@collabora.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 6/7] media: don't do an unsigned int with a 31 bit shift
Date: Thu, 29 Aug 2019 10:03:09 -0700	[thread overview]
Message-ID: <201908291002.2F67F5ADA@keescook> (raw)
In-Reply-To: <1a78a757b37d2628312e1d56d7a741ba89d42a91.1566502743.git.mchehab+samsung@kernel.org>

On Thu, Aug 22, 2019 at 04:39:33PM -0300, Mauro Carvalho Chehab wrote:
> Doing something like:
> 
> 	i32 foo = 1, bar;
> 
> 	bar = foo << 31;
> 
> has an undefined behavior in C, as warned by cppcheck, as we're
> shifting a signed integer.
> 
> Instead, force the numbers to be unsigned, in order to solve this
> issue.

I also recommend using the BIT() macro, which does the ULing correctly,
etc.

i.e. instead of:

-	keyup = (gpio & ir->mask_keyup) ? 1 << 31 : 0;
+	keyup = (gpio & ir->mask_keyup) ? 1UL << 31 : 0;

use:

-	keyup = (gpio & ir->mask_keyup) ? 1 << 31 : 0;
+	keyup = (gpio & ir->mask_keyup) ? BIT(31) : 0;

-- 
Kees Cook

  parent reply	other threads:[~2019-08-29 17:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22 19:39 [PATCH 1/7] media: remove include stdarg.h from some drivers Mauro Carvalho Chehab
2019-08-22 19:39 ` [PATCH 2/7] media: vicodec: make life easier for static analyzers Mauro Carvalho Chehab
2019-08-22 19:39 ` [PATCH 3/7] media: aspeed-video: address a protential usage of an unit var Mauro Carvalho Chehab
2019-08-26 15:12   ` Eddie James
2019-08-22 19:39 ` [PATCH 4/7] media: ov9650: add a sanity check Mauro Carvalho Chehab
2019-08-23 10:33   ` Sylwester Nawrocki
2019-08-22 19:39 ` [PATCH 5/7] media: use the BIT() macro Mauro Carvalho Chehab
2019-08-23  0:08   ` Laurent Pinchart
2019-08-23  9:47     ` [PATCH v2 " Mauro Carvalho Chehab
2019-08-23 10:22       ` Sylwester Nawrocki
2019-08-23 12:12       ` Benoit Parrot
2019-08-23 20:45       ` Laurent Pinchart
2019-08-22 19:39 ` [PATCH 6/7] media: don't do an unsigned int with a 31 bit shift Mauro Carvalho Chehab
2019-08-23  9:08   ` Marc Gonzalez
2019-08-23 10:20     ` Mauro Carvalho Chehab
2019-08-23 11:09       ` Marc Gonzalez
2019-08-29 17:03   ` Kees Cook [this message]
2019-08-22 19:39 ` [PATCH 7/7] media: ngene: don't try to memcpy from NULL Mauro Carvalho Chehab
2019-08-22 19:43   ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201908291002.2F67F5ADA@keescook \
    --to=keescook@chromium.org \
    --cc=a.hajda@samsung.com \
    --cc=agross@kernel.org \
    --cc=andrey.utkin@corp.bluecherry.net \
    --cc=andrzejtp2010@gmail.com \
    --cc=anton@corp.bluecherry.net \
    --cc=awalls@md.metrocast.net \
    --cc=boris.brezillon@collabora.com \
    --cc=colin.king@canonical.com \
    --cc=crope@iki.fi \
    --cc=ezequiel@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hverkuil@xs4all.nl \
    --cc=isely@pobox.com \
    --cc=ismael@iodev.co.uk \
    --cc=jacek.anaszewski@gmail.com \
    --cc=jtp.park@samsung.com \
    --cc=kamil@wypas.org \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=kstewart@linuxfoundation.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=maintainers@bluecherrydvr.com \
    --cc=mchehab+samsung@kernel.org \
    --cc=mchehab@infradead.org \
    --cc=natechancellor@gmail.com \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=prabhakar.csengg@gmail.com \
    --cc=rdunlap@infradead.org \
    --cc=rfontana@redhat.com \
    --cc=s.nawrocki@samsung.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=slongerbeam@gmail.com \
    --cc=stanimir.varbanov@linaro.org \
    --cc=tfiga@chromium.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).