Linux Container Development
 help / color / mirror / Atom feed
From: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
To: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH 1/2] Avoid memcpy overruns in fill|load_sigset()
Date: Mon, 16 Nov 2009 13:43:21 -0500	[thread overview]
Message-ID: <4B019D49.7040603@cs.columbia.edu> (raw)
In-Reply-To: <41033d2ce4f31d016400bde1c5d393ae6f6b856a.1258153503.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>


struct ckpt_sigset is defined to match the size of sigset_t.
Compilation should fail if it does not. Am I missing something ?

Oren.


Matt Helsley wrote:
> Only copy the minimum size of the two structs. I believe gcc
> will recognize that these are constants so the resulting code
> should be the same size and just as fast.
> 
> Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> ---
>  checkpoint/signal.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/checkpoint/signal.c b/checkpoint/signal.c
> index 989b974..c65ee00 100644
> --- a/checkpoint/signal.c
> +++ b/checkpoint/signal.c
> @@ -22,12 +22,12 @@
>  
>  static inline void fill_sigset(struct ckpt_sigset *h, sigset_t *sigset)
>  {
> -	memcpy(&h->sigset, sigset, sizeof(*sigset));
> +	memcpy(&h->sigset, sigset, min(sizeof(*h), sizeof(*sigset)));
>  }
>  
>  static inline void load_sigset(sigset_t *sigset, struct ckpt_sigset *h)
>  {
> -	memcpy(sigset, &h->sigset, sizeof(*sigset));
> +	memcpy(sigset, &h->sigset, min(sizeof(*h), sizeof(*sigset)));
>  }
>  
>  /***********************************************************************

  parent reply	other threads:[~2009-11-16 18:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-13 23:05 [PATCH 1/2] Avoid memcpy overruns in fill|load_sigset() Matt Helsley
     [not found] ` <41033d2ce4f31d016400bde1c5d393ae6f6b856a.1258153503.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-13 23:05   ` [PATCH 2/2] [RFC] checkpoint/restart signalfd Matt Helsley
     [not found]     ` <aa65242a98bf851a1d8432dd21850391c91607cf.1258153503.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-16  4:01       ` Matt Helsley
     [not found]         ` <20091116040129.GJ891-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-11-16 18:46           ` Oren Laadan
2009-11-16 18:43   ` Oren Laadan [this message]
     [not found]     ` <4B019D49.7040603-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2009-11-17 22:45       ` [PATCH 1/2] Avoid memcpy overruns in fill|load_sigset() Matt Helsley

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=4B019D49.7040603@cs.columbia.edu \
    --to=orenl-eqauephvms7envbuuze7ea@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=matthltc-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