Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6646830ybi; Wed, 29 May 2019 10:48:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRkKrJ3AavsSvw7x5F4xCp5IZApxFoc+gKeKxUQzWG8LF+CK+SQKHAajcOOjUT+5tBL79w X-Received: by 2002:a17:902:8f84:: with SMTP id z4mr58888278plo.233.1559152134645; Wed, 29 May 2019 10:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559152134; cv=none; d=google.com; s=arc-20160816; b=IeyYE4sVlDWdCAcQLYDsbdKCyYLBQyb8N54l69dhOgrjQ2v8OlM+JGz2xaHdzHI44b bBpey3TEkSw4FYwELnnYTMgsacs24+BU80qoRl+3pbFKvQMEGLmj1GwSXFBGHY1Lkiy4 ollibqwBopGfyUj4oBk+302KDQJvKg4/qrFYqsUcMr+QRQfo2G+ajkftY7BvgRxH2Xub M3BytMsUAsC4fzvQSKXTE+oVvj44/edoWmprO4bxgZPnXbhCpZBRyKAfQaq7wlw5aQk3 lArmgNhCBIcp8czALzkPgyYMQ+Zwj6fUqAIHoHdgzwBAk60PaXsrMMlO10z58G6fIjma SYGQ== 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=AmI4EFzZ6VT9TOg1cFEHsMHt6YDKL3frdwtue1WA3MQ=; b=dMMUjqNXKelxe1WlW/RUjdMPtxLU7WyVbLEq3qaSyMcXIJlQK1AlQv60SdizQx01C5 +jpyfGRzzGaYLgUHHuo7dwAOSRtENME/U8FPF3bNzTPMuVuo2uielZedmIXkg3g5mTHH M+hJgQ0Pd2C9d61ygMzt+hBvyXRUl2EIG3nIN1xyeOgAzssr04StX6kGHbWO+mdsCiOt JV6QRtF9qb6KVpsTG5I4mhzPk533CxslNl5DCXcAQr9hC4y3rNbCtFL1HfM0GfkvW7Xt 3Xj8XKvfFBtXHEvnOJmhWg06fJqyhJbcYgHAvDCnHnOUQIKMYPTvjhAfI+/7svqCnG9+ XGjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rqEGFjkU; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j11si55197pjs.73.2019.05.29.10.48.38; Wed, 29 May 2019 10:48:54 -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=@google.com header.s=20161025 header.b=rqEGFjkU; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727090AbfE2RrX (ORCPT + 99 others); Wed, 29 May 2019 13:47:23 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:37686 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbfE2RrX (ORCPT ); Wed, 29 May 2019 13:47:23 -0400 Received: by mail-oi1-f195.google.com with SMTP id i4so2402266oih.4 for ; Wed, 29 May 2019 10:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AmI4EFzZ6VT9TOg1cFEHsMHt6YDKL3frdwtue1WA3MQ=; b=rqEGFjkUEFmWfe+Bt5MYFJ/f/Ul+aHmqapx7HwxPLddDX0XutuICprcxl2IRBB+2wZ FBRhjkQhq0l8FGGPbG9iYTwcvG1L0zqWGnLkyYD0QUHtOHVFLuFexbbvf8DTq2cAJwIc qGAeqR/R7WWTblsPDHtqemkbqR/RjKHsE/rp1eLjwVmSOkWL+HLfgGJwRyW90asobQJ4 db628CyWRP0Gbo529Eq/uBkkm0ATyy/7jo4gyJbVRwGvSHZ4DHrUenMmRW4i+hfsltwh /NisW02kiqi8fqH+L1vXF6yr7Zpf/a9SpygycxZqARJe1E3v94fpOSgoJmPU9/JrJi49 HCeg== 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=AmI4EFzZ6VT9TOg1cFEHsMHt6YDKL3frdwtue1WA3MQ=; b=AxWU2EgU8yT1tEjYEi2h6bBe6o+notNuhMsKs7SNYUKVpDLbPS7TaOgFBgAVgp6WI5 qpsoAfVZTOZmK6Oy3ZJdsbUke+Hkiu+tmH7SZ8wFAElbb21iYTmCNTBlwXWxZ5yDLZqW pIQR8fmsmLtT+EvlI0jZjf6KjjYPSuDK7DjBNRf3XNtl3JkJMRmHIgv74oQsvjJHQ3yg u4d2860pnLloVlw9phm35OxxuWxjiB0T9UZZv1nEyp8NpqQuRubutsPorEn66qj0+PZl dBFyIiY/YEUtGrEQp4ST7XEGoESpZPmHFzhcN5Z8ozs7hTzhN/VTJIfM74gd1gs+12eT Q10w== X-Gm-Message-State: APjAAAWnLZFVf5U9y9TUOu/rCMQiSJzqXZ4TCTAOUQTY7hFbGtTA0FhT f27r44ctm3CjLXQiap9cUTxsjuQr3CjBWMiD6EMTiA== X-Received: by 2002:aca:5943:: with SMTP id n64mr58380oib.175.1559152041282; Wed, 29 May 2019 10:47:21 -0700 (PDT) MIME-Version: 1.0 References: <20190528162603.GA24097@kroah.com> <155905930702.7587.7100265859075976147.stgit@warthog.procyon.org.uk> <155905931502.7587.11705449537368497489.stgit@warthog.procyon.org.uk> <4031.1559064620@warthog.procyon.org.uk> <20190528231218.GA28384@kroah.com> <31936.1559146000@warthog.procyon.org.uk> In-Reply-To: <31936.1559146000@warthog.procyon.org.uk> From: Jann Horn Date: Wed, 29 May 2019 19:46:54 +0200 Message-ID: Subject: Re: [PATCH 1/7] General notification queue with user mmap()'able ring buffer To: David Howells Cc: Greg KH , Al Viro , raven@themaw.net, linux-fsdevel , Linux API , linux-block@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module , kernel list , Kees Cook , Kernel Hardening 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, May 29, 2019 at 6:07 PM David Howells wrote: > Greg KH wrote: > > everyone should use > > it. It saves us having to audit the same pattern over and over again. > > And, even nicer, it uses a refcount now, and as you are trying to > > reference count an object, it is exactly what this was written for. > > > > So yes, I do think it should be used here, unless it is deemed to not > > fit the pattern/usage model. > > kref_put() enforces a very specific destructor signature. I know of places > where that doesn't work because the destructor takes more than one argument > (granted that this is not the case here). So why does kref_put() exist at > all? Why not kref_dec_and_test()? > > Why doesn't refcount_t get merged into kref, or vice versa? Having both would > seem redundant. > > Mind you, I've been gradually reverting atomic_t-to-refcount_t conversions > because it seems I'm not allowed refcount_inc/dec_return() and I want to get > at the point refcount for tracing purposes. Yeeech, that's horrible, please don't do that. Does this mean that refcount_read() isn't sufficient for what you want to do with tracing (because for some reason you actually need to know the values atomically at the time of increment/decrement)?