public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: manish.rangankar@qlogic.com
Cc: Mike Christie <michaelc@cs.wisc.edu>,
	open-iscsi@googlegroups.com, linux-kernel@vger.kernel.org
Subject: re: [SCSI] qla4xxx: support iscsiadm session mgmt
Date: Thu, 14 Jun 2012 21:27:45 +0300	[thread overview]
Message-ID: <20120614182745.GA6383@elgon.mountain> (raw)

Hi Manish,

The patch b3a271a94d00: "[SCSI] qla4xxx: support iscsiadm session 
mgmt" from Jul 25, 2011, leads to the following warning:
drivers/scsi/qla4xxx/ql4_os.c:4479 qla4xxx_get_ep_fwdb()
	 warn: casting from 16 to 28 bytes

(Sort of).

drivers/scsi/qla4xxx/ql4_os.c qla4xxx_ep_connect()
   705          qla_ep = ep->dd_data;
   706          memset(qla_ep, 0, sizeof(struct qla_endpoint));
   707          if (dst_addr->sa_family == AF_INET) {
   708                  memcpy(&qla_ep->dst_addr, dst_addr, sizeof(struct sockaddr_in));
   709                  addr = (struct sockaddr_in *)&qla_ep->dst_addr;
   710                  DEBUG2(ql4_printk(KERN_INFO, ha, "%s: %pI4\n", __func__,
   711                                    (char *)&addr->sin_addr));
   712          } else if (dst_addr->sa_family == AF_INET6) {
   713                  memcpy(&qla_ep->dst_addr, dst_addr,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   714                         sizeof(struct sockaddr_in6));
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Both qla_ep->dst_addr and dst_addr are type struct sockaddr.  We are
copying sizeof(struct sockaddr_in6) bytes which is 12 bytes larger.  I
don't know the actual size of qla_ep->dst_addr but dst_addr is allocated
in qla4xxx_get_ep_fwdb() as a struct sockaddr.  So we are copying past
the end of the struct here and it's possibly an information leak or even
a memory corruption issue depending on how much space ep->dd_data has.

   715                  addr6 = (struct sockaddr_in6 *)&qla_ep->dst_addr;
   716                  DEBUG2(ql4_printk(KERN_INFO, ha, "%s: %pI6\n", __func__,
   717                                    (char *)&addr6->sin6_addr));
   718          }

regards,
dan carpenter


             reply	other threads:[~2012-06-14 18:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14 18:27 Dan Carpenter [this message]
2012-08-08 15:00 ` [SCSI] qla4xxx: support iscsiadm session mgmt Dan Carpenter
2012-08-08 15:35   ` Mike Christie
2012-08-08 16:57     ` Dan Carpenter
2012-08-09 17:49       ` Michael Christie

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=20120614182745.GA6383@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manish.rangankar@qlogic.com \
    --cc=michaelc@cs.wisc.edu \
    --cc=open-iscsi@googlegroups.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