mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/2] regmap: Add range check in _regmap_raw_write()
Date: Thu, 19 Feb 2015 19:31:56 +0900	[thread overview]
Message-ID: <20150219103156.GD3198@finisterre.sirena.org.uk> (raw)
In-Reply-To: <1424335255-7517-1-git-send-email-srinivas.kandagatla@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 1151 bytes --]

On Thu, Feb 19, 2015 at 08:40:55AM +0000, Srinivas Kandagatla wrote:
> regmap_bulk_write() ends up using the path that invokes _regmap_raw_write(),
> however _regmap_raw_write() never checks if the registers that are accessed
> are actually within the accessible range. This results in kernel crashes when
> trying to access registers beyond max_registers.
> 
> This patch just adds check before accessing the register range.

>  	/* Check for unwritable registers before we start */
> -	if (map->writeable_reg)
> -		for (i = 0; i < val_len / map->format.val_bytes; i++)
> -			if (!map->writeable_reg(map->dev,
> -						reg + (i * map->reg_stride)))
> -				return -EINVAL;
> +	for (i = 0; i < count; i++)
> +		if (!regmap_writeable(map, reg + (i * map->reg_stride)))
> +			return -EINVAL;

Your changelog doesn't correspond to what the code is actually doing
here...  what you're actually doing here is replacing an open coding of
regmap_writeable() with calls to the function.

The same papering over the cracks concerns do apply here as well, it's
not immediately obvious that this is a good fix for the issue you
describe.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2015-02-19 10:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-19  8:39 [PATCH 0/2] regmap: fix range checks in _regmap_raw_read/write() Srinivas Kandagatla
2015-02-19  8:40 ` [PATCH 1/2] regmap: Add range check in _regmap_raw_read() Srinivas Kandagatla
2015-02-19 10:27   ` Mark Brown
2015-02-19 11:04     ` Srinivas Kandagatla
2015-02-19 12:21       ` Mark Brown
2015-02-19 13:02         ` Srinivas Kandagatla
2015-02-24  8:55           ` Mark Brown
2015-02-24  9:12             ` Srinivas Kandagatla
2015-02-19  8:40 ` [PATCH 2/2] regmap: Add range check in _regmap_raw_write() Srinivas Kandagatla
2015-02-19 10:31   ` Mark Brown [this message]
2015-02-19 11:11     ` Srinivas Kandagatla
2015-02-19 11:55       ` Mark Brown

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=20150219103156.GD3198@finisterre.sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    /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

all inboxes | Powered by JetHome®