autofs-5.0.4 - use CLOEXEC flag for setmntent
Subsystems (2)
Ian Kent
maintainerPATCH 1/13 autofs-5.0.4 - use CLOEXEC flag for setmntent
Update use of CLOEXEC functionality to cover setmntent(3) calls as well.
---
CHANGELOG | 1 + include/automount.h | 20 ++++++++++++++++++++ lib/mounts.c | 8 ++++---- 3 files changed, 25 insertions(+), 4 deletions(-)
CHANGELOG +1 -0
@@ -8,6 +8,7 @@ - make hash table scale to thousands of entries (Paul Wankadia, Valerie Aurora Henson). - clear the quoted flag after each character from program map input. +- use CLOEXEC flag for setmntent also. 4/11/2008 autofs-5.0.4 -----------------------
include/automount.h +20 -0
@@ -581,5 +581,25 @@ static inline FILE *open_fopen_r(const char *path) return f; } +static inline FILE *open_setmntent_r (const char *table) +{ +FILE *tab; + +#if defined(O_CLOEXEC ) && defined(SOCK_CLOEXEC ) +if (cloexec_works !=-1 ) { + tab =setmntent (table,"re" ); +if (tab !=NULL ) { +check_cloexec (fileno (tab)); +return tab; + } + } +#endif + tab =fopen (table,"r" ); +if (tab ==NULL ) +return NULL ; +check_cloexec (fileno (tab)); +return tab; +} +#endif
lib/mounts.c +4 -4
@@ -218,7 +218,7 @@ struct mnt_list *get_mnt_list(const char *table, const char *path, int include)if (!path || !pathlen || pathlen >PATH_MAX )return NULL ; - tab =setmntent (table,"r" ); + tab =open_setmntent_r (table);if (!tab) {char *estr =strerror_r (errno, buf,PATH_MAX -1 );logerr ("setmntent: %s" , estr);
@@ -415,7 +415,7 @@ static int table_is_mounted(const char *table, const char *path, unsigned int tyif (!path || !pathlen || pathlen >=PATH_MAX )return 0 ; - tab =setmntent (table,"r" ); + tab =open_setmntent_r (table);if (!tab) {char *estr =strerror_r (errno, buf,PATH_MAX -1 );logerr ("setmntent: %s" , estr);
@@ -489,7 +489,7 @@ int has_fstab_option(const char *opt)if (!opt)return 0 ; - tab =setmntent (_PATH_MNTTAB,"r" ); + tab =open_setmntent_r (_PATH_MNTTAB);if (!tab) {char *estr =strerror_r (errno, buf,PATH_MAX -1 );logerr ("setmntent: %s" , estr);
@@ -668,7 +668,7 @@ struct mnt_list *tree_make_mnt_tree(const char *table, const char *path)size_t plen;int eq; - tab =setmntent (table,"r" ); + tab =open_setmntent_r (table);if (!tab) {char *estr =strerror_r (errno, buf,PATH_MAX -1 );logerr ("setmntent: %s" , estr);
Ian Kent
maintainerPATCH 2/13 autofs-5.0.4 - fix hosts map use after free
From: Paul Wankadia <[email protected]>
This patch fixed use a map entry after it has been freed in the hosts map lookup module.
---
CHANGELOG | 1 + modules/lookup_hosts.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-)
CHANGELOG +1 -0
@@ -9,6 +9,7 @@ Valerie Aurora Henson). - clear the quoted flag after each character from program map input. - use CLOEXEC flag for setmntent also. +- fix hosts map use after free (Paul Wankadia). 4/11/2008 autofs-5.0.4 -----------------------
modules/lookup_hosts.c +5 -3
@@ -138,17 +138,19 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void */* Check if we recorded a mount fail for this key anywhere */ me =lookup_source_mapent (ap, name,LKP_DISTINCT );if (me) { +struct mapent_cache *fmc = me->mc; +if (me->status >=time (NULL )) { -cache_unlock (me->mc); +cache_unlock (fmc);return NSS_STATUS_NOTFOUND ; }if (!me->mapent) { -cache_delete (me->mc, name); +cache_delete (fmc, name); me =NULL ; } -cache_unlock (me->mc); +cache_unlock (fmc); }cache_readlock (mc);
Ian Kent
maintainerQuoted 2 lines · Ian Kent
Update use of CLOEXEC functionality to cover setmntent(3) calls as well.
Pleas ignore this false start.
Oops.
Quoted 94 lines
---
CHANGELOG | 1 + include/automount.h | 20 ++++++++++++++++++++ lib/mounts.c | 8 ++++---- 3 files changed, 25 insertions(+), 4 deletions(-)CHANGELOG +1
-0@@ -8,6 +8,7 @@ - make hash table scale to thousands of entries (Paul Wankadia, Valerie Aurora Henson). - clear the quoted flag after each character from program map input. +- use CLOEXEC flag for setmntent also. 4/11/2008 autofs-5.0.4 -----------------------include/automount.h +20
-0@@ -581,5 +581,25 @@ static inline FILE *open_fopen_r(const char *path) return f; } +static inline FILE *open_setmntent_r (const char *table) +{ +FILE *tab; + +#if defined(O_CLOEXEC ) && defined(SOCK_CLOEXEC ) +if (cloexec_works !=-1 ) { + tab =setmntent (table,"re" ); +if (tab !=NULL ) { +check_cloexec (fileno (tab)); +return tab; + } + } +#endif + tab =fopen (table,"r" ); +if (tab ==NULL ) +return NULL ; +check_cloexec (fileno (tab)); +return tab; +} +#endif lib/mounts.c +4
-4@@ -218,7 +218,7 @@ struct mnt_list *get_mnt_list(const char *table, const char *path, int include)if (!path || !pathlen || pathlen >PATH_MAX )return NULL ; - tab =setmntent (table,"r" ); + tab =open_setmntent_r (table);if (!tab) {char *estr =strerror_r (errno, buf,PATH_MAX -1 );logerr ("setmntent: %s" , estr);@@ -415,7 +415,7 @@ static int table_is_mounted(const char *table, const char *path, unsigned int tyif (!path || !pathlen || pathlen >=PATH_MAX )return 0 ; - tab =setmntent (table,"r" ); + tab =open_setmntent_r (table);if (!tab) {char *estr =strerror_r (errno, buf,PATH_MAX -1 );logerr ("setmntent: %s" , estr);@@ -489,7 +489,7 @@ int has_fstab_option(const char *opt)if (!opt)return 0 ; - tab =setmntent (_PATH_MNTTAB,"r" ); + tab =open_setmntent_r (_PATH_MNTTAB);if (!tab) {char *estr =strerror_r (errno, buf,PATH_MAX -1 );logerr ("setmntent: %s" , estr);@@ -668,7 +668,7 @@ struct mnt_list *tree_make_mnt_tree(const char *table, const char *path)size_t plen;int eq; - tab =setmntent (table,"r" ); + tab =open_setmntent_r (table);if (!tab) {char *estr =strerror_r (errno, buf,PATH_MAX -1 );logerr ("setmntent: %s" , estr);_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs