Bug 857948

Summary: Usage of partial unitialized structure in call to sendmsg
Product: [Fedora] Fedora Reporter: Mark Wielaard <mjw>
Component: bashAssignee: Roman Rakus <rrakus>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 18CC: maxamillion, ooprala, rrakus, tsmetana
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-08 02:18:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mark Wielaard 2012-09-17 14:57:17 UTC
Description of problem:

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

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

bash-4.2.37-3.fc18.x86_64

How reproducible:

Always

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
==3332== 

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 09:35:25 UTC
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 12:54:46 UTC
bash-4.2.42-3.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/bash-4.2.42-3.fc18

Comment 3 Fedora Update System 2013-02-02 04:31:12 UTC
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:
https://admin.fedoraproject.org/updates/FEDORA-2013-1868/bash-4.2.42-3.fc18
then log in and leave karma (feedback).

Comment 4 Fedora Update System 2013-02-08 02:18:02 UTC
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.