Bug 857948 - Usage of partial unitialized structure in call to sendmsg
Usage of partial unitialized structure in call to sendmsg
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Roman Rakus
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2012-09-17 10:57 EDT by Mark Wielaard
Modified: 2014-01-12 19:14 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-02-07 21:18:01 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Mark Wielaard 2012-09-17 10:57:17 EDT
Description of problem:

bash uses a partial uninitialized structure passed to the sendmsg syscall.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. run valgrind -q bash
2. exit
Actual results:

==3332== Syscall param socketcall.sendmsg(msg.msg_name) points to uninitialised byte(s)
==3332==    at 0x5563200: __sendmsg_nocancel (syscall-template.S:82)
==3332==    by 0x489A77: readline (readline.c:346)
==3332==    by 0x41E5AB: yy_readline_get (parse.y:1443)
==3332==    by 0x4204F8: shell_getc (parse.y:1376)
==3332==    by 0x422E95: read_token.constprop.8 (parse.y:2908)
==3332==    by 0x4258BF: yyparse (parse.y:2517)
==3332==    by 0x41DE69: parse_command (eval.c:229)
==3332==    by 0x41DF35: read_command (eval.c:273)
==3332==    by 0x41E182: reader_loop (eval.c:138)
==3332==    by 0x41C8EE: main (shell.c:759)
==3332==  Address 0x7feffece2 is on thread 1's stack

Expected results:

No output from valgrind.

Additional info:

Valgrind is right that there is uninitialized data used in the sendmsg syscall. When using nl_family = AF_NETLINK the nl_pad field should be initialized to zero and it isn't. This is unlikely to cause real problems in practice since this field is currently unused. But in the unlikely event that field does get used in the future it could be an issue that it isn't explicitly set to zero. Also it makes valgrind happy :)

It looks like the audit.patch is fedora local and not upstream. If it is already upstream please do let me know and I'll post patch there.

Patch (against the audit patch) is simple:

index 8de4980..f0e0ec4 100644
--- a/bash-3.2-audit.patch
+++ b/bash-3.2-audit.patch
@@ -44,7 +44,7 @@ diff -up bash-4.0/lib/readline/readline.c.audit bash-4.0/lib/r
  /* System-specific feature definitions and include files. */
  #include "rldefs.h"
  #include "rlmbutil.h"
-@@ -297,7 +303,47 @@ rl_set_prompt (prompt)
+@@ -297,7 +303,48 @@ rl_set_prompt (prompt)
    rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
    return 0;
@@ -76,6 +76,7 @@ diff -up bash-4.0/lib/readline/readline.c.audit bash-4.0/lib/r
 +  iov[1].iov_base = string;
 +  iov[1].iov_len = size;
 +  addr.nl_family = AF_NETLINK;
++  addr.nl_pad = 0;
 +  addr.nl_pid = 0;
 +  addr.nl_groups = 0;
 +  msg.msg_name = &addr;
Comment 1 Roman Rakus 2012-09-18 05:35:25 EDT
Thanks for the report.
You're right, that patch is local. I will check and apply your patch. Thanks.
Comment 2 Fedora Update System 2013-02-01 07:54:46 EST
bash-4.2.42-3.fc18 has been submitted as an update for Fedora 18.
Comment 3 Fedora Update System 2013-02-01 23:31:12 EST
Package bash-4.2.42-3.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing bash-4.2.42-3.fc18'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).
Comment 4 Fedora Update System 2013-02-07 21:18:02 EST
bash-4.2.42-3.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.