Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4005359yba; Tue, 23 Apr 2019 13:21:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyopJF1ANFGLSpuXhKwdDtbii12hxV/1jMy7QYWguiPLgWfXB/JGQnYydQmAttWt74lZZO/ X-Received: by 2002:a63:5b24:: with SMTP id p36mr25701590pgb.84.1556050865984; Tue, 23 Apr 2019 13:21:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556050865; cv=none; d=google.com; s=arc-20160816; b=Be/iyJjS4B61TEGaxchQNs4EjZ8Xhw30lgxRhJOBZ6MDJCpLsOC9B5ORHAaOdRwlL0 46q4izSiROxPbSWaN3dJrlKgYT/ZNW7sTdeo8LHCZKwvg1voflv87uBfpfL8YQoQLd6m wTUDXYSx2Q5D8bwSbaX8J5PJ3nunLAkDiVFwzsMmbA3DT4P1MO0kBSSGYedY/wYaXSGH 6lS22MihoVJYUVqhbbh8XlyadAXaBzDaxaqKWgCj7D9kHuWmKr8Hw21IEV3UW9ir/wVu y4b0xSPTu4dnaLpV205mU0AIgZwmuAYAFf5AWe3NcQaNiMnKAEUDnO2LXg2XftxeECVX aNrw== 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=ISPtN114/vVDuvBUDQI+XOUJt45zg0Mc6YZThYyu9sE=; b=tZoHhZaCIfkiuWWgynx4BP1zcxawrgiYk5KVUvOrDeNUJop03f4pasEgkb9SFWAvnk tNVfAUXmOQQxF1rioXDWLKjbIXUs2zMcMrrsEDBRNdSZ5TQY3WKp2j9cBAuqwV/IiB6s s7nMohha7a14tgTJgKunH0+s/mTev4APoboJkyW2Tch8tPLE1r7Bf/G3towovHvE4a/5 maet9GGocYEkOMubJLUiE/wcx+NLDVRjK7l28vi9BsaLCTaIFO5s1NDWzol1Twbo1dUt Wx7ehTn+ZQ/pnI0QV7UkJTx07fzpbxnK1k9Ks32tanDinWLmLRph+0c5b77L5tTcWOmS eWEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=gItHDwtX; 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 e35si17292331plb.38.2019.04.23.13.20.50; Tue, 23 Apr 2019 13:21:05 -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=gItHDwtX; 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 S1727262AbfDWUTE (ORCPT + 99 others); Tue, 23 Apr 2019 16:19:04 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:41228 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727241AbfDWUTD (ORCPT ); Tue, 23 Apr 2019 16:19:03 -0400 Received: by mail-lf1-f66.google.com with SMTP id t30so12729169lfd.8 for ; Tue, 23 Apr 2019 13:19:01 -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=ISPtN114/vVDuvBUDQI+XOUJt45zg0Mc6YZThYyu9sE=; b=gItHDwtXfT3vkgFtkuMveM178GaK6E5BSH/sjG7WZHN92faZ+NIO1mJcaOYaIOXK1p bcO0SzU+RR/oz/yNUATaISXuEoPyA8f8qymglN1JJpQCpAsN27sye6iJBExT/tUJ/kbN 4l0mde06G+ysr/0Rw0CMfKb/ILGd/JdqLCmZpxQ8/AVO+RLFcWITTnp9ROlmZdM2eXXI liOIisIYiA/0G23ZhJ04RNJsV8Fzp2YB4Nrkd2cudFbA7PbxP82uHe9V3PeuCecpTzIH EWubVuGPSeJLLeXFs/r/6MEE7c43R6qZ6Np/bmngVrrt0wOaABymndI9VLLE9OgtizXn OOKg== 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=ISPtN114/vVDuvBUDQI+XOUJt45zg0Mc6YZThYyu9sE=; b=EdgPUI1MxVMaTvwVUJL8OF21fqXYBoEcPGh2etMSXSS9rU0TELyWc6unYbQTQ6bcqS fnK2T7f7S8kxkdkHnluW1b/veFCbP8XMva+9iwilGJQBM0ps60g25ayfYgnpFckGm2pa gCpcIrCamS3A2MeRAwHj6WlGxE55xFwuohO5oeDwf1XvlQ6bXdevhz2uX0xRZGPskK3z vUsc/JLcE+963xbGHV5CSLal5pYpom6Mib/0DhcEdlLYT7E5WzV39agBO2GMEgSz1mwv TGAxCYfZFzjSKhL1ohJpvEBq6zAxMnl2IubF/DJJ8rA0ntRiJqNEziQRCoA6WrlnMWjm VdtA== X-Gm-Message-State: APjAAAXau4mVeyL41DGmpdPGkRRsaoDRaN9F5oP5R7luUDP1JGBaM5UI fZggqWxCf2K/m0HTa6GNtm1nYum6LzJLHbMCsIfq X-Received: by 2002:a19:2814:: with SMTP id o20mr14905670lfo.117.1556050740201; Tue, 23 Apr 2019 13:19:00 -0700 (PDT) MIME-Version: 1.0 References: <20190417145711.GI32622@redhat.com> <20190417162723.GK32622@redhat.com> <0ca3f4cf-5c64-2fc0-1885-9dbcca2f4b47@schaufler-ca.com> <5CB7E5D4.2060703@huawei.com> <5CB933C4.7000300@huawei.com> <5CB9DC75.7010600@huawei.com> <5CBACC8F.8010409@huawei.com> <5CBE8FC4.8060400@huawei.com> In-Reply-To: <5CBE8FC4.8060400@huawei.com> From: Paul Moore Date: Tue, 23 Apr 2019 16:18:49 -0400 Message-ID: Subject: Re: kernel BUG at kernel/cred.c:434! To: Yang Yingliang Cc: Casey Schaufler , Oleg Nesterov , john.johansen@canonical.com, "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 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 Tue, Apr 23, 2019 at 12:08 AM Yang Yingliang wrote: > On 2019/4/23 3:48, Paul Moore wrote: > > On Sat, Apr 20, 2019 at 3:39 AM Yang Yingliang wrote: > >> I'm not sure you got my point. > > I went back and looked at your previous emails again to try and > > understand what you are talking about, and I'm a little confused by > > some of the output ... > > > >> --- a/kernel/acct.c > >> +++ b/kernel/acct.c > >> @@ -481,6 +481,7 @@ static void do_acct_process(struct bsd_acct_struct > >> *acct) > >> flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; > >> current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; > >> /* Perform file operations on behalf of whoever enabled > >> accounting */ > >> + pr_info("task:%px new cred:%px real cred:%px cred:%px\n", > >> current, file->f_cred, current->real_cred, current->cred); > >> orig_cred = override_creds(file->f_cred); > > Okay, with this patch applied we should the task/cred info when > > do_acct_process is called. Got it. > > > >> Messages: > >> [ 56.643298] task:ffff88841a9595c0 new cred:ffff88841ae450c0 real > >> cred:ffff88841ae450c0 cred:ffff88841ae450c0 //They are same. > > Okay, it looks like do_acct_process() was called and f_cred, > > real_cred, and cred are all the same. > > This is a original message, without patch applied. The patch I am referring to is your pr_info patch (above). I'm not talking about any other patches at the moment; I just want to understand the example dmesg output you copied into your email. With that in mind, the message above seems to indicate that do_acct_process() has been invoked with f_cred, real_cred, and cred all pointing to the same credentials struct, yes? > >> [ 56.646609] Process accounting resumed > > It looks like do_acct_process() has called check_free_space() now. So > > far so good. ... > >> [ 56.649943] task:ffff88841a9595c0 new cred:ffff88841ae450c0 real > >> cred:ffff88841c96c300 cred:ffff88841ae450c0 > > Wait a minute ... why are we seeing this again? Looking at the task > > pointer and the timestamp, this is the same task exiting and trying to > > write to the accounting file, yes? This output is particularly > > curious since it appears that real_cred has changed; where is this > > happening? > > This is the message when the BUG_ON was triggered without applying any > fix patch. The only place in the code that generates this message is the bit of code that you patches in using the pr_info() patch (above), yes? If so, that would seem to indicate that the same task is calling do_acct_process() twice, yes? I may be fundamentally misunderstanding something about process accounting, but I though do_acct_process() would only be called once for a given task - while it was exiting. Yes, no? > If we apply this patch "proc: prevent changes to overridden > credentials", program > runs like this: I'd like to focus on understanding the dmesg output you shared first, because it doesn't seem to make sense to me. -- paul moore www.paul-moore.com