Bug 1734057

Summary: automount segfaults if a bad hosts entry is added in /etc/auto.master
Product: Red Hat Enterprise Linux 7 Reporter: Kenneth D'souza <kdsouza>
Component: autofsAssignee: Ian Kent <ikent>
Status: CLOSED ERRATA QA Contact: Kun Wang <kunwan>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.6CC: fsorenso, xzhou
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: autofs-5.0.7-107.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-31 20:00:35 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:
Attachments:
Description Flags
Patch - fix reset flex scan buffer on init none

Description Kenneth D'souza 2019-07-29 14:27:06 UTC
Description of problem:
automount segfaults if a bad hosts entry is added in /etc/auto.master

Version-Release number of selected component (if applicable):
# rpm -q autofs
autofs-5.0.7-99.el7.x86_64

How reproducible:
always 

Steps to Reproduce:
1. Add a bad entry in /etc/auto/master like below

# grep -v ^# /etc/auto.master  | grep -i hosts
/net	-hosts
@ -hosts  <---------------

2. Trigger a crash by running automount -m or simply automount

# automount -m
100000000|syntax error in map near [ @ -hosts  ]
Segmentation fault (core dumped)

# dmesg | tail -f
[ 1684.146282] automount[6707]: segfault at 0 ip 00007f023f9d2901 sp 00007ffc0f4b8638 error 4 in libc-2.17.so[7f023f864000+1c2000]


Actual results:

# automount -m
100000000|syntax error in map near [ @ -hosts  ]
Segmentation fault (core dumped)


Expected results:

To not segfault and return the correct maps.

# automount -m
100000000|syntax error in map near [ @ -hosts ]

autofs dump map information
===========================

global options: none configured

Mount point: /misc

source(s):

  instance type(s): file 
  map: /etc/auto.misc

  cd | -fstype=iso9660,ro,nosuid,nodev	:/dev/cdrom


Mount point: /net

source(s):

  type: hosts

  localhost | (null)


Additional info:

Unable to reproduce the issue on fedora.

# rpm -q autofs
autofs-5.1.5-4.fc30.x86_64

Comment 2 Ian Kent 2019-07-30 01:49:36 UTC
(In reply to Kenneth D'souza from comment #0)
> Description of problem:
> automount segfaults if a bad hosts entry is added in /etc/auto.master
> 
> Version-Release number of selected component (if applicable):
> # rpm -q autofs
> autofs-5.0.7-99.el7.x86_64
> 
> How reproducible:
> always 
> 
> Steps to Reproduce:
> 1. Add a bad entry in /etc/auto/master like below
> 
> # grep -v ^# /etc/auto.master  | grep -i hosts
> /net	-hosts
> @ -hosts  <---------------
> 
> 2. Trigger a crash by running automount -m or simply automount

Mmm ... I'm not able to reproduce this.

I tried on Centos7 with rev 99 and couldn't reproduce it, so I checked
out a RHEL-7.6 lab machine and still couldn't reproduce it.

I'll try installing 7.6 into a VM and apply any updates and see if I
can reproduce it then.

If I can't reproduce it we'll need to inspect a core on an install
that can reproduce it to see if we can get more information.

Ian

Comment 3 Kenneth D'souza 2019-07-30 05:07:12 UTC
(In reply to Ian Kent from comment #2)
> (In reply to Kenneth D'souza from comment #0)
> > Description of problem:
> > automount segfaults if a bad hosts entry is added in /etc/auto.master
> > 
> > Version-Release number of selected component (if applicable):
> > # rpm -q autofs
> > autofs-5.0.7-99.el7.x86_64
> > 
> > How reproducible:
> > always 
> > 
> > Steps to Reproduce:
> > 1. Add a bad entry in /etc/auto/master like below
> > 
> > # grep -v ^# /etc/auto.master  | grep -i hosts
> > /net	-hosts
> > @ -hosts  <---------------
> > 
> > 2. Trigger a crash by running automount -m or simply automount
> 
> Mmm ... I'm not able to reproduce this.
> 
> I tried on Centos7 with rev 99 and couldn't reproduce it, so I checked
> out a RHEL-7.6 lab machine and still couldn't reproduce it.
> 
> I'll try installing 7.6 into a VM and apply any updates and see if I
> can reproduce it then.
> 
> If I can't reproduce it we'll need to inspect a core on an install
> that can reproduce it to see if we can get more information.
> 
> Ian

Sorry I missed to update that the issue is seen only if I have a autofs file inside /etc/auto.master.d

# cat /etc/auto.master.d/direct.autofs 
/- /etc/auto.direct
 
# cat /etc/auto.direct 
/test/data -rw nfs-server:/example

# grep -v ^# /etc/auto.master
/misc	/etc/auto.misc
/net	-hosts
@ -hosts  <-------------------------------------- bad entry
+dir:/etc/auto.master.d <----------------------------------- this is necessary
+auto.master

I hope this helps.

Comment 4 Ian Kent 2019-07-30 10:23:30 UTC
(In reply to Kenneth D'souza from comment #3)
> 
> Sorry I missed to update that the issue is seen only if I have a autofs file
> inside /etc/auto.master.d
> 
> # cat /etc/auto.master.d/direct.autofs 
> /- /etc/auto.direct
>  
> # cat /etc/auto.direct 
> /test/data -rw nfs-server:/example
> 
> # grep -v ^# /etc/auto.master
> /misc	/etc/auto.misc
> /net	-hosts
> @ -hosts  <-------------------------------------- bad entry
> +dir:/etc/auto.master.d <----------------------------------- this is
> necessary
> +auto.master
> 
> I hope this helps.

That did the trick, I'll sort it out.

Thanks
Ian

Comment 5 Ian Kent 2019-07-30 11:51:52 UTC
Created attachment 1594586 [details]
Patch - fix reset flex scan buffer on init

Found it.

Comment 6 Ian Kent 2019-07-30 12:15:07 UTC
Change applied, built and verified to work for the case here.
The build can be found at:
https://brewweb.engineering.redhat.com/brew/buildinfo?buildID=940222

Please test to make sure it really is ok.

Comment 7 Kenneth D'souza 2019-07-30 12:52:08 UTC
(In reply to Ian Kent from comment #6)
> Change applied, built and verified to work for the case here.
> The build can be found at:
> https://brewweb.engineering.redhat.com/brew/buildinfo?buildID=940222
> 
> Please test to make sure it really is ok.

Works for me!

Comment 11 errata-xmlrpc 2020-03-31 20:00:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:1106