netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: "Bjørn Mork" <bjorn@mork.no>, "Oliver Neukum" <oneukum@suse.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stern@rowland.harvard.edu, USB list <linux-usb@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Giuliano Belinassi <giuliano.belinassi@suse.com>
Subject: Re: malicious devices causing unaligned accesses [v2]
Date: Thu, 17 Feb 2022 11:35:10 +0100	[thread overview]
Message-ID: <0642f910-bccf-103c-c176-d77cc75e6a25@suse.com> (raw)
In-Reply-To: <87sfshaiuc.fsf@miraculix.mork.no>



On 17.02.22 11:27, Bjørn Mork wrote:
> Oliver Neukum <oneukum@suse.com> writes:
>
>> Hi,
>>
>> going through the USB network drivers looking for ways
>> a malicious device could do us harm I found drivers taking
>> the alignment coming from the device for granted.
>>
>> An example can be seen in qmi_wwan:
>>
>> while (offset + qmimux_hdr_sz < skb->len) {
>>     hdr = (struct qmimux_hdr*)(skb->data + offset);
>>     len = be16_to_cpu(hdr->pkt_len);
>>
>> As you can see the driver accesses stuff coming from the device with the
>> expectation
>> that it keep to natural alignment. On some architectures that is a way a
>> device could use to do bad things to a host. What is to be done about
>> that?
> We can deal with this the same way we deal with hostile hot-plugged CPUs
> or memory modules.
Yes. That is a basic decision that needs to be made
> Yes, the aligment should probably be verified.  But there are so many
> ways a hostile network adapter can mess with us than I don't buy the
> "malicious device" argument...
Sure, so what is the level of damage that is acceptable?
>
> FWIW, the more recent rmnet demuxing implementation from Qualcomm seems
> to suffer from the same problem.
>
>
> struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
> 				      struct rmnet_port *port)
> {
> 	struct rmnet_map_header *maph;
> 	struct sk_buff *skbn;
> 	u32 packet_len;
>
> 	if (skb->len == 0)
> 		return NULL;
>
> 	maph = (struct rmnet_map_header *)skb->data;
> 	packet_len = ntohs(maph->pkt_len) + sizeof(struct rmnet_map_header);
>
>
> (this implementation moves skb->data by packet_len instead of doing the
> offset calculation, but I don't think that makes any difference?)
>
> I guess there is no alignment guarantee here, whether the device is
> malicious or not. So we probably have to deal with unaligned accesses to
> maph/hdr->pkt_len?
Yes, as far as I can tell a device is fully in spec if it sends frames as
tightly packed as possible, so this is simply a bug, not a security issue.

    Regards
        Oliver


      reply	other threads:[~2022-02-17 10:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17  8:46 malicious devices causing unaligned accesses [v2] Oliver Neukum
2022-02-17 10:27 ` Bjørn Mork
2022-02-17 10:35   ` Oliver Neukum [this message]

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=0642f910-bccf-103c-c176-d77cc75e6a25@suse.com \
    --to=oneukum@suse.com \
    --cc=bjorn@mork.no \
    --cc=giuliano.belinassi@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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).