Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp495558rdh; Thu, 26 Oct 2023 07:52:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmw6qk7AU2vTLExY49Wwsd4namV0qjIg935jgjcysjHHZj7ZzQkZHzqzLsHtyf/we2C/um X-Received: by 2002:a05:6808:17aa:b0:3b2:df83:a760 with SMTP id bg42-20020a05680817aa00b003b2df83a760mr23201098oib.41.1698331944476; Thu, 26 Oct 2023 07:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698331944; cv=none; d=google.com; s=arc-20160816; b=EIaV9ejby9E4CLTg6jLUe0C8+AgNUxxrnKwfSNRRGgsLqyfOtt+9V5T3xzTKrrwWpt NcZ45/f8gow/9LwovjcQFFCDzVTKwZP4svgFvMejMLQY1mpn/lIfTSDJpUswG0K++NQu jWis03Uc0SWNETfX/QsuwadwkyycnbxPPwOfdHKynN6j+RE+OiFbkdAeHnyBgdtRksWB AQi5/vOLL/ExJqRSpSp3fBspNOqc6VL/xmzf9+0jRW8+xIioFyRK0fHLNZNjCHXiY8dj RXv+Hm3+qBIyaBlum4WOC+PTJAo89kIoDbAE3i4h/tBDXrianMu62K0LFWcuJytwigfR ADsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=hA6ur+zxVh6hcs3TN0CFRgd8tv2hAoQkgA2OB10Qgbo=; fh=tyImQFIXNyLp6dUZSTER8Y6OuKI7fK9Vu3XqATr6uc4=; b=ldP7fWQmxv4EhwBkdvWiKkhKkLsrnhAKSD/NGV+LSPo8Y/QylrorLLiXZFGlfDASGg YMzgmRi52P23W/YyC/cFtXn0lWeFKL1VeWpX00BNUQdxZXQPFL/u+7gXHnq1+oxwCJ0l kAaP8rL6UhptZC99YRz0xN6eOErjlb7G+Ooccjc8t+sEZnztSeTT9hLnCjno5UtKqoL4 ZJJJEb5V+oRv5LdUEfvDfRIIKeV7d2hR0y3bujvxlSwUK4zg4YQmprm2h085vVfJAlkl yN2743rPHtbvxLNbukASEuwgxdAiLIuH1tzm/ZrOpfWf4LLGLQShkrS4s9/1shO+X4N3 MDgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b="N3P/Hydj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id p189-20020a2529c6000000b00d9cd5c5e635si6586302ybp.180.2023.10.26.07.52.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 07:52:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b="N3P/Hydj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D69898145554; Thu, 26 Oct 2023 07:52:16 -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 S1345343AbjJZOvb (ORCPT + 99 others); Thu, 26 Oct 2023 10:51:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345330AbjJZOva (ORCPT ); Thu, 26 Oct 2023 10:51:30 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F935CA for ; Thu, 26 Oct 2023 07:51:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1698331882; bh=zCxTGeta7j9+1MvbeHs0ufQDzrEJIbaDrDa1lovi73Y=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=N3P/HydjL1+T6To9o5YEwM0iMpG0Rm+7WPyrd2xKnKLLbuXBLpSPzECFGmtYy6VS4 Nr7qxaf2Hyq8573FyuW4FXWFCUUnaKjvtt0DqJ4PSgsfSldgKjTHGhDgxnnIKKcSB+ iSI2JZKAolprbzP7y+esbYx3ITCwrGpB/czXIdu0MXOaeQkRRwaybPvuDbcz0rq6/u M70IBI/CzkgOd0UoNpjXk4nAh5qy4b9s/P2EPlwglsAwtERm4Nokm8IYYR0AMCLPKi wuqPt8LfVF623INmssMMXgAYhYw7aYcn4+Zs3fDRCHnXAJlLfdv/we5cmIa51ULraD EHNE8vH2731Aw== Received: from [172.16.0.85] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4SGTJV2N6Vz1ZXJ; Thu, 26 Oct 2023 10:51:22 -0400 (EDT) Message-ID: Date: Thu, 26 Oct 2023 10:51:36 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] Fixing directly deferencing a __rcu pointer warning Content-Language: en-US To: Mateusz Guzik , "Michael S. Tsirkin" Cc: Abhinav Singh , akpm@linux-foundation.org, brauner@kernel.org, surenb@google.com, michael.christie@oracle.com, npiggin@gmail.com, shakeelb@google.com, peterz@infradead.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org References: <20231025165002.64ab92e6d55d204b66e055f4@linux-foundation.org> <20231026121621.358388-1-singhabhinav9051571833@gmail.com> <20231026091222-mutt-send-email-mst@kernel.org> From: Mathieu Desnoyers In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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]); Thu, 26 Oct 2023 07:52:17 -0700 (PDT) On 2023-10-26 10:06, Mateusz Guzik wrote: > On 10/26/23, Michael S. Tsirkin wrote: >> On Thu, Oct 26, 2023 at 05:46:21PM +0530, Abhinav Singh wrote: >>> This patch fixes the warning about directly dereferencing a pointer >>> tagged with __rcu annotation. >>> >>> Dereferencing the pointers tagged with __rcu directly should >>> always be avoided according to the docs. There is a rcu helper >>> functions rcu_dereference(...) to use when dereferencing a __rcu >>> pointer. This functions returns the non __rcu tagged pointer which >>> can be dereferenced just like a normal pointers. >>> >>> Signed-off-by: Abhinav Singh >> >> Well yes but these need to be called under rcu_read_lock. >> Who does it here? >> If no one then maybe you found an actual bug and we need to >> fix it not paper over it. >> > > There is no bug here. > > p is the newly created thread, ->real_cred was initialized just prior > to this code and there is nobody to whack the creds from under it. > > Second bit in the patch changes one real_parent deref, but leaves 2 > others just above it. Once more no bug since the entire thing happens > under tasklist_lock, but the patch should either sort all these cases > or none. Drive-by comment: perhaps use rcu_dereference_protected() ? Thanks, Mathieu > > I think it would help if the submitter had shown warnings they see. > -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com