From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 561CA28C849 for ; Mon, 5 Jan 2026 21:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767647065; cv=none; b=BzmIwAu870kAh5vhdm4hiEmKp4PN4AYyYxwymY1oQCf7YnpyxpJYQNcDegLs2jZR4vLQ5pJ8FBMfQ+hgVfQS/S0xrcGibzJYD7q1eGDcZQ75sLO4N05r4ERIyMitwurXtXYzZG21XW6dlrJFmrTN15feFeCaDPS0peLr2Z6Za+k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767647065; c=relaxed/simple; bh=ShY9KNnVLQ0fyXnGBHmt441cvYVse0oMts1K7E3gVCg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=C12rTrOEUCR4HwpC5yjk+BOilj4aRMCmHRdNWiVC9IqLIqr9JhnVHzcacJS54LfYbmOi6s5prvWfy9euc29K0infS0Aykz44h9Z0Hb2Djhj3PSJ4xfUZOjfqqh8wa6gOTW6pu2L0YUD+Xqt+DDP1cU0+72gExZW+lUHlwDAYy/8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jLlJwdml; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jLlJwdml" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-b73161849e1so68974066b.2 for ; Mon, 05 Jan 2026 13:04:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767647062; x=1768251862; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=8Pu0j22Ua6/B/af/fCm8aYXRd0QaCIL2/BGIXkmKA6g=; b=jLlJwdmlHUut4OPzz3tjnc7NGndR6e8ORkIZKxYOOE6LV72i3ABdclu4/xcOM+g03O ui932qzTAQYgpkHmC/dAdSE/IdIzzz+L0IdSz+cKYuTQSXFSCovk3vBTiinQQCaFLkq0 HkcNcAcy9sJ6Oprks4jYMqVqqgRuDEFsPw/ibWRj0k9VByPTsgwiG1v79+EhuOdrjn2P pTEbKbw3cN5QtlSLVOUEcONn+EtP70D1s39NecJoY5O2RBLUj3dbYijmrVu4uUC55xA2 olBkeB4qDGRdHvuJVdu43YdHnJpfBoITOa3zDE4iD4xcfipA85+iWwHYGVDHrSDYZDZA Y8DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767647062; x=1768251862; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8Pu0j22Ua6/B/af/fCm8aYXRd0QaCIL2/BGIXkmKA6g=; b=SJMgYirOCrN/3Ct/vhlaahflW3b1cNv4XLm8c0P/dh0if1ExX+3ur8cjv9NzjwthF3 xXucYNtjQ5TsVcZJqCkRwwuuD1mJ92361bNqRsaIyWZB6PpSc0/Lt3iJQnmWL4r72GCB ZcstzO3Ppv5eeJtDniojHKg9hHyH4yI7zpALYgtYB16c7V6HlIRfTtzx6LNR7MGxQ2Vb mtM7RzRid1b/CvmBt7+eD9aQ6AXbe3nSpFYdxOVVovcBoqDyCSMChETUnTA9E9JibTS2 YHEcE+/NP5qd1fXwxTppQz+4Vosz/2QUChhw8o8XbZ2tLfrS9dFUEk5HKO+nVI9xrJCa HA+g== X-Forwarded-Encrypted: i=1; AJvYcCVezO1w4kGxp1P7F/qYAP1GOwkqjHQr+tuFyaRuTBAqxaLW8AbFdZIJI7GkX8G9qgsfMdzNUAxQjwfzZq8=@vger.kernel.org X-Gm-Message-State: AOJu0YwjiUYA2VHtkUI0rEdflIoZdRfw+CLrkK6B3s3cHH3YE49PnoLf fjFDtCD1yRRbIIIJCvgnzGX8BlHzGGmC/TE7iDTu1axDUQ0Jg3JqM+P7/Z8YmiyblA== X-Gm-Gg: AY/fxX6I84eNKhZHSaq7UkGZM574TL5AJ/V4oFiCHMVOuXHJzjsoyEJSca0qqd2Uale NT8snqJMtarC9eF/3gYmDwq5vZCqkxlfKMffs5mMrMXwHEKYeWlc9G+L8PrXvQFmI/2wc4e68SQ 1BdF0fQoNYiKkvO8ZnSAuA3RIWmwf/bnuaZoJO2TBjJ3+SR18r4QC/fQoM4nfiAS2O7D1CXA00b uzihzQt2V9R45gqw+D3ScvvnV4tsV3WYqOJmbLlqc3EJ4IKlshN13ldd3cEjjogPeJzu4eKoV2g /DICGGMvuT9bK7gpJ3H08MzmlB45yNGzAxVMv6Tmhg7j519gGq6e64XGHkgRDpwdL9AI1zCkpIA 8CwWwSp+HxWMHT0pwP3zEe2+FjNA96NuU10dABt2AyLVDvDe/e5W7ioJVXmhdhYKDTjDbJoezVP JhIG+JAtAP1ltRwxPe/dbiYBJRkboqB4A2XuW5QdUztLAfIZNNJMhf4A== X-Google-Smtp-Source: AGHT+IH5WTn41lg95uujB075zzBoLd9HIlELS6iNanZ/1oj+Lg79QDlEASfdo8DVdErdLUKvHN7/MA== X-Received: by 2002:a17:907:70c:b0:b73:80de:e6b2 with SMTP id a640c23a62f3a-b8426bf10a8mr113572266b.31.1767647061473; Mon, 05 Jan 2026 13:04:21 -0800 (PST) Received: from google.com (14.59.147.34.bc.googleusercontent.com. [34.147.59.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b842a2bc6bbsm29697666b.27.2026.01.05.13.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 13:04:21 -0800 (PST) Date: Mon, 5 Jan 2026 21:04:17 +0000 From: Matt Bobrowski To: Alexei Starovoitov Cc: Kumar Kartikeya Dwivedi , Tejun Heo , Roman Gushchin , bpf , linux-mm , LKML , JP Kobryn , Alexei Starovoitov , Daniel Borkmann , Shakeel Butt , Michal Hocko , Johannes Weiner Subject: Re: [PATCH bpf-next v4 3/6] mm: introduce bpf_get_root_mem_cgroup() BPF kfunc Message-ID: References: <20251223044156.208250-1-roman.gushchin@linux.dev> <20251223044156.208250-4-roman.gushchin@linux.dev> <7ia4ms2zwuqb.fsf@castle.c.googlers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Jan 05, 2026 at 08:05:54AM -0800, Alexei Starovoitov wrote: > On Sun, Jan 4, 2026 at 11:49 PM Matt Bobrowski wrote: > > > > > > > > No need for a new KF flag. Any struct returned by kfunc should be > > > trusted or trusted_or_null if KF_RET_NULL was specified. > > > I don't remember off the top of my head, but this behavior > > > is already implemented or we discussed making it this way. > > > > Hm, I do not see any evidence of this kind of semantic currently > > implemented, so perhaps it was only discussed at some point. Would you > > like me to put forward a patch that introduces this kind of implicit > > trust semantic for BPF kfuncs returning pointer to struct types? > > Hmm. What about these: > BTF_ID_FLAGS(func, scx_bpf_cpu_rq) > BTF_ID_FLAGS(func, scx_bpf_locked_rq, KF_RET_NULL) > BTF_ID_FLAGS(func, scx_bpf_cpu_curr, KF_RET_NULL | KF_RCU_PROTECTED) > > I thought they're returning a trusted pointer without acquiring it. > iirc the last one returns trusted in RCU CS, > but the first two return just a legacy ptr_to_btf_id ? > This is something to fix asap then. No, AFAIU they do not. These simply return a regular pointer to BTF ID (PTR_TO_BTF_ID), rather than a formally "trusted" pointer (which would carry the PTR_TRUSTED flag or a ref_obj_id). scx_bpf_cpu_curr returns a MEM_RCU pointer (via KF_RCU_PROTECTED), which is somewhat considered to be trusted within a RCU read-side critical section *ONLY*. Kumar/Tejun, Please keep me honest here.