* [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts
@ 2019-06-27 16:58 ` Colin King
0 siblings, 0 replies; 10+ messages in thread
From: Colin King @ 2019-06-27 16:58 UTC (permalink / raw)
To: Oleksandr Andrushchenko, Jaroslav Kysela, Takashi Iwai,
xen-devel, alsa-devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Shifting the integer value 1 is evaluated using 32-bit
arithmetic and then used in an expression that expects a 64-bit
value, so there is potentially an integer overflow. Fix this
by using the BIT_ULL macro to perform the shift.
Addresses-Coverity: ("Unintentional integer overflow")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
sound/xen/xen_snd_front_alsa.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
index b14ab512c2ce..e01631959ed8 100644
--- a/sound/xen/xen_snd_front_alsa.c
+++ b/sound/xen/xen_snd_front_alsa.c
@@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
mask = 0;
for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
- mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif;
+ mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
return mask;
}
@@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
mask = 0;
for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
- if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats)
+ if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
return mask;
--
2.20.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts
@ 2019-06-27 16:58 ` Colin King
0 siblings, 0 replies; 10+ messages in thread
From: Colin King @ 2019-06-27 16:58 UTC (permalink / raw)
To: Oleksandr Andrushchenko, Jaroslav Kysela, Takashi Iwai,
xen-devel, alsa-devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Shifting the integer value 1 is evaluated using 32-bit
arithmetic and then used in an expression that expects a 64-bit
value, so there is potentially an integer overflow. Fix this
by using the BIT_ULL macro to perform the shift.
Addresses-Coverity: ("Unintentional integer overflow")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
sound/xen/xen_snd_front_alsa.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
index b14ab512c2ce..e01631959ed8 100644
--- a/sound/xen/xen_snd_front_alsa.c
+++ b/sound/xen/xen_snd_front_alsa.c
@@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
mask = 0;
for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
- mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif;
+ mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
return mask;
}
@@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
mask = 0;
for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
- if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats)
+ if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
return mask;
--
2.20.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Xen-devel] [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts
@ 2019-06-27 16:58 ` Colin King
0 siblings, 0 replies; 10+ messages in thread
From: Colin King @ 2019-06-27 16:58 UTC (permalink / raw)
To: Oleksandr Andrushchenko, Jaroslav Kysela, Takashi Iwai,
xen-devel, alsa-devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Shifting the integer value 1 is evaluated using 32-bit
arithmetic and then used in an expression that expects a 64-bit
value, so there is potentially an integer overflow. Fix this
by using the BIT_ULL macro to perform the shift.
Addresses-Coverity: ("Unintentional integer overflow")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
sound/xen/xen_snd_front_alsa.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
index b14ab512c2ce..e01631959ed8 100644
--- a/sound/xen/xen_snd_front_alsa.c
+++ b/sound/xen/xen_snd_front_alsa.c
@@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
mask = 0;
for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
- mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif;
+ mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
return mask;
}
@@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
mask = 0;
for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
- if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats)
+ if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
return mask;
--
2.20.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts
2019-06-27 16:58 ` Colin King
(?)
(?)
@ 2019-06-28 8:46 ` Takashi Iwai
-1 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2019-06-28 8:46 UTC (permalink / raw)
To: Colin King
Cc: alsa-devel, Oleksandr Andrushchenko, xen-devel, Jaroslav Kysela,
kernel-janitors, linux-kernel
On Thu, 27 Jun 2019 18:58:53 +0200,
Colin King wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Shifting the integer value 1 is evaluated using 32-bit
> arithmetic and then used in an expression that expects a 64-bit
> value, so there is potentially an integer overflow. Fix this
> by using the BIT_ULL macro to perform the shift.
>
> Addresses-Coverity: ("Unintentional integer overflow")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
The fix is correct, but luckily we didn't hit the integer overflow, as
all passed values are less than 32bit.
In anyway, applied now. Thanks.
Takashi
> ---
> sound/xen/xen_snd_front_alsa.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
> index b14ab512c2ce..e01631959ed8 100644
> --- a/sound/xen/xen_snd_front_alsa.c
> +++ b/sound/xen/xen_snd_front_alsa.c
> @@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
> mask = 0;
> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
> if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
> - mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif;
> + mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
>
> return mask;
> }
> @@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
>
> mask = 0;
> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
> - if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats)
> + if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
> mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
>
> return mask;
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts
@ 2019-06-28 8:46 ` Takashi Iwai
0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2019-06-28 8:46 UTC (permalink / raw)
To: Colin King
Cc: alsa-devel, Oleksandr Andrushchenko, xen-devel, Jaroslav Kysela,
kernel-janitors, linux-kernel
On Thu, 27 Jun 2019 18:58:53 +0200,
Colin King wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Shifting the integer value 1 is evaluated using 32-bit
> arithmetic and then used in an expression that expects a 64-bit
> value, so there is potentially an integer overflow. Fix this
> by using the BIT_ULL macro to perform the shift.
>
> Addresses-Coverity: ("Unintentional integer overflow")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
The fix is correct, but luckily we didn't hit the integer overflow, as
all passed values are less than 32bit.
In anyway, applied now. Thanks.
Takashi
> ---
> sound/xen/xen_snd_front_alsa.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
> index b14ab512c2ce..e01631959ed8 100644
> --- a/sound/xen/xen_snd_front_alsa.c
> +++ b/sound/xen/xen_snd_front_alsa.c
> @@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
> mask = 0;
> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
> if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
> - mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif;
> + mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
>
> return mask;
> }
> @@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
>
> mask = 0;
> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
> - if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats)
> + if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
> mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
>
> return mask;
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts
@ 2019-06-28 8:46 ` Takashi Iwai
0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2019-06-28 8:46 UTC (permalink / raw)
To: Colin King
Cc: alsa-devel, Oleksandr Andrushchenko, xen-devel, Jaroslav Kysela,
kernel-janitors, linux-kernel
On Thu, 27 Jun 2019 18:58:53 +0200,
Colin King wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Shifting the integer value 1 is evaluated using 32-bit
> arithmetic and then used in an expression that expects a 64-bit
> value, so there is potentially an integer overflow. Fix this
> by using the BIT_ULL macro to perform the shift.
>
> Addresses-Coverity: ("Unintentional integer overflow")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
The fix is correct, but luckily we didn't hit the integer overflow, as
all passed values are less than 32bit.
In anyway, applied now. Thanks.
Takashi
> ---
> sound/xen/xen_snd_front_alsa.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
> index b14ab512c2ce..e01631959ed8 100644
> --- a/sound/xen/xen_snd_front_alsa.c
> +++ b/sound/xen/xen_snd_front_alsa.c
> @@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
> mask = 0;
> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
> if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
> - mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif;
> + mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
>
> return mask;
> }
> @@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
>
> mask = 0;
> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
> - if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats)
> + if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
> mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
>
> return mask;
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Xen-devel] [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts
@ 2019-06-28 8:46 ` Takashi Iwai
0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2019-06-28 8:46 UTC (permalink / raw)
To: Colin King
Cc: alsa-devel, Oleksandr Andrushchenko, kernel-janitors,
linux-kernel, Jaroslav Kysela, xen-devel
On Thu, 27 Jun 2019 18:58:53 +0200,
Colin King wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Shifting the integer value 1 is evaluated using 32-bit
> arithmetic and then used in an expression that expects a 64-bit
> value, so there is potentially an integer overflow. Fix this
> by using the BIT_ULL macro to perform the shift.
>
> Addresses-Coverity: ("Unintentional integer overflow")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
The fix is correct, but luckily we didn't hit the integer overflow, as
all passed values are less than 32bit.
In anyway, applied now. Thanks.
Takashi
> ---
> sound/xen/xen_snd_front_alsa.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
> index b14ab512c2ce..e01631959ed8 100644
> --- a/sound/xen/xen_snd_front_alsa.c
> +++ b/sound/xen/xen_snd_front_alsa.c
> @@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
> mask = 0;
> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
> if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
> - mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif;
> + mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
>
> return mask;
> }
> @@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
>
> mask = 0;
> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
> - if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats)
> + if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
> mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
>
> return mask;
> --
> 2.20.1
>
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Xen-devel] [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts
2019-06-28 8:46 ` Takashi Iwai
(?)
@ 2019-07-01 5:46 ` Oleksandr Andrushchenko
-1 siblings, 0 replies; 10+ messages in thread
From: Oleksandr Andrushchenko @ 2019-07-01 5:46 UTC (permalink / raw)
To: Takashi Iwai, Colin King
Cc: alsa-devel, Oleksandr Andrushchenko, kernel-janitors,
linux-kernel, Jaroslav Kysela, xen-devel
On 6/28/19 11:46 AM, Takashi Iwai wrote:
> On Thu, 27 Jun 2019 18:58:53 +0200,
> Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Shifting the integer value 1 is evaluated using 32-bit
>> arithmetic and then used in an expression that expects a 64-bit
>> value, so there is potentially an integer overflow. Fix this
>> by using the BIT_ULL macro to perform the shift.
>>
>> Addresses-Coverity: ("Unintentional integer overflow")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thank you for you patch,
Oleksandr
> The fix is correct, but luckily we didn't hit the integer overflow, as
> all passed values are less than 32bit.
>
> In anyway, applied now. Thanks.
>
>
> Takashi
>
>> ---
>> sound/xen/xen_snd_front_alsa.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
>> index b14ab512c2ce..e01631959ed8 100644
>> --- a/sound/xen/xen_snd_front_alsa.c
>> +++ b/sound/xen/xen_snd_front_alsa.c
>> @@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
>> mask = 0;
>> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
>> if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
>> - mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif;
>> + mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
>>
>> return mask;
>> }
>> @@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
>>
>> mask = 0;
>> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
>> - if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats)
>> + if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
>> mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
>>
>> return mask;
>> --
>> 2.20.1
>>
>>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Xen-devel] [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts
@ 2019-07-01 5:46 ` Oleksandr Andrushchenko
0 siblings, 0 replies; 10+ messages in thread
From: Oleksandr Andrushchenko @ 2019-07-01 5:46 UTC (permalink / raw)
To: Takashi Iwai, Colin King
Cc: alsa-devel, Oleksandr Andrushchenko, kernel-janitors,
linux-kernel, Jaroslav Kysela, xen-devel
On 6/28/19 11:46 AM, Takashi Iwai wrote:
> On Thu, 27 Jun 2019 18:58:53 +0200,
> Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Shifting the integer value 1 is evaluated using 32-bit
>> arithmetic and then used in an expression that expects a 64-bit
>> value, so there is potentially an integer overflow. Fix this
>> by using the BIT_ULL macro to perform the shift.
>>
>> Addresses-Coverity: ("Unintentional integer overflow")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thank you for you patch,
Oleksandr
> The fix is correct, but luckily we didn't hit the integer overflow, as
> all passed values are less than 32bit.
>
> In anyway, applied now. Thanks.
>
>
> Takashi
>
>> ---
>> sound/xen/xen_snd_front_alsa.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
>> index b14ab512c2ce..e01631959ed8 100644
>> --- a/sound/xen/xen_snd_front_alsa.c
>> +++ b/sound/xen/xen_snd_front_alsa.c
>> @@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
>> mask = 0;
>> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
>> if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
>> - mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif;
>> + mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
>>
>> return mask;
>> }
>> @@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
>>
>> mask = 0;
>> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
>> - if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats)
>> + if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
>> mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
>>
>> return mask;
>> --
>> 2.20.1
>>
>>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Xen-devel] [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts
@ 2019-07-01 5:46 ` Oleksandr Andrushchenko
0 siblings, 0 replies; 10+ messages in thread
From: Oleksandr Andrushchenko @ 2019-07-01 5:46 UTC (permalink / raw)
To: Takashi Iwai, Colin King
Cc: alsa-devel, Oleksandr Andrushchenko, kernel-janitors,
linux-kernel, Jaroslav Kysela, xen-devel
On 6/28/19 11:46 AM, Takashi Iwai wrote:
> On Thu, 27 Jun 2019 18:58:53 +0200,
> Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Shifting the integer value 1 is evaluated using 32-bit
>> arithmetic and then used in an expression that expects a 64-bit
>> value, so there is potentially an integer overflow. Fix this
>> by using the BIT_ULL macro to perform the shift.
>>
>> Addresses-Coverity: ("Unintentional integer overflow")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thank you for you patch,
Oleksandr
> The fix is correct, but luckily we didn't hit the integer overflow, as
> all passed values are less than 32bit.
>
> In anyway, applied now. Thanks.
>
>
> Takashi
>
>> ---
>> sound/xen/xen_snd_front_alsa.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
>> index b14ab512c2ce..e01631959ed8 100644
>> --- a/sound/xen/xen_snd_front_alsa.c
>> +++ b/sound/xen/xen_snd_front_alsa.c
>> @@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
>> mask = 0;
>> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
>> if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
>> - mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif;
>> + mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
>>
>> return mask;
>> }
>> @@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
>>
>> mask = 0;
>> for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
>> - if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats)
>> + if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
>> mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
>>
>> return mask;
>> --
>> 2.20.1
>>
>>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-07-01 5:46 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-27 16:58 [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts Colin King
2019-06-27 16:58 ` [Xen-devel] " Colin King
2019-06-27 16:58 ` Colin King
2019-06-28 8:46 ` Takashi Iwai
2019-06-28 8:46 ` [Xen-devel] " Takashi Iwai
2019-06-28 8:46 ` Takashi Iwai
2019-06-28 8:46 ` Takashi Iwai
2019-07-01 5:46 ` [Xen-devel] " Oleksandr Andrushchenko
2019-07-01 5:46 ` Oleksandr Andrushchenko
2019-07-01 5:46 ` Oleksandr Andrushchenko
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.