public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/char/ipmi: memcpy, need additional 2 bytes to avoid memory overflow
@ 2013-03-29  7:18 Chen Gang
  2013-03-29 13:51 ` Corey Minyard
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Gang @ 2013-03-29  7:18 UTC (permalink / raw)
  To: minyard; +Cc: Greg KH, openipmi-developer, linux-kernel@vger.kernel.org


  when calling memcpy, read_data and write_data need additional 2 bytes.

  write_data:
    for checking:  "if (size > IPMI_MAX_MSG_LENGTH)" 
    for operating: "memcpy(bt->write_data + 3, data + 1, size - 1)"

  read_data:
    for checking:  "if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH)"
    for operating: "memcpy(data + 2, bt->read_data + 4, msg_len - 2)"


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 drivers/char/ipmi/ipmi_bt_sm.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
index cdd4c09f..a22a7a5 100644
--- a/drivers/char/ipmi/ipmi_bt_sm.c
+++ b/drivers/char/ipmi/ipmi_bt_sm.c
@@ -95,9 +95,9 @@ struct si_sm_data {
 	enum bt_states	state;
 	unsigned char	seq;		/* BT sequence number */
 	struct si_sm_io	*io;
-	unsigned char	write_data[IPMI_MAX_MSG_LENGTH];
+	unsigned char	write_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */
 	int		write_count;
-	unsigned char	read_data[IPMI_MAX_MSG_LENGTH];
+	unsigned char	read_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */
 	int		read_count;
 	int		truncated;
 	long		timeout;	/* microseconds countdown */
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/char/ipmi: memcpy, need additional 2 bytes to avoid memory overflow
  2013-03-29  7:18 [PATCH] drivers/char/ipmi: memcpy, need additional 2 bytes to avoid memory overflow Chen Gang
@ 2013-03-29 13:51 ` Corey Minyard
  2013-03-30  2:55   ` Chen Gang
  0 siblings, 1 reply; 3+ messages in thread
From: Corey Minyard @ 2013-03-29 13:51 UTC (permalink / raw)
  To: Chen Gang; +Cc: Greg KH, openipmi-developer, linux-kernel@vger.kernel.org

Yes, this is correct, I've pulled it into my tree.

-corey

On 03/29/2013 02:18 AM, Chen Gang wrote:
>    when calling memcpy, read_data and write_data need additional 2 bytes.
>
>    write_data:
>      for checking:  "if (size > IPMI_MAX_MSG_LENGTH)"
>      for operating: "memcpy(bt->write_data + 3, data + 1, size - 1)"
>
>    read_data:
>      for checking:  "if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH)"
>      for operating: "memcpy(data + 2, bt->read_data + 4, msg_len - 2)"
>
>
> Signed-off-by: Chen Gang <gang.chen@asianux.com>
> ---
>   drivers/char/ipmi/ipmi_bt_sm.c |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
> index cdd4c09f..a22a7a5 100644
> --- a/drivers/char/ipmi/ipmi_bt_sm.c
> +++ b/drivers/char/ipmi/ipmi_bt_sm.c
> @@ -95,9 +95,9 @@ struct si_sm_data {
>   	enum bt_states	state;
>   	unsigned char	seq;		/* BT sequence number */
>   	struct si_sm_io	*io;
> -	unsigned char	write_data[IPMI_MAX_MSG_LENGTH];
> +	unsigned char	write_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */
>   	int		write_count;
> -	unsigned char	read_data[IPMI_MAX_MSG_LENGTH];
> +	unsigned char	read_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */
>   	int		read_count;
>   	int		truncated;
>   	long		timeout;	/* microseconds countdown */


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/char/ipmi: memcpy, need additional 2 bytes to avoid memory overflow
  2013-03-29 13:51 ` Corey Minyard
@ 2013-03-30  2:55   ` Chen Gang
  0 siblings, 0 replies; 3+ messages in thread
From: Chen Gang @ 2013-03-30  2:55 UTC (permalink / raw)
  To: minyard
  Cc: Corey Minyard, Greg KH, openipmi-developer,
	linux-kernel@vger.kernel.org

On 2013年03月29日 21:51, Corey Minyard wrote:
> Yes, this is correct, I've pulled it into my tree.

  thanks.

  :-)

-- 
Chen Gang

Asianux Corporation

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-30  2:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-29  7:18 [PATCH] drivers/char/ipmi: memcpy, need additional 2 bytes to avoid memory overflow Chen Gang
2013-03-29 13:51 ` Corey Minyard
2013-03-30  2:55   ` Chen Gang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox