Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1508532imi; Sat, 23 Jul 2022 07:50:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sNGiaPg0b3DiEmKtYtkwcoT8DIoRG/7n+pC25Vf9s6cxFE2ugC9hXiwsYTZAtwsNbuQBDb X-Received: by 2002:a05:6402:5289:b0:43b:69a9:38c8 with SMTP id en9-20020a056402528900b0043b69a938c8mr4843570edb.263.1658587808840; Sat, 23 Jul 2022 07:50:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658587808; cv=pass; d=google.com; s=arc-20160816; b=f2Hj478X3WTcmD1Rz7vN0/RW6cQ7T0JvJqSlzghRol9GNJdkBrKQMgf87bnPAq8A1F EtlEpRUgI8WEJBxSsxQG1gPA8uVvIugq/jPgGfafDWQOj8hi6KcCmP1wx/SvWnaYGHx4 oYA5dwvaW9UGyTGjYYDsyJce3eOTxt2nPqLsaAwDTTH4GbGLBaXpuo1F2frycLkyoPjX d6OGUTyQzCWsaghXtLTqLT227TXClMg6HwLlmjcOTkZJCdwyWQHI+GZCfVFKVg4dyK7E hfdWUXHVZ3oE4IMdU2vbCx2SCszWxnKNE5eCUJPw5P5uGXSSYHFjiXcJRJASV7TPYenQ nkLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:importance:content-transfer-encoding :mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:dkim-signature; bh=+F8VEZ1Z9Pj1QEwW5vQk6MFoPQK/TpHHEams4IFBR5o=; b=zK1vgQMoTCglLC5hEuknJGCfLXkhC2UZ5V9oiiELRIUVpo00wYhvLwCU4uBoLH2Yq4 Vtaw2xyA6wUGqggrJZa+YuKyVe8uxxnejCTbcvLZDJKFCyYRI2gDwKQk2ctD/BQvmYE/ uCH8FLonfn9pnoJqqJFL4X8cn0cW9f031WLGD1GDaY2Ux1fKCiPNmC7/FA1wJq5sGOwc Q1qBGA4wTSiFEXOYzDuHpVSjtCi3onnXQ3D0BMDZZ73GV7tf+QFX6dLBGxaS5ZL43brO Jx1s7sCyixAVFANNZivQe7a5vhotdi0f4N7bZsK1O9n0ySUFdI+ZUYLWzx9iTHC5cWJ5 cGNw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=KbKtqbec; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siddh.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg2-20020a1709072cc200b00722e82edf14si10359031ejc.14.2022.07.23.07.49.41; Sat, 23 Jul 2022 07:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=KbKtqbec; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siddh.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238227AbiGWOgL (ORCPT + 99 others); Sat, 23 Jul 2022 10:36:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238214AbiGWOgJ (ORCPT ); Sat, 23 Jul 2022 10:36:09 -0400 Received: from sender-of-o53.zoho.in (sender-of-o53.zoho.in [103.117.158.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22F4EDF44; Sat, 23 Jul 2022 07:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658586938; cv=none; d=zohomail.in; s=zohoarc; b=P14KMg7Zc246bVkhisdefrW6lxfNpldYDDzSVYqK0RNGk9phCJMo14SjMus4YHD71M+5L2KIkmKCotIBvpC75T1AV0i/xtcICFJGXTWecTOBXJJ1dF/pG8KgRV7i1n/G/MOCTYB3TdJ09BvyjejLMcRnvVEubEF7XMSqSBdlUvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.in; s=zohoarc; t=1658586938; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=+F8VEZ1Z9Pj1QEwW5vQk6MFoPQK/TpHHEams4IFBR5o=; b=FxX9ttl/jntH3qcSUk2myZJl+keN4fVeE4RmdRYUXjqmBShsPp5xdWWBJO8yV7vMbAQuVqi7IPRVCQSdDEspii/9GPc30fxqNgmvcYD6QR4ZtlanEvi32HmoflggMi5YW4yZpa1aKalHoe4nLyMSQbg9FqmEws7cx0Q9V+2qtSA= ARC-Authentication-Results: i=1; mx.zohomail.in; dkim=pass header.i=siddh.me; spf=pass smtp.mailfrom=code@siddh.me; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1658586938; s=zmail; d=siddh.me; i=code@siddh.me; h=Date:Date:From:From:To:To:Cc:Cc:Message-ID:In-Reply-To:References:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=+F8VEZ1Z9Pj1QEwW5vQk6MFoPQK/TpHHEams4IFBR5o=; b=KbKtqbecy0QVLwF36Avuvq0fq3nBQzaO+KqXMun669P08qJxDt7fvskseBUZ4R7t cTs6071CJGosVhZvQ8XdOnOXoaVh2LQncYcURGrR/WZQY3cuz8PAOwLIH98iv85dnFb VFUYNXf4lA5olE3VDQVY+gjJ0JHKYPDTkaOu+WPU= Received: from mail.zoho.in by mx.zoho.in with SMTP id 165858692779635.69655596083135; Sat, 23 Jul 2022 20:05:27 +0530 (IST) Date: Sat, 23 Jul 2022 20:05:27 +0530 From: Siddh Raman Pant To: "Greg KH" Cc: "David Howells" , "Jarkko Sakkinen" , "James Morris" , "Serge E. Hallyn" , "linux-security-modules" , "keyrings" , "linux-kernel-mentees" , "linux-kernel" Message-ID: <1822b7c129a.14411444236159.6380883938307880248@siddh.me> In-Reply-To: References: <20220723135035.199188-1-code@siddh.me> Subject: Re: [PATCH] keys/keyctl: Use kfree_rcu instead of kfree MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_RED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 23 Jul 2022 19:35:16 +0530 Greg KH wrote: > That does not explain why this change is needed. What problem does this > solve? Why use RCU if you don't have to? What functionality did you > just change in this commit and why? We can avoid a race condition wherein some process tries to access them while they are being freed. For instance, the comment on `watch_queue_clear()` also states that: /* * Remove all the watches that are contributory to a queue. This has the * potential to race with removal of the watches by the destruction of the * objects being watched or with the distribution of notifications. */ And an RCU read critical section is initiated in that function, so we should use kfree_rcu() to not unintentionally free it while it is in the critical section. > And how was this tested? It compiles locally for me, and I used syzbot on this along with testing the other `watch_queue_clear` patch, which generated no errors. Thanks, Siddh