mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Louis Langholtz <lou_langholtz@me.com>
To: linux-kernel@vger.kernel.org
Cc: Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH] include/linux: avoid narrowing length parameter values
Date: Mon, 18 May 2015 09:33:10 -0600	[thread overview]
Message-ID: <45D183F5-DFCC-4FBF-833E-E738E098CF1D@me.com> (raw)

memcpy_from_msg() and memcpy_to_msg() functions previously called
memcpy_fromiovec() and memcpy_toiovec() functions respectively. The
memcpy_fromiovec() and memcpy_toiovec() functions took a length parameter
of type int. memcpy_from_msg() and memcpy_to_msg() now call
copy_from_iter() and copy_to_iter() functions respectively which take a length
parameter of type size_t. Most code calling the memcpy_from_msg() and
memcpy_to_msg() functions currently pass a length value of type size_t.
This patch updates the memcpy_from_msg() and memcpy_to_msg() functions
concordantly to take the length parameter of type size_t. This also avoids a potential
for data narrowing.

Signed-off-by: Louis Langholtz <lou_langholtz@me.com>
--

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 45e0aa6..ee590fb 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2708,12 +2708,12 @@ int skb_ensure_writable(struct sk_buff *skb, int write_len);
 int skb_vlan_pop(struct sk_buff *skb);
 int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);
 
-static inline int memcpy_from_msg(void *data, struct msghdr *msg, int len)
+static inline int memcpy_from_msg(void *data, struct msghdr *msg, size_t len)
 {
        return copy_from_iter(data, len, &msg->msg_iter) == len ? 0 : -EFAULT;
 }
 
-static inline int memcpy_to_msg(struct msghdr *msg, void *data, int len)
+static inline int memcpy_to_msg(struct msghdr *msg, void *data, size_t len)
 {
        return copy_to_iter(data, len, &msg->msg_iter) == len ? 0 : -EFAULT;
 }


             reply	other threads:[~2015-05-18 15:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 15:33 Louis Langholtz [this message]
2015-05-18 15:56 ` Al Viro
2015-05-18 20:43   ` Louis Langholtz

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=45D183F5-DFCC-4FBF-833E-E738E098CF1D@me.com \
    --to=lou_langholtz@me.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®