public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Kees Cook <keescook@chromium.org>,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	Sangbeom Kim <sbkim73@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-samsung-soc@vger.kernel.org, linux-rtc@vger.kernel.org,
	Kernel Hardening <kernel-hardening@lists.openwall.com>
Subject: Re: [PATCH] rtc: s5m: Remove VLA usage
Date: Fri, 9 Mar 2018 22:34:55 -0600	[thread overview]
Message-ID: <4f25592d-e805-b81e-b518-4b60867ef32a@embeddedor.com> (raw)
In-Reply-To: <CAJKOXPf+4tF4oq5ePsgcpUAQS_M2Vi6b1+J-8D9CVemO-6ve5g@mail.gmail.com>


Hi Krzysztof,

On 03/09/2018 07:04 AM, Krzysztof Kozlowski wrote:
> On Thu, Mar 8, 2018 at 7:03 PM, Gustavo A. R. Silva
> <garsilva@embeddedor.com> wrote:
>>
>>
>> On 03/08/2018 11:58 AM, Kees Cook wrote:
>>>
>>> On Thu, Mar 8, 2018 at 9:20 AM, Gustavo A. R. Silva
>>> <gustavo@embeddedor.com> wrote:
>>>>
>>>> In preparation to enabling -Wvla, remove VLAs and replace them
>>>> with fixed-length arrays instead.
>>>>
>>>>   From a security viewpoint, the use of Variable Length Arrays can be
>>>> a vector for stack overflow attacks. Also, in general, as the code
>>>> evolves it is easy to lose track of how big a VLA can get. Thus, we
>>>> can end up having segfaults that are hard to debug.
>>>>
>>>> Also, fixed as part of the directive to remove all VLAs from
>>>> the kernel: https://lkml.org/lkml/2018/3/7/621
>>>>
>>>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>>>> ---
>>>>    drivers/rtc/rtc-s5m.c | 15 +++++++++------
>>>>    1 file changed, 9 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
>>>> index 6deae10..2b5f4f7 100644
>>>> --- a/drivers/rtc/rtc-s5m.c
>>>> +++ b/drivers/rtc/rtc-s5m.c
>>>> @@ -38,6 +38,9 @@
>>>>     */
>>>>    #define UDR_READ_RETRY_CNT     5
>>>>
>>>> +/* Maximum number of registers for setting time/alarm0/alarm1 */
>>>> +#define MAX_NUM_TIME_REGS      8
>>>
>>>
>>> I would adjust the various const struct s5m_rtc_reg_config's
>>> .regs_count to be represented by this new define, so the stack and the
>>> structures stay in sync. Something like:
>>>
>>> static const struct s5m_rtc_reg_config s2mps13_rtc_regs = {
>>>           .regs_count             = MAX_NUM_TIME_REGS - 1,
>>>
>>> ?
>>>
>>
>> Yep. I thought about that and decided to wait for some feedback first. But
>> yeah, I think is that'd be a good change.
> 
> Define and these assignments should be somehow connected with enum
> defining the offsets for data[] (from
> include/linux/mfd/samsung/rtc.h). Otherwise we define the same in two
> places. The enum could be itself (in separate patch) moved to the
> driver because it is meaningless for others.
>

I got it.

I'll move the enum to rtc-s5m.c and add RTC_MAX_NUM_TIME_REGS at the end 
of it. I'll send a patch series for this.

Thanks for the feedback.
--
Gustavo

> Best regards,
> Krzysztof
> 

      reply	other threads:[~2018-03-10  4:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-08 17:20 [PATCH] rtc: s5m: Remove VLA usage Gustavo A. R. Silva
2018-03-08 17:58 ` Kees Cook
2018-03-08 18:03   ` Gustavo A. R. Silva
2018-03-09 13:04     ` Krzysztof Kozlowski
2018-03-10  4:34       ` Gustavo A. R. Silva [this message]

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=4f25592d-e805-b81e-b518-4b60867ef32a@embeddedor.com \
    --to=garsilva@embeddedor.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=gustavo@embeddedor.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=sbkim73@samsung.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox