lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 24 Apr 2019 11:49:37 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Nathan Chancellor <natechancellor@...il.com>
Cc:     Andreas Noever <andreas.noever@...il.com>,
        Michael Jamet <michael.jamet@...el.com>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>,
        Yehezkel Bernat <YehezkelShB@...il.com>,
        LKML <linux-kernel@...r.kernel.org>,
        clang-built-linux@...glegroups.com
Subject: Re: [PATCH] thunderbolt: Make priority unsigned in struct tb_path

On Wed, Apr 24, 2019 at 11:34 AM Nathan Chancellor
<natechancellor@...il.com> wrote:
>
> Clang warns:
>
> drivers/thunderbolt/tunnel.c:504:17: warning: implicit truncation from
> 'int' to bit-field changes value from 5 to -3
> [-Wbitfield-constant-conversion]
>         path->priority = 5;
>                        ^ ~
> 1 warning generated.
>
> The priority member in struct tb_path is only ever assigned a positive
> number:
>
> $ rg -n priority drivers/thunderbolt/path.c
> drivers/thunderbolt/tunnel.c:99:        path->priority = 3;
> drivers/thunderbolt/tunnel.c:308:       path->priority = 2;
> drivers/thunderbolt/tunnel.c:323:       path->priority = 1;
> drivers/thunderbolt/tunnel.c:504:       path->priority = 5;

LGTM.  Looks like drivers/thunderbolt/tb_regs.h also defines it as u32
(no change needed here).
Triple checking it's uses, looks like it gets assigned:
drivers/thunderbolt/path.c#L492:
hop.priority = path->priority;
hop is an instance of a struct tb_regs_hop, which is the definition I
was looking at above.  LGTM thanks Nathan!
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>

>
> Furthmore, that value is only assigned to an unsigned integer in
> tb_path_activate (the priority member in struct tb_regs_hop).
>
> Fixes: 44242d6c9703 ("thunderbolt: Add support for DMA tunnels")
> Link: https://github.com/ClangBuiltLinux/linux/issues/454
> Signed-off-by: Nathan Chancellor <natechancellor@...il.com>
> ---
>  drivers/thunderbolt/tb.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
> index 15d225dcb403..b12c8f33d89c 100644
> --- a/drivers/thunderbolt/tb.h
> +++ b/drivers/thunderbolt/tb.h
> @@ -225,7 +225,7 @@ struct tb_path {
>         enum tb_path_port ingress_fc_enable;
>         enum tb_path_port egress_fc_enable;
>
> -       int priority:3;
> +       unsigned int priority:3;
>         int weight:4;
>         bool drop_packages;
>         bool activated;
> --
> 2.21.0
>


-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ