From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org
Subject: Re: [PATCH 3/4] Update the UNIX buffer restore code to match the new format saved in the image file
Date: Tue, 17 Nov 2009 22:39:20 -0600 [thread overview]
Message-ID: <20091118043920.GD19841@us.ibm.com> (raw)
In-Reply-To: <1258471590-29768-4-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Quoting Dan Smith (danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org):
> Signed-off-by: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> ---
> net/unix/checkpoint.c | 54 ++++++++++++++++++++++++++----------------------
> 1 files changed, 29 insertions(+), 25 deletions(-)
>
> diff --git a/net/unix/checkpoint.c b/net/unix/checkpoint.c
> index 749673d..c6a1b27 100644
> --- a/net/unix/checkpoint.c
> +++ b/net/unix/checkpoint.c
> @@ -201,7 +201,6 @@ static int sock_read_buffer_sendmsg(struct ckpt_ctx *ctx,
> uint8_t peer_shutdown = 0;
> void *buf = NULL;
> int sndbuf;
> - int len;
> int ret = 0;
>
> memset(&msg, 0, sizeof(msg));
> @@ -210,14 +209,30 @@ static int sock_read_buffer_sendmsg(struct ckpt_ctx *ctx,
> if (IS_ERR(h))
> return PTR_ERR(h);
>
> - len = _ckpt_read_obj_type(ctx, NULL, 0, CKPT_HDR_BUFFER);
> - if (len < 0) {
> - ret = len;
> + if (h->lin_len > SKB_MAX_ALLOC) {
> + ckpt_debug("socket buffer too big (%u > %lu)\n",
> + h->lin_len, SKB_MAX_ALLOC);
> + ret = -EINVAL;
> + goto out;
> + } else if (h->nr_frags != 0) {
> + ckpt_debug("unix socket claims to have fragments\n");
> + ret = -EINVAL;
> goto out;
> - } else if (len > SKB_MAX_ALLOC) {
> - ckpt_debug("Socket buffer too big (%i > %lu)",
> - len, SKB_MAX_ALLOC);
> - ret = -ENOSPC;
> + }
> +
> + buf = kmalloc(h->lin_len, GFP_KERNEL);
> + if (!buf) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + kvec.iov_len = h->lin_len;
> + kvec.iov_base = buf;
> + ret = _ckpt_read_obj_type(ctx, kvec.iov_base,
> + h->lin_len, CKPT_HDR_BUFFER);
> + ckpt_debug("read unix socket buffer %u: %i\n", h->lin_len, ret);
> + if (ret < h->lin_len) {
> + ret = -EINVAL;
> goto out;
> }
>
> @@ -246,18 +261,6 @@ static int sock_read_buffer_sendmsg(struct ckpt_ctx *ctx,
> }
> }
>
> - kvec.iov_len = len;
> - buf = kmalloc(len, GFP_KERNEL);
> - kvec.iov_base = buf;
> - if (!buf) {
> - ret = -ENOMEM;
> - goto out;
> - }
> -
> - ret = ckpt_kread(ctx, kvec.iov_base, len);
> - if (ret < 0)
> - goto out;
> -
> msg.msg_name = addr;
> msg.msg_namelen = addrlen;
>
> @@ -273,15 +276,16 @@ static int sock_read_buffer_sendmsg(struct ckpt_ctx *ctx,
>
> /* Make sure there's room in the send buffer */
> sndbuf = sk->sk_sndbuf;
> - if (((sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc)) < len) &&
> + if (((sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc)) < h->lin_len) &&
> capable(CAP_NET_ADMIN))
> - sk->sk_sndbuf += len;
> + sk->sk_sndbuf += h->lin_len;
> else
> sk->sk_sndbuf = sysctl_wmem_max;
Again, should you check whether h->len_len < sysctl_wmem_max before doing
the capable(CAP_NET_ADMIN)? The goal is to prevent setting PF_SUPERPRIV
in task->flags if it wasn't absolutely necessary.
>
> - ret = kernel_sendmsg(sk->sk_socket, &msg, &kvec, 1, len);
> - ckpt_debug("kernel_sendmsg(%i,%i): %i\n", h->sk_objref, len, ret);
> - if ((ret > 0) && (ret != len))
> + ret = kernel_sendmsg(sk->sk_socket, &msg, &kvec, 1, h->lin_len);
> + ckpt_debug("kernel_sendmsg(%i,%u): %i\n",
> + h->sk_objref, h->lin_len, ret);
> + if ((ret > 0) && (ret != h->lin_len))
> ret = -ENOMEM;
>
> sk->sk_sndbuf = sndbuf;
> --
> 1.6.2.5
>
> _______________________________________________
> Containers mailing list
> Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
next prev parent reply other threads:[~2009-11-18 4:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-17 15:26 Add support for connected INET sockets Dan Smith
2009-11-17 15:26 ` [PATCH 2/4] [RFC] Add c/r support for connected INET sockets (v5) Dan Smith
2009-11-18 4:34 ` Serge E. Hallyn
[not found] ` <1258471590-29768-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-17 15:26 ` [PATCH 1/4] Unify skb read/write functions and fix for fragmented buffers (v2) Dan Smith
[not found] ` <1258471590-29768-2-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-18 4:34 ` Serge E. Hallyn
2009-11-17 15:26 ` [PATCH 3/4] Update the UNIX buffer restore code to match the new format saved in the image file Dan Smith
[not found] ` <1258471590-29768-4-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-18 4:39 ` Serge E. Hallyn [this message]
[not found] ` <20091118043920.GD19841-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-18 14:28 ` Dan Smith
[not found] ` <876397vrf1.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-11-18 15:16 ` Serge E. Hallyn
2009-11-17 15:26 ` [PATCH 4/4] Add some content to the readme.txt for socket c/r Dan Smith
2009-11-25 18:51 ` Add support for connected INET sockets Oren Laadan
-- strict thread matches above, loose matches on Subject: below --
2009-11-10 18:47 Dan Smith
[not found] ` <1257878856-25520-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-10 18:47 ` [PATCH 3/4] Update the UNIX buffer restore code to match the new format saved in the image file Dan Smith
[not found] ` <1257878856-25520-4-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-11 21:38 ` Serge E. Hallyn
[not found] ` <20091111213851.GE8761-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-11 21:57 ` Dan Smith
[not found] ` <87vdhgvi6b.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-11-12 2:18 ` Serge E. Hallyn
[not found] ` <20091112021824.GA14646-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-12 18:19 ` Dan Smith
[not found] ` <87k4xvvc5b.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-11-12 19:43 ` Serge E. Hallyn
2009-11-16 18:35 ` Oren Laadan
2009-11-11 21:40 ` Serge E. Hallyn
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=20091118043920.GD19841@us.ibm.com \
--to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.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