Received: by 10.223.185.116 with SMTP id b49csp625397wrg; Wed, 21 Feb 2018 04:21:57 -0800 (PST) X-Google-Smtp-Source: AH8x225iR6WkOApRT4ZQ4iO0tj+ml/XNG0PgbcyKFWf8iNo0k6fM1YM++TDIaLTwaT2BEyuXVNpf X-Received: by 2002:a17:902:7b98:: with SMTP id w24-v6mr3004001pll.328.1519215717548; Wed, 21 Feb 2018 04:21:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519215717; cv=none; d=google.com; s=arc-20160816; b=kw5aQt2LNqbCYZUKx9cXs7oRsOIaQGxx8osQ4mi5O/2Qu+308+0BzvZtPEZorCYgHn YjTP8xd/egI0lfWdhwe84mdD3oqEU9fSqyyeSjUcBrbX78Xx77xyjpQNnOudbyiTKvg7 4rowPvU3qrG3ql/d+14l2wGcLZlvboHCAnOOwhkqsyxtaaWIuAHNLb5CbWLzw+H5fzPU 78vq1g3md/gX/lMbZZR+FBf6TfTl9kFImsnvcIwOlxa2OkFyK3TiKUfsVEP8LBFfsGbP v9Xa/jI2W+Q6UU6kzqUke0gBJfL6QGJMqmsyFinut1ecgytElOLa4i0/IYrRQwlTugeO klgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=EPp8EOEMlrfGpztZEoRbZbPd75EdUZ0V4JXiERKwRx8=; b=cXDTDLfZjqMYCkU+k21KDWpoxv7a/wETW3gM2mEujrwUj1azeyoQRJwilsfA5nGQGG avaKFmsQePoeGbBx9EQ4CR02zb41UnL1cpv9m66k9Mpy7Q+nm8rRgM0qtb+iXvHLL3dk Vlzwk0RU1wCucMfSos1BlHtMPo66Jy0i9E6lB0JCR0iOPo9sawnxSuhX5lBvqfZC6UKk gVRIcRfHL2ChPfVGskOT13xgSpWGfPVtcYIyKS+35pn6H818ATNFVO0JSOwTyuBtr9Dj bB65r8lTcZX8v15sP6C82rCPxq2SMyPZNXhhDuDsqzHiYhcYTZhFOCtVDCIlv/rIFLQ5 /T4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Ht84gC6g; 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 62-v6si7349461ple.267.2018.02.21.04.21.29; Wed, 21 Feb 2018 04:21:57 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Ht84gC6g; 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 S1752604AbeBUIqI (ORCPT + 99 others); Wed, 21 Feb 2018 03:46:08 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:39455 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752442AbeBUIqG (ORCPT ); Wed, 21 Feb 2018 03:46:06 -0500 Received: by mail-wr0-f196.google.com with SMTP id w77so2102067wrc.6; Wed, 21 Feb 2018 00:46:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=EPp8EOEMlrfGpztZEoRbZbPd75EdUZ0V4JXiERKwRx8=; b=Ht84gC6g28TAS4QL1RHiV/LJHJt968QJs2RKuhL/7wKmWHTUYzY5/L9sT17K51l2eK DdJWuzzqndezEg1LES9lmhkxjksjMODaRuptG02bQAGE5ukRKjXoreJyQ8fqWohX1k6R TLk0Ob0qMs2RSsNv3SSpcZbfTDh6N0wFG7PIn7FLqOemydhrs8eBJ/1VXZJXnr3heDHa gTvjkpFYMWqepcyNFgwCJRwOa+xcyCnAhIAmdhU5kIBBHX+13Bi7swiD6M/KR2Yobq6q BhuZIKJvc3+LVIkZT+tdCssiD7+1Fnl4oRwuMYoMlLfnoPOORQuZjpHWrqrjlXQlfLxm EEZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=EPp8EOEMlrfGpztZEoRbZbPd75EdUZ0V4JXiERKwRx8=; b=T5piIA9/FW5uYvEYHuQGnroYV6Y8N530y0PWOxSGvu8yoyNPZ9gsKWjFaLzQEbaYOP 0KqvEi3yiJ0qYuB/RJEENNWmMWLWyWK8mcyOtmGt27ueguCFSVE2eItZvwPTX3U268yF VdMhkeu0q9dZ8223VY1GPhBBF3L7c7JDsqnpmHIuVC+YG/P4Fxdz1Y5pJwCn+nydISjM cJ9ONlzCa5TnrEKNZMCZYVtxe53APW9HegZ5UoM4GwoEm+o1n0Cm+iKya3IoEZutCZSQ IRMOfbXY9dfFnGt8I1rJWr8vAgtOBVB2tpoYo5n7K/hjGJZ1BbVA2NbQpzWl9ofFSWjE ghcA== X-Gm-Message-State: APf1xPDg/Z63cDrJ43SSxibbJJtKDsPY0Jqq4IjP7W4MyFBISzzhSUzx sF4AaQRcqfSlbngTNSoEZGs= X-Received: by 10.28.229.213 with SMTP id c204mr1342939wmh.1.1519202765244; Wed, 21 Feb 2018 00:46:05 -0800 (PST) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id n20sm13899964wrg.84.2018.02.21.00.46.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2018 00:46:04 -0800 (PST) Date: Wed, 21 Feb 2018 09:46:02 +0100 From: Ingo Molnar To: Paul Moore Cc: Peter Zijlstra , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Dmitry Vyukov , linux-audit@redhat.com, Thomas Gleixner Subject: Re: [PATCH 4.10 070/111] audit: fix auditd/kernel connection state tracking Message-ID: <20180221084601.scnvgiiv32s2pgye@gmail.com> References: <20170328122915.640228468@linuxfoundation.org> <20170328122918.597715642@linuxfoundation.org> <20180220123757.GE25314@hirez.programming.kicks-ass.net> <20180220140640.GE25201@hirez.programming.kicks-ass.net> <20180220151849.GG25201@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Paul Moore wrote: > On Tue, Feb 20, 2018 at 10:18 AM, Peter Zijlstra wrote: > > On Tue, Feb 20, 2018 at 09:51:08AM -0500, Paul Moore wrote: > >> On Tue, Feb 20, 2018 at 9:06 AM, Peter Zijlstra wrote: > > > >> > It's not at all clear to me what that code does, I just stumbled upon > >> > __mutex_owner() outside of the mutex code itself and went WTF. > >> > >> If you don't want people to use __mutex_owner() outside of the mutex > >> code I might suggest adding a rather serious comment at the top of the > >> function, because right now I don't see anything suggesting that > >> function shouldn't be used. Yes, there is the double underscore > >> prefix, but that can mean a few different things these days. > > > > Find below. > > > >> > The comment (aside from having the most horribly style) ... > >> > >> Yeah, your dog is ugly too. Notice how neither comment is constructive? > > > > I'm sure you've seen this one: > > > > https://lkml.org/lkml/2016/7/8/625 > > Yep. I stand behind my earlier comment in this thread. > > >> > Maybe if you could explain how that code is supposed to work and why it > >> > doesn't know if it holds a lock I could make a suggestion... > >> > >> I just spent a few minutes looking back over the bits available in > >> include/linux/mutex.h and I'm not seeing anything beyond > >> __mutex_owner() which would allow us to determine the mutex owning > >> task. It's probably easiest for us to just track ownership ourselves. > >> I'll put together a patch later today. > > > > Note that up until recently the mutex implementation didn't even have a > > consistent owner field. And the thing is, it's very easy to use wrong, > > only today I've seen a patch do: "__mutex_owner() == task", where task > > was allowed to be !current, which is just wrong. > > Arguably all the more reason why a strongly worded warning is > important (which I see you've included below, feel free to include my > Reviewed-by). > > > Looking through kernel/audit.c I'm not even sure I see how you would end > > up in audit_log_start() with audit_cmd_mutex held. > > > > Can you give me a few code paths that trigger this? Simple git-grep is > > failing me. > > Basically look at the code in audit_receive_msg(), but I wasn't asking > your opinion on how we should rewrite the audit subsystem, I was just > asking how one could determine if the current task was holding a given > mutex in a way that was acceptable to you. Based on your comments, > and some further inspection of the mutex code, it appears that is/was > not something that the core mutex code wants to support/make-visible. > Which is perfectly fine, I just wanted to make sure I wasn't missing > something before I went ahead and wrote a wrapper around the mutex > code for use by audit. > > FWIW, I just put together the following patch which removes the > __mutex_owner() call from audit and doesn't appear to break anything > on the audit side (you're CC'd on the patch). It has only been > lightly tested, but I'm going to bang on it for a day or so and if I > hear no objections I'll merge it into audit/next. > > * https://www.redhat.com/archives/linux-audit/2018-February/msg00066.html Could you please explain the audit_ctl_lock()/unlock() primitive you are introducing there? You seem to be implementing some sort of recursive locking primitive, but in a strange way. AFAICS the primary problem appears to be this code path: audit_receive() -> audit_receive_msg() -> AUDIT_TTY_SET -> audit_log_common_recv_msg() -> audit_log_start() where we can arrive already holding the lock. I.e. recursive mutex, kinda. What's the thinking there? Neither the changelog nor the code explains this. Thanks, Ingo