netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: jmarchan@redhat.com
Cc: manish.chopra@cavium.com, rahul.verma@cavium.com,
	Dept-GELinuxNICDev@cavium.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] netxen_nic: null-terminate serial number string in netxen_check_options()
Date: Wed, 26 Apr 2017 14:38:26 -0400 (EDT)	[thread overview]
Message-ID: <20170426.143826.1046934906391756246.davem@davemloft.net> (raw)
In-Reply-To: <20170425074229.28267-1-jmarchan@redhat.com>

From: "Jerome Marchand" <jmarchan@redhat.com>
Date: Tue, 25 Apr 2017 09:42:29 +0200

> The serial_num string in netxen_check_options() is not always properly
> null-terminated. I couldn't find the documention on the serial number
> format and I suspect a proper integer to string conversion is in
> order, but this patch a least prevents the out-of-bound access.
> 
> It solves the following kasan warning:
 ...
> @@ -842,7 +842,7 @@ netxen_check_options(struct netxen_adapter *adapter)
>  {
>  	u32 fw_major, fw_minor, fw_build, prev_fw_version;
>  	char brd_name[NETXEN_MAX_SHORT_NAME];
> -	char serial_num[32];
> +	char serial_num[33];
>  	int i, offset, val, err;
>  	__le32 *ptr32;
>  	struct pci_dev *pdev = adapter->pdev;

Another problem is that the serial_num array is only 4-byte aligned by
accident.  Steps are necessary to make sure the ptr32 assignments don't
take unaligned traps.

Something like:

	union {
		char buf[33];
		__le32 dummy;
	} serial_num;

      reply	other threads:[~2017-04-26 18:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-25  7:42 [RFC PATCH] netxen_nic: null-terminate serial number string in netxen_check_options() Jerome Marchand
2017-04-26 18:38 ` David Miller [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=20170426.143826.1046934906391756246.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=Dept-GELinuxNICDev@cavium.com \
    --cc=jmarchan@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manish.chopra@cavium.com \
    --cc=netdev@vger.kernel.org \
    --cc=rahul.verma@cavium.com \
    /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).