[RHEL7,COMMIT] net/scm/creds: drop redundant check for pid against init userns in scm_check_creds()

Submitted by Konstantin Khorenko on Dec. 18, 2017, 10:40 a.m.

Details

Message ID 201712181040.vBIAeXAS013164@finist_ce7.work
State New
Series "net/scm/creds: drop redundant check for pid against init userns in scm_check_creds()"
Headers show

Commit Message

Konstantin Khorenko Dec. 18, 2017, 10:40 a.m.
The commit is pushed to "branch-rh7-3.10.0-693.11.1.vz7.39.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.11.1.vz7.39.7
------>
commit 2a188a68a7f0478f290cb53e63791deea9b2f642
Author: Konstantin Khorenko <khorenko@virtuozzo.com>
Date:   Mon Dec 18 12:22:20 2017 +0300

    net/scm/creds: drop redundant check for pid against init userns in scm_check_creds()
    
    Normally scm_check_creds() checks if received pid equals to "current" pid in
    current userns and our additional check for equality to "current" pid in init
    userns seems to be a leftover:
    
    in 2.6.18-x we had the following patch:
     static __inline__ int scm_check_creds(struct ucred *creds)
     {
    -       if ((creds->pid == current->tgid || capable(CAP_SYS_ADMIN)) &&
    +       if ((creds->pid == virt_tgid(current) ||
    +            creds->pid == current->tgid ||
    +            capable(CAP_VE_SYS_ADMIN)) &&
    
    while mainstream patch:
    
    commit b488893a390edfe027bae7a46e9af8083e740668
    Author: Pavel Emelyanov <xemul@openvz.org>
    Date:   Thu Oct 18 23:40:14 2007 -0700
    
        pid namespaces: changes to show virtual ids to user
    
     static __inline__ int scm_check_creds(struct ucred *creds)
     {
    -       if ((creds->pid == current->tgid || capable(CAP_SYS_ADMIN)) &&
    +       if ((creds->pid == task_tgid_vnr(current) || capable(CAP_SYS_ADMIN)) &&
    
    Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 net/core/scm.c | 1 -
 1 file changed, 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/net/core/scm.c b/net/core/scm.c
index 593d8e5b4a70..b62658d9fe2e 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -53,7 +53,6 @@  static __inline__ int scm_check_creds(struct ucred *creds)
 		return -EINVAL;
 
 	if ((creds->pid == task_tgid_vnr(current) ||
-	     creds->pid == current->tgid ||
 	     ns_capable(task_active_pid_ns(current)->user_ns, CAP_SYS_ADMIN)) &&
 	    ((uid_eq(uid, cred->uid)   || uid_eq(uid, cred->euid) ||
 	      uid_eq(uid, cred->suid)) || ns_capable(cred->user_ns, CAP_SETUID)) &&