netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Bernat, Yehezkel" <yehezkel.bernat@intel.com>
To: "dan.carpenter@oracle.com" <dan.carpenter@oracle.com>,
	"Jamet, Michael" <michael.jamet@intel.com>,
	"Levy, Amir (Jer)" <amir.jer.levy@intel.com>
Cc: "mika.westerberg@linux.intel.com"
	<mika.westerberg@linux.intel.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH 2/2 net-next] thunderbolt: Right shifting to zero bug in tbnet_handle_packet()
Date: Tue, 17 Oct 2017 13:17:30 +0000	[thread overview]
Message-ID: <1508246223.3477.28.camel@intel.com> (raw)
In-Reply-To: <20171017123301.z6heqexdlo6lc52b@mwanda>

On Tue, 2017-10-17 at 15:33 +0300, Dan Carpenter wrote:
> There is a problem when we do:
> 
> 	sequence = pkg->hdr.length_sn & TBIP_HDR_SN_MASK;
> 	sequence >>= TBIP_HDR_SN_SHIFT;
> 
> TBIP_HDR_SN_SHIFT is 27, and right shifting a u8 27 bits is always
> going to result in zero.  The fix is to declare these variables as
> u32.
> 
> Fixes: e69b6c02b4c3 ("net: Add support for networking over
> Thunderbolt cable")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c
> index 1a7bc0bf4598..435854688a7a 100644
> --- a/drivers/net/thunderbolt.c
> +++ b/drivers/net/thunderbolt.c
> @@ -394,7 +394,7 @@ static int tbnet_handle_packet(const void *buf,
> size_t size, void *data)
>  	struct tbnet *net = data;
>  	u32 command_id;
>  	int ret = 0;
> -	u8 sequence;
> +	u32 sequence;
>  	u64 route;
>  
>  	/* Make sure the packet is for us */

Acked-by: Yehezkel Bernat <yehezkel.bernat@intel.com>

Thanks!

  reply	other threads:[~2017-10-17 13:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20171013112959.sc2pwazrpk7fxbtw@mwanda>
2017-10-17 12:32 ` [PATCH 1/2 v2 net-next] thunderbolt: Fix a couple right shifting to zero bugs Dan Carpenter
2017-10-19 12:04   ` David Miller
2017-10-17 12:33 ` [PATCH 2/2 net-next] thunderbolt: Right shifting to zero bug in tbnet_handle_packet() Dan Carpenter
2017-10-17 13:17   ` Bernat, Yehezkel [this message]
2017-10-19 12:05   ` David Miller

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=1508246223.3477.28.camel@intel.com \
    --to=yehezkel.bernat@intel.com \
    --cc=amir.jer.levy@intel.com \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=michael.jamet@intel.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).