* [PATCH 0/2] Remove Variable Length Arrays from powerpc code
@ 2018-09-05 2:09 Suraj Jitindar Singh
2018-09-05 2:09 ` [PATCH 1/2] powerpc/prom: Remove VLA in prom_check_platform_support() Suraj Jitindar Singh
2018-09-05 2:09 ` [PATCH 2/2] powerpc/pseries: Remove VLA from lparcfg_write() Suraj Jitindar Singh
0 siblings, 2 replies; 6+ messages in thread
From: Suraj Jitindar Singh @ 2018-09-05 2:09 UTC (permalink / raw)
To: linuxppc-dev; +Cc: mpe, mikey, joel, Suraj Jitindar Singh
This patch series removes two Variable Length Arrays (VLAs) from
the powerpc code.
Series based on v4.19-rc2
Suraj Jitindar Singh (2):
powerpc/prom: Remove VLA in prom_check_platform_support()
powerpc/pseries: Remove VLA from lparcfg_write()
arch/powerpc/kernel/prom_init.c | 7 +++++--
arch/powerpc/platforms/pseries/lparcfg.c | 5 ++---
2 files changed, 7 insertions(+), 5 deletions(-)
--
2.13.6
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] powerpc/prom: Remove VLA in prom_check_platform_support()
2018-09-05 2:09 [PATCH 0/2] Remove Variable Length Arrays from powerpc code Suraj Jitindar Singh
@ 2018-09-05 2:09 ` Suraj Jitindar Singh
2018-09-17 2:37 ` Joel Stanley
2018-09-20 4:21 ` [1/2] " Michael Ellerman
2018-09-05 2:09 ` [PATCH 2/2] powerpc/pseries: Remove VLA from lparcfg_write() Suraj Jitindar Singh
1 sibling, 2 replies; 6+ messages in thread
From: Suraj Jitindar Singh @ 2018-09-05 2:09 UTC (permalink / raw)
To: linuxppc-dev; +Cc: mpe, mikey, joel, Suraj Jitindar Singh
In prom_check_platform_support() we retrieve and parse the
"ibm,arch-vec-5-platform-support" property of the chosen node.
Currently we use a variable length array however to avoid this use an
array of constant length 8.
This property is used to indicate the supported options of vector 5
bytes 23-26 of the ibm,architecture.vec node. Each of these options
is a pair of bytes, thus for 4 options we have a max length of 8 bytes.
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
---
arch/powerpc/kernel/prom_init.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 9b38a2e5dd35..ce5fc03dc69f 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1131,12 +1131,15 @@ static void __init prom_check_platform_support(void)
"ibm,arch-vec-5-platform-support");
if (prop_len > 1) {
int i;
- u8 vec[prop_len];
+ u8 vec[8];
prom_debug("Found ibm,arch-vec-5-platform-support, len: %d\n",
prop_len);
+ if (prop_len > sizeof(vec))
+ prom_printf("WARNING: ibm,arch-vec-5-platform-support longer "\
+ " than expected (len: %d)\n", prop_len);
prom_getprop(prom.chosen, "ibm,arch-vec-5-platform-support",
&vec, sizeof(vec));
- for (i = 0; i < prop_len; i += 2) {
+ for (i = 0; i < sizeof(vec); i += 2) {
prom_debug("%d: index = 0x%x val = 0x%x\n", i / 2
, vec[i]
, vec[i + 1]);
--
2.13.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] powerpc/pseries: Remove VLA from lparcfg_write()
2018-09-05 2:09 [PATCH 0/2] Remove Variable Length Arrays from powerpc code Suraj Jitindar Singh
2018-09-05 2:09 ` [PATCH 1/2] powerpc/prom: Remove VLA in prom_check_platform_support() Suraj Jitindar Singh
@ 2018-09-05 2:09 ` Suraj Jitindar Singh
2018-09-17 2:37 ` Joel Stanley
1 sibling, 1 reply; 6+ messages in thread
From: Suraj Jitindar Singh @ 2018-09-05 2:09 UTC (permalink / raw)
To: linuxppc-dev; +Cc: mpe, mikey, joel, Suraj Jitindar Singh
In lparcfg_write we hard code kbuf_sz and then use this as the variable
length of kbuf creating a variable length array. Since we're hard coding
the length anyway just define the array using this as the length and
remove the need for kbuf_sz, thus removing the variable length array.
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
---
arch/powerpc/platforms/pseries/lparcfg.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/lparcfg.c b/arch/powerpc/platforms/pseries/lparcfg.c
index 7c872dc01bdb..8bd590af488a 100644
--- a/arch/powerpc/platforms/pseries/lparcfg.c
+++ b/arch/powerpc/platforms/pseries/lparcfg.c
@@ -585,8 +585,7 @@ static ssize_t update_mpp(u64 *entitlement, u8 *weight)
static ssize_t lparcfg_write(struct file *file, const char __user * buf,
size_t count, loff_t * off)
{
- int kbuf_sz = 64;
- char kbuf[kbuf_sz];
+ char kbuf[64];
char *tmp;
u64 new_entitled, *new_entitled_ptr = &new_entitled;
u8 new_weight, *new_weight_ptr = &new_weight;
@@ -595,7 +594,7 @@ static ssize_t lparcfg_write(struct file *file, const char __user * buf,
if (!firmware_has_feature(FW_FEATURE_SPLPAR))
return -EINVAL;
- if (count > kbuf_sz)
+ if (count > sizeof(kbuf))
return -EINVAL;
if (copy_from_user(kbuf, buf, count))
--
2.13.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] powerpc/prom: Remove VLA in prom_check_platform_support()
2018-09-05 2:09 ` [PATCH 1/2] powerpc/prom: Remove VLA in prom_check_platform_support() Suraj Jitindar Singh
@ 2018-09-17 2:37 ` Joel Stanley
2018-09-20 4:21 ` [1/2] " Michael Ellerman
1 sibling, 0 replies; 6+ messages in thread
From: Joel Stanley @ 2018-09-17 2:37 UTC (permalink / raw)
To: Suraj Jitindar Singh
Cc: linuxppc-dev, Michael Ellerman, Michael Neuling, Kees Cook
On Wed, 5 Sep 2018 at 11:40, Suraj Jitindar Singh
<sjitindarsingh@gmail.com> wrote:
>
> In prom_check_platform_support() we retrieve and parse the
> "ibm,arch-vec-5-platform-support" property of the chosen node.
> Currently we use a variable length array however to avoid this use an
> array of constant length 8.
>
> This property is used to indicate the supported options of vector 5
> bytes 23-26 of the ibm,architecture.vec node. Each of these options
> is a pair of bytes, thus for 4 options we have a max length of 8 bytes.
>
> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] powerpc/pseries: Remove VLA from lparcfg_write()
2018-09-05 2:09 ` [PATCH 2/2] powerpc/pseries: Remove VLA from lparcfg_write() Suraj Jitindar Singh
@ 2018-09-17 2:37 ` Joel Stanley
0 siblings, 0 replies; 6+ messages in thread
From: Joel Stanley @ 2018-09-17 2:37 UTC (permalink / raw)
To: Suraj Jitindar Singh
Cc: linuxppc-dev, Michael Ellerman, Michael Neuling, Kees Cook
On Wed, 5 Sep 2018 at 11:40, Suraj Jitindar Singh
<sjitindarsingh@gmail.com> wrote:
>
> In lparcfg_write we hard code kbuf_sz and then use this as the variable
> length of kbuf creating a variable length array. Since we're hard coding
> the length anyway just define the array using this as the length and
> remove the need for kbuf_sz, thus removing the variable length array.
>
> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [1/2] powerpc/prom: Remove VLA in prom_check_platform_support()
2018-09-05 2:09 ` [PATCH 1/2] powerpc/prom: Remove VLA in prom_check_platform_support() Suraj Jitindar Singh
2018-09-17 2:37 ` Joel Stanley
@ 2018-09-20 4:21 ` Michael Ellerman
1 sibling, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-09-20 4:21 UTC (permalink / raw)
To: Suraj Jitindar Singh, linuxppc-dev; +Cc: mikey, joel, Suraj Jitindar Singh
On Wed, 2018-09-05 at 02:09:50 UTC, Suraj Jitindar Singh wrote:
> In prom_check_platform_support() we retrieve and parse the
> "ibm,arch-vec-5-platform-support" property of the chosen node.
> Currently we use a variable length array however to avoid this use an
> array of constant length 8.
>
> This property is used to indicate the supported options of vector 5
> bytes 23-26 of the ibm,architecture.vec node. Each of these options
> is a pair of bytes, thus for 4 options we have a max length of 8 bytes.
>
> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
> Reviewed-by: Joel Stanley <joel@jms.id.au>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/ab91239942a900e209f72488627306
cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-09-20 4:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-05 2:09 [PATCH 0/2] Remove Variable Length Arrays from powerpc code Suraj Jitindar Singh
2018-09-05 2:09 ` [PATCH 1/2] powerpc/prom: Remove VLA in prom_check_platform_support() Suraj Jitindar Singh
2018-09-17 2:37 ` Joel Stanley
2018-09-20 4:21 ` [1/2] " Michael Ellerman
2018-09-05 2:09 ` [PATCH 2/2] powerpc/pseries: Remove VLA from lparcfg_write() Suraj Jitindar Singh
2018-09-17 2:37 ` Joel Stanley
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).