Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1084560rdb; Tue, 19 Sep 2023 21:41:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjViyPeSjj1AaRWEiwyIvey2rlJXjbgctCjnuCka4AzoTk8d47goKG35Ueu+4dj/aNqZfc X-Received: by 2002:a17:90b:11d4:b0:263:3386:9da8 with SMTP id gv20-20020a17090b11d400b0026333869da8mr1280916pjb.49.1695184861231; Tue, 19 Sep 2023 21:41:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695184861; cv=none; d=google.com; s=arc-20160816; b=xgtlufU7sMQWoVfw6028gJ8W0DQiUf0Di9jwlQXJVXOLTGC2tJ79AbhN1mK7UmVmPm blxnIOuTGnWxWh1eB97h274bcTlthp00tsLvneBln0WKl5GRekoeURrMEU8tDNmATCNs 3cATb8fxBB5fG5yDO32pB7vhqPWnGC84B6MPqUc1PWGstE84Y7bhuS7GeBcwB5v483/I rDvWDT1e1g7A55EEl2NDT2MUXNdy3uwQEzFYFamxE5eEuSyGnjRwaxLjiZcfb6tlHmAj 4Fmp4rjPW9CzBsc6z1/D9d3xrYzKxQt6ZfAzOZJJdgDVEVIDZ/coekYOcaP251TekxBz ZFLQ== 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=Ya0NjT0hID8cNaHUIIbnzb7CSLwCFD+xdaWNcnIycUY=; fh=0T/Cz/6kfzyq4MPg6wrhuDkAsXxv4Wnv+2jNEKRU/s0=; b=pxKyzT2+6aObwd5ldoQNP77bEI263NLmwlZZr0QSozoXMZKRQpGEI/PR5/EDBKqCZa HdY9CwVxN3bKSOgHHKTw7IgF1Wiy7GdBR8YueIdQIQFniyaW/5kSE6LHNiPpUIm+ApNO Qw8XA7OXLmy6k2whZNutDVEswxV/pehiEUzJ2r5bl4l0vnvb735BXIKVTbPcU3LzjoyU wXPqSGpn50CvMaYhiCKbU/YQFB6UcjXCLVmbmZaUwhE03SlSVWdvYLGiE03y7+ZhUYQT y/ATsP5gtidgXGT47h0slnymSPJW9E/iytbxHG6LA0AHVOwF04fB3zbHbZ5BXP8zoIjO nyjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=FdcuBr5T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id b24-20020a17090acc1800b002747da1ef66si733290pju.53.2023.09.19.21.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 21:41:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=FdcuBr5T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 5B98881F2771; Tue, 19 Sep 2023 12:35:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232804AbjISTf3 (ORCPT + 99 others); Tue, 19 Sep 2023 15:35:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232790AbjISTf2 (ORCPT ); Tue, 19 Sep 2023 15:35:28 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03CCAF0 for ; Tue, 19 Sep 2023 12:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=Ya0NjT0hID8cNaHUIIbnzb7CSLwCFD+xdaWNcnIycUY=; b=FdcuBr5TM8FRW/ltzRkEy1H7H9 mPibmiHL/PsA6Q1i+6uQGZwmh0Z2ugC3FKG5OC+Huv+oWT/wMgS1RjOoEr6AyCT0VUv0q+61OlpN0 AKSjWnX8OQYFpSXALWWjSVRKrF3olJOa4ChlEbI5oBI/TqS2hdLL2OL7GI2QQ26GMIx9IVc/x5mNL 7FA8Qrp0ujYigEEwmvmHINTOQ80/3YwNamEFI/dsOQyF2+ohgozO5QkKaVInAzzeS67c7vk7leL2w 9IqDMlrS55zxFWZ+hiZgpllynPhmVPftQyJ7oJECwHkTENOuYHQUdz92CZDmgvRM4LzEPM9U5m0UH phBGdapQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qigV9-00Dqne-15; Tue, 19 Sep 2023 19:35:17 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 58E3A300348; Tue, 19 Sep 2023 21:35:16 +0200 (CEST) Date: Tue, 19 Sep 2023 21:35:16 +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: <20230919193516.GA20937@noisy.programming.kicks-ass.net> References: <20230915210851.GA23174@noisy.programming.kicks-ass.net> <20230915213231.GB23174@noisy.programming.kicks-ass.net> <20230915221332.GC23174@noisy.programming.kicks-ass.net> <20230919125752.GA39346@noisy.programming.kicks-ass.net> <20230919125954.GB39346@noisy.programming.kicks-ass.net> <20230919131038.GC39346@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230919131038.GC39346@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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:35:30 -0700 (PDT) On Tue, Sep 19, 2023 at 03:10:38PM +0200, Peter Zijlstra wrote: > This isn't exactly nice.. > > I tried something like: > > scoped_cond_guard (mutex_intr, return -EINTR, &task->signal->cred_guard_mutex) { > ... > } > > Which I can make work, but then I also tried to capture my other case: > > scoped_cond_guard (rwsem_down_intr, if (task) return -EINTR, > task ? &task->signal->exec_guard_mutex : NULL) { > > ... > } > > But I can't get that to work because of that extra if, the not case > doesn't fall through and do the body. > > Anyway, I'll poke more.. #define scoped_cond_guard(_name, _label, args...) \ for (CLASS(_name, scope)(args), \ *done = NULL; !done; done = (void *)1) \ if (!__guard_ptr(_name)(&scope)) goto _label; \ else Allows one to write: scoped_cond_guard (rwsem_down_intr, no_lock, task ? &task->signal->exec_guard_mutex : NULL) { if (0) { no_lock: if (task) return -EINTR; } ... block that holds exec_guard_mutex if task ... } Still not exactly pretty, but perhaps better than before...