Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp516239rdh; Thu, 26 Oct 2023 08:18:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF22RckHpzLZxOCIExKKqFF/kyzLh0cEgQS2yG0aY4O9i8nAQLUm/oLxTA2fj+Tsd8JS2YL X-Received: by 2002:a25:cb56:0:b0:da0:97d3:4e2 with SMTP id b83-20020a25cb56000000b00da097d304e2mr3258291ybg.42.1698333505429; Thu, 26 Oct 2023 08:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698333505; cv=none; d=google.com; s=arc-20160816; b=IK25ViXTqR810Ju9z6zHO8nQuGFQg/zcX6vkBApDJrgsW5ZmzmFbrDqDx7ulmd/E1F fk9R22Gg8jSwE9XE7gPpwe6BuW5siKQqj1Aj2m33oYp/NYb/PpzAATrLha/FBJYnY6Bz tjgKXqxEKgNQa2WazRGCOcYAJsWYsY94M2mgdPg1IYJxUY9OjAiWjrg71s6/K8g2P5h8 k4BzInDLTVVnOP+50Ej8kMnmtXi9OnMzGd05QyCCiS549iw+kGZMNft33eSvbEvPWdlb qtVW/f8QXdzv25fsW5yYA5Tipo5N1OcKxBOI+DSLDmg2Hx6lY6WyKphFXSN72Y2T7eQL 5IaA== 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=fgM36SpZwrGqrgTUTrL8+qbWVWryBY61X1wo6VnsJ+g=; fh=1TjdUOm1foOJ0WwYIr2gZW97hRyLRuVZs4Ly2SRxsek=; b=Kkvm5bUcKUJKhnzJNlxdsBkjluXtVxQ2s5fZM4PrUiiXzd2ymgtAb+ileiCtPna9wv lpypQ9G86ir4CDDeVpxAMcwN610b0vBssGH21fKyj5KUkRD25V0ixuSxh5n7oVFZcHSA A7q6d+hhgg8hhJ2fNiN1Ioe7U6HIzaNF/J8grcCSj76aNnK9pFSQOmUGr3xR/G06xCRk ctqU7oDmvGtr1hL9oATsPCKgTh/YRx1n6dwHV8kQQm6HNrco3TCT9jvxwV2Qt3UM92xx 1qB471siqvWTuS3xdU4a4YqYQJymvqCXShjpMVfO+y+l/BAbenIvv76hUQ/3or7U+v5R qrLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RhIfrT3+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id 131-20020a250389000000b00da0514a0593si7191822ybd.474.2023.10.26.08.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:18:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RhIfrT3+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7A3B682157A1; Thu, 26 Oct 2023 08:18:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345399AbjJZPSN (ORCPT + 99 others); Thu, 26 Oct 2023 11:18:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231347AbjJZPSM (ORCPT ); Thu, 26 Oct 2023 11:18:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2494D7 for ; Thu, 26 Oct 2023 08:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698333444; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fgM36SpZwrGqrgTUTrL8+qbWVWryBY61X1wo6VnsJ+g=; b=RhIfrT3+Ssj7aU0BQFKvAbVC+pxj299g9XfwlvFuKCsPgkEnelrcx8kgyDcArqwiA+asWM OE2D+Mmu6nrLWAYgsMcn4A3IhpFB5Im4vOYshSYSdr0xkSDnSyub0Z5/C28zb+/ZnX/Y87 i3AJEMDE1XQIFQ8PbV+nMOTOY8lEbSY= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-582-yjZ39dIjMbOfvDQibIEnqA-1; Thu, 26 Oct 2023 11:17:23 -0400 X-MC-Unique: yjZ39dIjMbOfvDQibIEnqA-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-53df95eaebfso758515a12.2 for ; Thu, 26 Oct 2023 08:17:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698333442; x=1698938242; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fgM36SpZwrGqrgTUTrL8+qbWVWryBY61X1wo6VnsJ+g=; b=hwmbasl5YNeE3wue8j8aiCvd4s2aRCeaKPTQ5v0ZSi+KPLvU/w8mUr6RnEdjySy9tP OYDVTefsEIeImz3Yv89MBy4vpxYi4ZF54YU6/DOErC7vn6sloOYPsYOXJZ9rb4Br3eMh Yey4qUdIJcAyi/5q/InvmufatQEVEo1xixk4uI4EF+Xy5vnRhNA6LPqW6d6bEGLBWXeL LEB7Lfkm8D5jJgSn1CUsIaLQefFtRHOpucsWGePV4LyCBjhBQWYl6RocJZH5aXBWQ3wV uAQm/xg8ZCH7YDAdGXvFEQKcWdXr9K5L02WPPi5pa6wtPYmuJCDenP+mpB+sI8EG/e7z 056Q== X-Gm-Message-State: AOJu0YySFSdWA35B9qBYFr4os7dd4xp9LlF0XtQ6u9ACnjZFQ93DV1bj DAWYNLUNgU6bhtzj8MqxDH5OFYek99RqHH8njSlzIH+iEl97dGHHys65Sb8WdDch8V2r73ioJky Zm8Oy2TT96A9UUc8eXuh1dYfg X-Received: by 2002:a05:6402:a54:b0:53d:d799:641 with SMTP id bt20-20020a0564020a5400b0053dd7990641mr42927edb.26.1698333442294; Thu, 26 Oct 2023 08:17:22 -0700 (PDT) X-Received: by 2002:a05:6402:a54:b0:53d:d799:641 with SMTP id bt20-20020a0564020a5400b0053dd7990641mr42908edb.26.1698333441671; Thu, 26 Oct 2023 08:17:21 -0700 (PDT) Received: from redhat.com ([2a02:14f:17b:37eb:8e1f:4b3b:22c7:7722]) by smtp.gmail.com with ESMTPSA id w12-20020aa7cb4c000000b0053e7809615esm11362265edt.80.2023.10.26.08.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:17:21 -0700 (PDT) Date: Thu, 26 Oct 2023 11:17:16 -0400 From: "Michael S. Tsirkin" To: Mateusz Guzik Cc: Abhinav Singh , akpm@linux-foundation.org, brauner@kernel.org, surenb@google.com, michael.christie@oracle.com, mathieu.desnoyers@efficios.com, npiggin@gmail.com, shakeelb@google.com, peterz@infradead.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, "Paul E. McKenney" Subject: Re: [PATCH v2] Fixing directly deferencing a __rcu pointer warning Message-ID: <20231026110925-mutt-send-email-mst@kernel.org> References: <20231025165002.64ab92e6d55d204b66e055f4@linux-foundation.org> <20231026121621.358388-1-singhabhinav9051571833@gmail.com> <20231026091222-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 26 Oct 2023 08:18:22 -0700 (PDT) On Thu, Oct 26, 2023 at 04:06:24PM +0200, 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. > > I think it would help if the submitter had shown warnings they see. Yes, and this must be tested under lockdep, which I think would spit out warnings for this patch. What should be used here I'm not sure. IIUC rcu_dereference_protected(p, 1) is discouraged now? -- MST