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:   Tue, 30 Jul 2019 10:07:49 -0700
From:   Kees Cook <keescook@...omium.org>
To:     Michael Ellerman <mpe@...erman.id.au>
Cc:     Stephen Rothwell <sfr@...b.auug.org.au>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        PowerPC <linuxppc-dev@...ts.ozlabs.org>,
        "Gustavo A. R. Silva" <gustavo@...eddedor.com>,
        Linux kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drivers/macintosh/smu.c: Mark expected switch
 fall-through

On Wed, Jul 31, 2019 at 12:28:55AM +1000, Michael Ellerman wrote:
> Stephen Rothwell <sfr@...b.auug.org.au> writes:
> > Mark switch cases where we are expecting to fall through.
> >
> > This patch fixes the following warning (Building: powerpc):
> >
> > drivers/macintosh/smu.c: In function 'smu_queue_i2c':
> > drivers/macintosh/smu.c:854:21: warning: this statement may fall through [-Wimplicit-fallthrough=]
> >    cmd->info.devaddr &= 0xfe;
> >    ~~~~~~~~~~~~~~~~~~^~~~~~~
> > drivers/macintosh/smu.c:855:2: note: here
> >   case SMU_I2C_TRANSFER_STDSUB:
> >   ^~~~
> >
> > Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
> > Cc: Gustavo A. R. Silva <gustavo@...eddedor.com>
> > Cc: Kees Cook <keescook@...omium.org>
> > Signed-off-by: Stephen Rothwell <sfr@...b.auug.org.au>
> > ---
> >  drivers/macintosh/smu.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
> > index 276065c888bc..23f1f41c8602 100644
> > --- a/drivers/macintosh/smu.c
> > +++ b/drivers/macintosh/smu.c
> > @@ -852,6 +852,7 @@ int smu_queue_i2c(struct smu_i2c_cmd *cmd)
> >  		break;
> >  	case SMU_I2C_TRANSFER_COMBINED:
> >  		cmd->info.devaddr &= 0xfe;
> > +		/* fall through */
> >  	case SMU_I2C_TRANSFER_STDSUB:
> >  		if (cmd->info.sublen > 3)
> >  			return -EINVAL;
> 
> Why do we think it's an expected fall through? I can't really convince
> myself from the surrounding code that it's definitely intentional.

Yeah, good question. Just now when I went looking for who
used SMU_I2C_TRANSFER_COMBINED, I found the only caller in
arch/powerpc/platforms/powermac/low_i2c.c and it is clearly using a
fall-through for building the command for "stdsub" and "combined",
so I think that's justification enough:

        switch(bus->mode) {
        case pmac_i2c_mode_std:
                if (subsize != 0)
                        return -EINVAL;
                cmd->info.type = SMU_I2C_TRANSFER_SIMPLE;
                break;
        case pmac_i2c_mode_stdsub:
        case pmac_i2c_mode_combined:
                if (subsize > 3 || subsize < 1)
                        return -EINVAL;
                cmd->info.sublen = subsize;
                /* that's big-endian only but heh ! */
                memcpy(&cmd->info.subaddr, ((char *)&subaddr) + (4 - subsize),
                       subsize);
                if (bus->mode == pmac_i2c_mode_stdsub)
                        cmd->info.type = SMU_I2C_TRANSFER_STDSUB;
                else
                        cmd->info.type = SMU_I2C_TRANSFER_COMBINED;


Reviewed-by: Kees Cook <keescook@...omium.org>

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ