All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: "Jernej Škrabec" <jernej.skrabec@gmail.com>,
	"Maxime Ripard" <mripard@kernel.org>
Cc: thomas.graichen@googlemail.com, David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	Sean Paul <seanpaul@chromium.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH 3/4] drm/modes: Introduce a whitelist for the named modes
Date: Tue, 03 Sep 2019 15:51:38 +0300	[thread overview]
Message-ID: <87k1ap4k6d.fsf@intel.com> (raw)
In-Reply-To: <5597537.Wd4mHnyQvH@jernej-laptop>

On Thu, 29 Aug 2019, Jernej Škrabec <jernej.skrabec@gmail.com> wrote:
> Hi!
>
> Dne torek, 27. avgust 2019 ob 13:58:49 CEST je Maxime Ripard napisal(a):
>> From: Maxime Ripard <maxime.ripard@bootlin.com>
>> 
>> The named modes support has introduced a number of glitches that were in
>> part due to the fact that the parser will take any string as a named mode.
>> 
>> Since we shouldn't have a lot of options there (and they should be pretty
>> standard), let's introduce a whitelist of the available named modes so that
>> the kernel can differentiate between a poorly formed command line and a
>> named mode.
>> 
>> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
>> ---
>>  drivers/gpu/drm/drm_modes.c | 20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>> 
>> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
>> index ea7e6c8c8318..988797d8080a 100644
>> --- a/drivers/gpu/drm/drm_modes.c
>> +++ b/drivers/gpu/drm/drm_modes.c
>> @@ -1677,6 +1677,22 @@ static int drm_mode_parse_cmdline_options(char *str,
>> size_t len, return 0;
>>  }
>> 
>> +const char *drm_named_modes_whitelist[] = {
>> +	"NTSC",
>> +	"PAL",
>> +};
>
> That array should be static. With that fixed:

And add more const for good measure:

static const char * const drm_named_modes_whitelist[] = {

BR,
Jani.

>
> Reviewed-by: Jernej Skrabec <jernej.skrabec@siol.net>
>
> Best regards,
> Jernej
>
>> +
>> +static bool drm_named_mode_is_in_whitelist(const char *mode, unsigned int
>> size) +{
>> +	int i;
>> +
>> +	for (i = 0; i < ARRAY_SIZE(drm_named_modes_whitelist); i++)
>> +		if (!strncmp(mode, drm_named_modes_whitelist[i], size))
>> +			return true;
>> +
>> +	return false;
>> +}
>> +
>>  /**
>>   * drm_mode_parse_command_line_for_connector - parse command line modeline
>> for connector * @mode_option: optional per connector mode option
>> @@ -1794,6 +1810,10 @@ bool drm_mode_parse_command_line_for_connector(const
>> char *mode_option, if (named_mode) {
>>  		if (mode_end + 1 > DRM_DISPLAY_MODE_LEN)
>>  			return false;
>> +
>> +		if (!drm_named_mode_is_in_whitelist(name, mode_end))
>> +			return false;
>> +
>>  		strscpy(mode->name, name, mode_end + 1);
>>  	} else {
>>  		ret = drm_mode_parse_cmdline_res_mode(name, mode_end,
>
>
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-09-03 12:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 11:58 [PATCH 1/4] drm/modes: Add a switch to differentiate free standing options Maxime Ripard
2019-08-27 11:58 ` [PATCH 2/4] drm/modes: Fix the command line parser to take force options into account Maxime Ripard
2019-08-27 19:34   ` Thomas Graichen
2019-08-29 18:14   ` Jernej Škrabec
2019-08-27 11:58 ` [PATCH 3/4] drm/modes: Introduce a whitelist for the named modes Maxime Ripard
2019-08-27 19:35   ` Thomas Graichen
2019-08-29 18:15   ` Jernej Škrabec
2019-09-03 12:51     ` Jani Nikula [this message]
2019-08-27 11:58 ` [PATCH 4/4] drm/selftests: modes: Add more unit tests for the cmdline parser Maxime Ripard
2019-08-27 19:36   ` Thomas Graichen
2019-08-29 18:16   ` Jernej Škrabec
2019-08-27 19:33 ` [PATCH 1/4] drm/modes: Add a switch to differentiate free standing options Thomas Graichen
2019-08-29 18:13 ` Jernej Škrabec

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=87k1ap4k6d.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=mripard@kernel.org \
    --cc=seanpaul@chromium.org \
    --cc=thomas.graichen@googlemail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.