Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4928930rdb; Fri, 15 Sep 2023 17:46:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUelgL7oUYCFQS0u/S11s4lHv/07oL6t6nm5NdKBBA78tI8WKZZFWIaODI/UY2+G1B3lCE X-Received: by 2002:a17:903:26c7:b0:1bb:8931:ee94 with SMTP id jg7-20020a17090326c700b001bb8931ee94mr2846795plb.67.1694825199375; Fri, 15 Sep 2023 17:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694825199; cv=none; d=google.com; s=arc-20160816; b=nQrIBkeHvUyYDRkg2lGYjgMvhv+ddJXOh5u4aBR9CpQCd51oam4j0kI7kCUbu/FpII F03KOS3Uwex0w/OengyaMMYm5D9yyyBWEG3SjoJWgid4nQwheHhkZRY3HstuIjnRRXlg Rd90+6QnzPjyvVJO95rY68Va19joH7fObGYt5BIvwEhnezOV8/JkrxikfRMBTCWn8pLr ylTm+ljegsNFYJarpHJDaVFxJelab1DXSyPn8OVrewVrMKPp8rx5xfOdK1L7e9+D4zaU Jze4c8iWYO0qtGegZVWUFOYZdKHWDTDe+2dQPo+stecePlOWn4IjXDZu1O5F0DO/5ASP fXLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Y1bSlQlyxuFS2ROn3PtZn/oEo4a4ZfAfEmG1nYzItZc=; fh=0T/Cz/6kfzyq4MPg6wrhuDkAsXxv4Wnv+2jNEKRU/s0=; b=zYgf7w9i4X8YZHYsLgzUEdT2ctILUIrD8BCn8OU/EXqYpYfDZUfQOeAwoFYl/zXXNk QNRZ29xTlkb6bUK5wkRbcPnTWhX9n63vBS9LRbrhocanHdR9c/ZLkHHmT7TE0eT3B0dK guDfQBrH/pr32kgujWIRiatC2I/o8ZRzyvj7fTKSPLdRhse/Xjs41XkFD2/ouxYby3nY jkQag5WD7wwgKVny024AV/fNu+sgpfIdNJEuX4YtbCEtEyAwldDfhNdakSTOUUEvdG/9 BZFqXJ+ymQ4JhLVmweYKb9v29Z1VDWpR15Z3oujR+jIClKXDRinCD5vKesKcUFOdcMSY fFgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Lx4wKg5d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id h7-20020a170902b94700b001bbfbe6bf3esi3863649pls.504.2023.09.15.17.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 17:46:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Lx4wKg5d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 92ADB845380B; Fri, 15 Sep 2023 14:19:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237412AbjIOVSa (ORCPT + 99 others); Fri, 15 Sep 2023 17:18:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237470AbjIOVS0 (ORCPT ); Fri, 15 Sep 2023 17:18:26 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 903ACA0 for ; Fri, 15 Sep 2023 14:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Y1bSlQlyxuFS2ROn3PtZn/oEo4a4ZfAfEmG1nYzItZc=; b=Lx4wKg5dYpMu1OC5IesCE0ZTbL awcV0rg8DM4c0wKYQN6uMUK4GrBoL2/H8q/2E86K2JvXPeML78T67ZvolieM8KtP0nQTOcTNmapLP 7hYNZLqq9xAj1AAlt+jTSzzKFdz3L8jbtb7n0Ckc+ZhO74Hr1PGCAE2pYe2BkWyZhksqwudItA9Wn ksCbltbnusatqyf9b8tKDTCH7FOap6mI+gAtQcE4AeUtGybKdH0+T3Ze3jYonBrl4C6HgcDGlRNdy SkMqoAnM6E2L2A1HUIyq9b06+DEpVETLPqqfTkd/MvioUl2utvpEJ4GYdwnUuoMmPUQlQ0CGBFiFK 8mWKFNiw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qhGCe-00C6g9-72; Fri, 15 Sep 2023 21:18:17 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id D88AC300155; Fri, 15 Sep 2023 23:18:15 +0200 (CEST) Date: Fri, 15 Sep 2023 23:18:15 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Bartosz Golaszewski , Alexey Dobriyan , linux-kernel@vger.kernel.org, Linus Walleij , akpm@linux-foundation.org Subject: Re: Buggy __free(kfree) usage pattern already in tree Message-ID: <20230915211815.GA34041@noisy.programming.kicks-ass.net> References: <07c32bf1-6c1a-49d9-b97d-f0ae4a2b42ab@p183> <20230915210851.GA23174@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230915210851.GA23174@noisy.programming.kicks-ass.net> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 15 Sep 2023 14:19:11 -0700 (PDT) On Fri, Sep 15, 2023 at 11:08:51PM +0200, Peter Zijlstra wrote: > But a little later in that same function I then have: > > do { > struct rw_semaphore *exec_update_lock __free(up_read) = NULL; > if (task) { > err = down_read_interruptible(&task->signal->exec_update_lock); > if (err) > return err; > > exec_update_lock = &task->signal->exec_update_lock; > > if (!perf_check_permissions(&attr, task)) > return -EACCESS; > } > > ... stuff serialized against exec *if* this is a task event ... > > } while (0); > > > And that might be a little harder to 'fix'. Hmm, perhaps I can do a class for it and write the thing like: do { CLASS(cond_exec_update_lock, exec_lock_guard)(task); /* allow task == NULL */ if (task && !exec_lock_guard) return -EINTR; if (task && !perf_check_permissions(&attr, task)) return -EACCESS; ... the rest ... } while (0); that might be nicer..