Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4659162yba; Wed, 17 Apr 2019 16:42:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwB1Lmbg7TF3reQ1p0DM57LIDK3Q/l0PHJ6Zj7H7qNy0pv/Z2xRFwWy70RIv3zwZImuzRn+ X-Received: by 2002:aa7:9389:: with SMTP id t9mr93849365pfe.60.1555544530497; Wed, 17 Apr 2019 16:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555544530; cv=none; d=google.com; s=arc-20160816; b=ZvSyLwLFI926rB5R1d+LcG7PrdlhZD6naqk0gJ8wgnsTtrCoZllB3+xD2CvobsRq/h BiN5UAnKRyHQBOmll1oo8vlIvklTHgTSGFJ//jIICtfc9dbAKUKFwOITUon34ZTwsLco ANCS+cpdLHIMH6kedxi0IHl2EOUE08YwjTRzZ8BIaU8CDhOOj9JLg7gPJdgUZHjeyqUB 1yZ5pCoFx+9nNwBZMYmJXBlL9HfmnHNuRCUeCk8kveSgeYudlgXTXf9TZnDdV3VlvaOq ReG2pNw4G3w1Al3f/pMAoVs0bHBvx8VpuXO3ogXa6BXvw38nNNb41iWEWgMOae7bltdP AGyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PueCdnTmdAT9LR/dMMBLPphcTcVeVYSjT+9pj3ZFIEk=; b=fvGynvOiiBVGGE1PORBP2xawPif/WIHzNBamWSmtkUBFyODtN3r1wjFUHh3LOZnKI9 0TbSTXg6eo2sEVICS+Lnne8jwjfYu9cy3lBa3fIQyUnC5DkllTmB5R96G2FA4Oejg4eU Ns1XUmbez6AtlQn3jLxQsr/7o0AsFoz5lRCZxCVbrcuFZbELqoxrxt/BApCEg4oNE6J/ lHkRdSNOISJnvQNJK0GTfPF33BzucTIKlpbCIcch35KgXgjqP6WkOsuGWAkDia184HcB +hG6D+Gg7VUU8X9yPGqJuhh/SOl6rz0sLttb75xJqUsrBkcPewHeiqUUJu7oz0xCVpxH bBSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=u9bf552P; 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 193si540964pfv.108.2019.04.17.16.41.56; Wed, 17 Apr 2019 16:42:10 -0700 (PDT) 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; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=u9bf552P; 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 S2387771AbfDQXje (ORCPT + 99 others); Wed, 17 Apr 2019 19:39:34 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:42349 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387705AbfDQXjc (ORCPT ); Wed, 17 Apr 2019 19:39:32 -0400 Received: by mail-lj1-f194.google.com with SMTP id v22so227969lje.9 for ; Wed, 17 Apr 2019 16:39:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PueCdnTmdAT9LR/dMMBLPphcTcVeVYSjT+9pj3ZFIEk=; b=u9bf552P1eISqEHwEehti8ZDUiZux4GSy41ZyWvrYDVAY6B0E60UfJ+fR0zJa+X+q3 iOcjO94jP6EinkOBdEaFxpo7mfOmp6J7Z/au5MUODtDd3RBc2LCbBFaLMTR74uFuMXNu G0c2bTKCt5F3RKaZ8dzd4lw87laYH8qvoacFJTQ1AVQ5KXQlB8SQEaetiBakBkCgO7Nb jI9qT1rjnPRdbLFY6doN7AQEdkgyvEShKOX8o5v5U3Sn/DGbwj3yMXcIaUQR33Trk7uI fgJuPmklXSHIhu6IHPKzGL7A5FIg+eW9BzE8kkiTzViG6DbwFQjZ+O+GW4b31FguwYdH YRHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PueCdnTmdAT9LR/dMMBLPphcTcVeVYSjT+9pj3ZFIEk=; b=b7gCNpg15/LuNHxAnd2welcJ2rTFIdxXyoqHYKlSboP09XbjsxAEyZrpinsHHlZ6Yj z3x7E5yB0wjrEoWJFO1zawqpEjVQr5yiaEIhfjZ4uQ4a+ebULCiD3TCKr7jWAD0IWpAc ie+86OhmkY8STvTLCJv0BsbY/cW88ygOwqDrgcxWxCjEMnvHNdqhvXliLHWGFpGJe8Ka MmueIT6A1KP4qcyyeqbrU8UtM4QP7DwVSIe2IiQyRoUBfahUhYVRI+xe+RqkGuwmVnN+ fVdGUpTs3CxT6ZgRA4Rx4BSNU6vGrtMMH8uF2qsvmbaGad0wuo/s3wZ9CUmDtRHOp75G tHJQ== X-Gm-Message-State: APjAAAWu/dwc0Sk/AjYVv2Dqq1pg55XXlhaeHSEIra30EZyTVGk9JDAT AFx+vvntp7ezaXcR9JTnge8pm6busOywD3qpUhkq X-Received: by 2002:a2e:88c5:: with SMTP id a5mr32153958ljk.5.1555544370455; Wed, 17 Apr 2019 16:39:30 -0700 (PDT) MIME-Version: 1.0 References: <20190415134331.GC22204@redhat.com> <20190415150520.GA13257@redhat.com> <20190417145711.GI32622@redhat.com> <20190417162723.GK32622@redhat.com> In-Reply-To: <20190417162723.GK32622@redhat.com> From: Paul Moore Date: Wed, 17 Apr 2019 19:39:19 -0400 Message-ID: Subject: Re: kernel BUG at kernel/cred.c:434! To: Oleg Nesterov , Casey Schaufler , john.johansen@canonical.com Cc: "chengjian (D)" , Kees Cook , NeilBrown , Anna Schumaker , "linux-kernel@vger.kernel.org" , Al Viro , "Xiexiuqi (Xie XiuQi)" , Li Bin , Jason Yan , Peter Zijlstra , Ingo Molnar , Linux Security Module list , SELinux , Yang Yingliang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 17, 2019 at 12:27 PM Oleg Nesterov wrote: > On 04/17, Paul Moore wrote: > > > > On Wed, Apr 17, 2019 at 10:57 AM Oleg Nesterov wrote: > > > On 04/17, Paul Moore wrote: > > > > > > > > I'm tempted to simply return an error in selinux_setprocattr() if > > > > the task's credentials are not the same as its real_cred; > > > > > > What about other modules? I have no idea what smack_setprocattr() is, > > > but it too does prepare_creds/commit creds. > > > > > > it seems that the simplest workaround should simply add the additional > > > cred == real_cred into proc_pid_attr_write(). > > > > Yes, that is simple, but I worry about what other LSMs might want to > > do. While I believe failing if the effective creds are not the same > > as the real_creds is okay for SELinux (possibly Smack too), I worry > > about what other LSMs may want to do. After all, > > proc_pid_attr_write() doesn't change the the creds itself, that is > > something the specific LSMs do. > > Yes, but if proc_pid_attr_write() is called with cred != real_cred then > something is already wrong? True, or at least I would think so. Looking at the current tree there are three LSMs which implement setprocattr hooks: SELinux, Smack, and AppArmor. I know Casey has already mentioned that he wasn't able to trigger the problem in Smack, but looking at smack_setprocattr() I see the similar commit_creds() usage so I would expect the same problem in Smack; what say you Casey? Looking at apparmor_setprocattr(), it appears that it too could end up calling commit_creds() via aa_set_current_hat(). Since it looks like all three LSMs which implement the setprocattr hook are vulnerable I'm open to the idea that proc_pid_attr_write() is a better choice for the cred != read_cred check, but I would want to make sure John and Casey are okay with that. John? Casey? -- paul moore www.paul-moore.com