All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: Jean Delvare <jdelvare@suse.de>
Cc: Linux I2C <linux-i2c@vger.kernel.org>
Subject: Re: [PATCH 3/3] i2ctransfer: Zero out memory passed to ioctl()
Date: Mon, 19 May 2025 17:36:53 +0200	[thread overview]
Message-ID: <aCtQFfPvGJuVN1tv@shikoro> (raw)
In-Reply-To: <20250513173539.39952965@endymion>

[-- Attachment #1: Type: text/plain, Size: 1226 bytes --]

On Tue, May 13, 2025 at 05:35:39PM +0200, Jean Delvare wrote:
> Valgrind complains that uninitialized memory may be passed to
> ioctl():
> 
> == Syscall param ioctl(I2C_RDWR) points to uninitialised byte(s)
> ==    at 0x499382B: ioctl (in /lib64/libc.so.6)
> ==    by 0x401957: main (i2ctransfer.c:343)
> ==  Address 0x1ffefff94c is on thread 1's stack
> ==  in frame #1, created by main (i2ctransfer.c:144)
> == 
> == Syscall param ioctl(I2C_RDWR).msgs points to uninitialised byte(s)
> ==    at 0x499382B: ioctl (in /lib64/libc.so.6)
> ==    by 0x401957: main (i2ctransfer.c:343)
> ==  Address 0x1ffefff956 is on thread 1's stack
> ==  in frame #1, created by main (i2ctransfer.c:144)
> 
> Zero out the i2c_rdwr_ioctl_data struct as well as the msgs array to
> guarantee that no uninitialized memory will ever be passed to the
> kernel.
> 
> Signed-off-by: Jean Delvare <jdelvare@suse.de>

Applied, thanks!

> This one is not strictly needed, I can't see any actual bug. However
> making valgrind happy seems to be a sane goal, so that we can keep
> using it when debugging other issues without getting distracted.
> Wolfram, what do you think?

Sure, I agree. Also, I like the simpler code.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2025-05-19 15:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-13 15:21 [PATCH 1/3] i2ctransfer: Don't free memory which was never allocated Jean Delvare
2025-05-13 15:23 ` [PATCH 2/3] i2ctransfer: Prevent msgs[] overflow with many parameters Jean Delvare
2025-05-19 15:35   ` Wolfram Sang
2025-05-13 15:35 ` [PATCH 3/3] i2ctransfer: Zero out memory passed to ioctl() Jean Delvare
2025-05-19 15:36   ` Wolfram Sang [this message]
2025-05-19 15:31 ` [PATCH 1/3] i2ctransfer: Don't free memory which was never allocated Wolfram Sang

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=aCtQFfPvGJuVN1tv@shikoro \
    --to=wsa+renesas@sang-engineering.com \
    --cc=jdelvare@suse.de \
    --cc=linux-i2c@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.