cifs.upcall: trim even more capabilities
Subsystems (2)
PATCH 1/1 cifs.upcall: trim even more capabilities
We really only need CAP_DAC_READ_SEARCH, not CAP_DAC_OVERRIDE, and only when we are going to probe the environ file.
Also, fix the non-libcap-ng trim_capabilities prototype.
--- cifs.upcall.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
cifs.upcall.c +8 -9
@@ -70,22 +70,21 @@ typedef enum _sectype {#ifdef HAVE_LIBCAP_NG static int -trim_capabilities (bool need_ptrace) +trim_capabilities (bool need_environ) {capng_clear (CAPNG_SELECT_BOTH ); -/* -* Need PTRACE and DAC_OVERRIDE for environment scraping, SETGID to -* change gid and grouplist, and SETUID to change uid. -*/ +/* SETUID and SETGID to change uid, gid, and grouplist */ if (capng_updatev (CAPNG_ADD ,CAPNG_PERMITTED |CAPNG_EFFECTIVE , -CAP_SETUID ,CAP_SETGID ,CAP_DAC_OVERRIDE ,-1 )) { +CAP_SETUID ,CAP_SETGID ,-1 )) {syslog (LOG_ERR ,"%s: Unable to update capability set: %m\n" , __func__);return 1 ; } -if (need_ptrace && -capng_update (CAPNG_ADD ,CAPNG_PERMITTED |CAPNG_EFFECTIVE ,CAP_SYS_PTRACE )) { +/* Need PTRACE and DAC_OVERRIDE for environment scraping */ +if (need_environ && +capng_updatev (CAPNG_ADD ,CAPNG_PERMITTED |CAPNG_EFFECTIVE , +CAP_SYS_PTRACE ,CAP_DAC_READ_SEARCH ,-1 )) {syslog (LOG_ERR ,"%s: Unable to update capability set: %m\n" , __func__);return 1 ; }
@@ -109,7 +108,7 @@ drop_all_capabilities(void) }#else /* HAVE_LIBCAP_NG */ static int -trim_capabilities (void ) +trim_capabilities (bool unused) {return 0 ; }
Signature · 1 line
2.9.3
A message that is not in the archive (sent off-list or not yet received): 20170216145913.15848-1-jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org
Simo Sorce
Reviewed-byQuoted 53 lines · Jeff Layton
We really only need
CAP_DAC_READ_SEARCH, notCAP_DAC_OVERRIDE, and only when we are going to probe the environ file.Also, fix the non-libcap-ng
trim_capabilitiesprototype.Signed-off-by Jeff Layton <[email protected]>--- cifs.upcall.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)cifs.upcall.c +8
-9@@ -70,22 +70,21 @@ typedef enum _sectype {#ifdef HAVE_LIBCAP_NG static int -trim_capabilities (bool need_ptrace) +trim_capabilities (bool need_environ) {capng_clear (CAPNG_SELECT_BOTH ); -/* -* Need PTRACE and DAC_OVERRIDE for environment scraping, SETGID to -* change gid and grouplist, and SETUID to change uid. -*/ +/* SETUID and SETGID to change uid, gid, and grouplist */ if (capng_updatev (CAPNG_ADD ,CAPNG_PERMITTED |CAPNG_EFFECTIVE , -CAP_SETUID ,CAP_SETGID ,CAP_DAC_OVERRIDE ,-1 )) { +CAP_SETUID ,CAP_SETGID ,-1 )) {syslog (LOG_ERR ,"%s: Unable to update capability set: %m\n" , __func__);return 1 ; } -if (need_ptrace && -capng_update (CAPNG_ADD ,CAPNG_PERMITTED |CAPNG_EFFECTIVE ,CAP_SYS_PTRACE )) { +/* Need PTRACE and DAC_OVERRIDE for environment scraping */ +if (need_environ && +capng_updatev (CAPNG_ADD ,CAPNG_PERMITTED |CAPNG_EFFECTIVE , +CAP_SYS_PTRACE ,CAP_DAC_READ_SEARCH ,-1 )) {syslog (LOG_ERR ,"%s: Unable to update capability set: %m\n" , __func__);return 1 ; }@@ -109,7 +108,7 @@ drop_all_capabilities(void) }#else /* HAVE_LIBCAP_NG */ static int -trim_capabilities (void ) +trim_capabilities (bool unused) {return 0 ; }
Signature · 1 line
Simo Sorce * Red Hat, Inc * New York
2017-02-16 6:59 GMT-08:00 Jeff Layton <[email protected]>:
Quoted 28 lines
We really only need
CAP_DAC_READ_SEARCH, notCAP_DAC_OVERRIDE, and only when we are going to probe the environ file.Also, fix the non-libcap-ng
trim_capabilitiesprototype.Signed-off-by Jeff Layton <[email protected]>--- cifs.upcall.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)cifs.upcall.c +2
-5@@ -70,22 +70,21 @@ typedef enum _sectype {#ifdef HAVE_LIBCAP_NG static int -trim_capabilities (bool need_ptrace) +trim_capabilities (bool need_environ) {capng_clear (CAPNG_SELECT_BOTH ); -/* -* Need PTRACE and DAC_OVERRIDE for environment scraping, SETGID to -* change gid and grouplist, and SETUID to change uid. -*/ +/* SETUID and SETGID to change uid, gid, and grouplist */
cifs.upcall.c typedef enum _sectype { · line 84
Quoted 10 lines
cifs.upcall.c +2
-3if (capng_updatev (CAPNG_ADD ,CAPNG_PERMITTED |CAPNG_EFFECTIVE , -CAP_SETUID ,CAP_SETGID ,CAP_DAC_OVERRIDE ,-1 )) { +CAP_SETUID ,CAP_SETGID ,-1 )) {syslog (LOG_ERR ,"%s: Unable to update capability set: %m\n" , __func__);return 1 ; } -if (need_ptrace && -capng_update (CAPNG_ADD ,CAPNG_PERMITTED |CAPNG_EFFECTIVE ,CAP_SYS_PTRACE )) { +/* Need PTRACE and DAC_OVERRIDE for environment scraping */
It seems that the comment above doesn't reflect the proposed change. Should it be DAC_READ_SEARCH instead?
Quoted 22 lines
cifs.upcall.c +4
-2+if (need_environ && +capng_updatev (CAPNG_ADD ,CAPNG_PERMITTED |CAPNG_EFFECTIVE , +CAP_SYS_PTRACE ,CAP_DAC_READ_SEARCH ,-1 )) {syslog (LOG_ERR ,"%s: Unable to update capability set: %m\n" , __func__);return 1 ; }@@ -109,7 +108,7 @@ drop_all_capabilities(void) }#else /* HAVE_LIBCAP_NG */ static int -trim_capabilities (void ) +trim_capabilities (bool unused) {return 0 ; } --2.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best regards, Pavel Shilovsky
A message that is not in the archive (sent off-list or not yet received): CAKywueQiDRKZPW3ev7OBmXea=h7W1bc_5rtf9Ds7NChVm6=gbg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 36 lines · Pavel Shilovsky
2017-02-16 6:59 GMT-08:00 Jeff Layton <[email protected]>:
Quoted 35 lines
We really only need
CAP_DAC_READ_SEARCH, notCAP_DAC_OVERRIDE, and only when we are going to probe the environ file.Also, fix the non-libcap-ng
trim_capabilitiesprototype.Signed-off-by Jeff Layton <[email protected]>--- cifs.upcall.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)cifs.upcall.c +3
-6@@ -70,22 +70,21 @@ typedef enum _sectype {#ifdef HAVE_LIBCAP_NG static int -trim_capabilities (bool need_ptrace) +trim_capabilities (bool need_environ) {capng_clear (CAPNG_SELECT_BOTH ); -/* -* Need PTRACE and DAC_OVERRIDE for environment scraping, SETGID to -* change gid and grouplist, and SETUID to change uid. -*/ +/* SETUID and SETGID to change uid, gid, and grouplist */ if (capng_updatev (CAPNG_ADD ,CAPNG_PERMITTED |CAPNG_EFFECTIVE , -CAP_SETUID ,CAP_SETGID ,CAP_DAC_OVERRIDE ,-1 )) { +CAP_SETUID ,CAP_SETGID ,-1 )) {syslog (LOG_ERR ,"%s: Unable to update capability set: %m\n" , __func__);return 1 ; }
Quoted 7 lines
cifs.upcall.c typedef enum _sectype { · line 84
Quoted 3 lines
cifs.upcall.c +1
-2-if (need_ptrace && -capng_update (CAPNG_ADD ,CAPNG_PERMITTED |CAPNG_EFFECTIVE ,CAP_SYS_PTRACE )) { +/* Need PTRACE and DAC_OVERRIDE for environment scraping */ It seems that the comment above doesn't reflect the proposed change. Should it be
DAC_READ_SEARCHinstead?
Yes! It should and it's fixed in the version in the tree.
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>