Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2990545imu; Sun, 9 Dec 2018 14:28:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/WWjYr/9pHC1LnE8dPgvsZxFDYQtt8csgv7u7A8OGpsBTF6pxtTsPWSOXtLwscVhrt6jZDQ X-Received: by 2002:a17:902:6bc7:: with SMTP id m7mr10120851plt.106.1544394489584; Sun, 09 Dec 2018 14:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544394489; cv=none; d=google.com; s=arc-20160816; b=0EzJ2edvbtWEC0k3OnT62nao4sRvatOi26GfT6l+TLF6pJQg7vbwRUhshQXlswZnBr ToDuTuxUKawShjVAa819w1C9oYUBrmnZKOdl0guS+InSQdY5BwQFv+VBSGGyyHJfjFHr 9YSB4ew5m72KslTugTQYVwDHFAf5dIcXPu3v4nVcw7ujSPmsLMdz3EK3dnRt3EDhKrkD TDmgDr5v9Yb3j76ZCl0MYxfyg7bw9hsaYRKAeG5+99ZL1jGsqXJuLxXBIyPgl/SPUy7v pWA2fZvRA7PLaeI7kPLDOuStg9Uu9YrR1QPuvOGvvr+xUYLHt0DlY50ypd5zftNqK97i S5xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=i6b28G2g3R60fA1UtjoWwbNIlyFU5Zn03vymXlRJ6Y8=; b=d1M06q2GEN/+NvCDa3Q3HYsshHhsQ5LvEOS2OgWIk1ofSPT7gny/qyN9D3rhAFLu1i MxodtwmTCN567M1L7LiOpfRQBlTxe+qm0dk4hUuxLYTEnhoHxA8rBiFVFdDQRFmAwz8v Bx0VWtkWeTuIfvTSjFGBpmmxB1X3bT+Puu47g2BLGHXYyRMx3Pc7dLE+at3+nMNQ4txk GOqC66P/l0xzrOBTakpCOjM3d1P7j64OzvqndV28wn3+irgLGThX/0mcmwH5ReqNF4qn OTyz15+q08QpW/cZPqnCy9GlkZ0+uP2d7j3Ow5ZhNF/HkLvo2iP9sY4+jhucYQWbI9Y4 m17g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13si7255875pgs.17.2018.12.09.14.27.54; Sun, 09 Dec 2018 14:28:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726422AbeLIVzO (ORCPT + 99 others); Sun, 9 Dec 2018 16:55:14 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34548 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726313AbeLIVzJ (ORCPT ); Sun, 9 Dec 2018 16:55:09 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW72Y-0002ic-Qi; Sun, 09 Dec 2018 21:55:06 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72X-0003CO-Ro; Sun, 09 Dec 2018 21:55:05 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "=?UTF-8?q?Ondrej=20Mosn=C3=A1=C4=8Dek?=" , "Paul Moore" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 004/328] audit: Fix extended comparison of GID/EGID In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Ondrej Mosnáček commit af85d1772e31fed34165a1b3decef340cf4080c0 upstream. The audit_filter_rules() function in auditsc.c used the in_[e]group_p() functions to check GID/EGID match, but these functions use the current task's credentials, while the comparison should use the credentials of the task given to audit_filter_rules() as a parameter (tsk). Note that we can use group_search(cred->group_info, ...) as a replacement for both in_group_p and in_egroup_p as these functions only compare the parameter to cred->fsgid/egid and then call group_search. In fact, the usage of in_group_p was even more incorrect: it compares to cred->fsgid (which is usually equal to cred->egid) and not cred->gid. GitHub issue: https://github.com/linux-audit/audit-kernel/issues/82 Fixes: 37eebe39c973 ("audit: improve GID/EGID comparation logic") Signed-off-by: Ondrej Mosnacek Signed-off-by: Paul Moore Signed-off-by: Ben Hutchings --- kernel/auditsc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -489,20 +489,20 @@ static int audit_filter_rules(struct tas result = audit_gid_comparator(cred->gid, f->op, f->gid); if (f->op == Audit_equal) { if (!result) - result = in_group_p(f->gid); + result = groups_search(cred->group_info, f->gid); } else if (f->op == Audit_not_equal) { if (result) - result = !in_group_p(f->gid); + result = !groups_search(cred->group_info, f->gid); } break; case AUDIT_EGID: result = audit_gid_comparator(cred->egid, f->op, f->gid); if (f->op == Audit_equal) { if (!result) - result = in_egroup_p(f->gid); + result = groups_search(cred->group_info, f->gid); } else if (f->op == Audit_not_equal) { if (result) - result = !in_egroup_p(f->gid); + result = !groups_search(cred->group_info, f->gid); } break; case AUDIT_SGID: