Skip to contentSkip to conversation

Out-of-bound access in sysrq

DISCUSSION Jiri Slaby 2 participants 3 messages Mar 28, 2013

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

Guys,

how is this supposed to work?

#define SYSRQ_KEY_RESET_MAX 20 /* Should be plenty */
static unsigned short sysrq_reset_seq[SYSRQ_KEY_RESET_MAX];
...
unsigned short platform_sysrq_reset_seq[] __weak = { KEY_RESERVED };
...
static inline void sysrq_register_handler(void)
{
...

        for (i = 0; i < ARRAY_SIZE(sysrq_reset_seq); i++) {
                key = platform_sysrq_reset_seq[i];
                if (key == KEY_RESERVED || key > KEY_MAX)

...

i runs from 0 to 19 incl., but platform_sysrq_reset_seq, if not overriden, is of size 1, so?

thanks,

Signature · 2 lines
js
suse labs
#1 lore raw
Quoted 20 lines · Jiri Slaby

Guys,

how is this supposed to work?

#define SYSRQ_KEY_RESET_MAX 20 /* Should be plenty */
static unsigned short sysrq_reset_seq[SYSRQ_KEY_RESET_MAX];
...
unsigned short platform_sysrq_reset_seq[] __weak = { KEY_RESERVED };
...
static inline void sysrq_register_handler(void)
{
...

        for (i = 0; i < ARRAY_SIZE(sysrq_reset_seq); i++) {
                key = platform_sysrq_reset_seq[i];
                if (key == KEY_RESERVED || key > KEY_MAX)

...

Quoted 5 lines

i runs from 0 to 19 incl., but platform_sysrq_reset_seq, if not overriden, is of size 1, so?

thanks,

Unless I'm missing something, 'i' won't go higher than '0' since the first element of platform_sysrq_reset_seq is set to KEY_RESERVED and in such case the 'break' is executed.

author
#2 lore raw
Quoted 24 lines · Mathieu Poirier
Quoted 23 lines · Jiri Slaby

Guys,

how is this supposed to work?

#define SYSRQ_KEY_RESET_MAX 20 /* Should be plenty */
static unsigned short sysrq_reset_seq[SYSRQ_KEY_RESET_MAX];
...
unsigned short platform_sysrq_reset_seq[] __weak = { KEY_RESERVED };
...
static inline void sysrq_register_handler(void)
{
...

        for (i = 0; i < ARRAY_SIZE(sysrq_reset_seq); i++) {
                key = platform_sysrq_reset_seq[i];
                if (key == KEY_RESERVED || key > KEY_MAX)

...

i runs from 0 to 19 incl., but platform_sysrq_reset_seq, if not overriden, is of size 1, so?

Quoted 6 lines
Quoted 2 lines

thanks,

Unless I'm missing something, 'i' won't go higher than '0' since the first element of platform_sysrq_reset_seq is set to KEY_RESERVED and in such case the 'break' is executed.

Of course, I was apparently sleeping yet. Sorry for the noise!

Signature · 2 lines
js
suse labs