From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45]) (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 99AD8449ED5 for ; Tue, 20 Jan 2026 17:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768931770; cv=none; b=C16DZWwy3zEGPDpgS6XGjjmnXx69unkMrXPYBNeGkVX7dKmSYlfm6Sb8bGywjm+/WHWpJcm0X/m3YDpbQszpMfkF6hSnxZhLwwAF0L0MGQ/0wCAsNntfxyNvLnT2wZegQOPyJntewqmCGfiXWtOUAE5+FTzY4giVcpVuuQm9a2I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768931770; c=relaxed/simple; bh=bntCYoY/lWBskz/E4EMaSD5LphJe4tlIc8UXi+CQOYM=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=ZaUxUYVEOUYocauOPfzDV45X42QaDKz9mFWScMN03ejBhIdPYnOOJ5qWQWelJo2I+1xsVruuPpIsFkRg3Y64unTyzeJeVFPBrX3IkhNnkc0+48jT0cGzNATwPSNEhNK2XduZHMnyvDJ2CntFNk74bov3ZDFdN+fDDp25GedEfJI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gR8mMOvB; arc=none smtp.client-ip=74.125.82.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gR8mMOvB" Received: by mail-dl1-f45.google.com with SMTP id a92af1059eb24-1233b172f02so7002741c88.0 for ; Tue, 20 Jan 2026 09:56:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768931768; x=1769536568; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=bntCYoY/lWBskz/E4EMaSD5LphJe4tlIc8UXi+CQOYM=; b=gR8mMOvBYSYs4BDd+EuMw286bxsDrKO4AlPwF9KVstZhN1kymsTmbasIhsPF5of6di /O3mucE5owcpmwBrw7zrhAj1lRzUp8XrV9ZCsS2rwuBgIQeMu1COKMYVsC0+k+Y0q/tT f9VUsiVtLr/yo7A8DMvlBLZmmA2SqtXzYJ/r3tWtmvMXu+aEp5GO+b0oSCIOHkGqfAVG x9t5wmZligD8PQIeUCfahqpVz5NUaJYsGSKVU/cI+ojkRViUnncRrWh7467dLBmaNqNJ YzWzNewZPbM599cBMRIgs6K9lHlb1g+zUqoYmvRx3voaovo8RXtorooaS6vLoeh//FcJ 68Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768931768; x=1769536568; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bntCYoY/lWBskz/E4EMaSD5LphJe4tlIc8UXi+CQOYM=; b=eSUtAC1cTBLDKanJXnS4zJ+6XbffTrwUm1UAQmBBr8j+yaxlD3d8AHeN/PJGICYbwa O4SnnfWBXpWBUBKl+UDDPz2I0WI1xSNVirjobbHchwxLqakwAZfoKBoTBOz/FLUFjyyc KZXWEHU92E5H7UTY/aTzhYO5RFFEs2Vspz7HzmW5uzvAaGlcMIl2vAGTSE9mpPq3a9Is nuae+8LzM7itEzxgH//ir7WqtXVov7BpOmozPfEcjMpa7yD3L6HSs0qhJXp45ZYrwfvO ucyngsUDcNd8U/OjP9A0YYOUXjrj2Aqw30V3MKb4ST/we2IhSpJS4fUI8wJqyS2mfMc/ YtSA== X-Forwarded-Encrypted: i=1; AJvYcCWgPI2fnolOSHFokHQagnoarm0J1AoyKCpVcrddDCEGMKaFZssJAU+pEDnG3PuSwXLeK5lVcQtJNWg3cksKllcopO0=@vger.kernel.org X-Gm-Message-State: AOJu0YwoqdYiSIC+l91LTOv2vP3sqdPgAo0bLMlhIsXqW/WkX/Y9NhSC GeSfRuUhQzmk8oYD41cqwcEhix1S092nCuknqGk5tER+EtYk8xhI5ZtW X-Gm-Gg: AZuq6aJhSs33GwDVapkipAKhIushsG2vbFCP85lrL8z8susgSKdNeZF1CUY+Adjyibn aJ4qMYAZG0Dc5onBg0MsRs5bTBhQTC9hAkWXlrR4q51X6mnom+ikYHtbQI7Ea0UgXAEyQ1i02kk gHxURNLmmc3Mu+tRcBMTy5Way7jBau7J6LHI5nJa03ojO2h/nLrQmt0ll3h8zP/5fM268eZU4KZ HIV1KN9ZNZrExR0lwqNDy7uSLmcNIfXGXLbrj2fH9RklzwPP/eC43redYrA3fEUmM7BOWQJgW0X RkXDpdmDl6Sozn4MgFTCKQC8n/YkAGV4kSY184QLNZ5/e7PgOM9aoTF7NdjcmlTZq/JxHQDfavb 2kCMfs35JcsBChXwPRe8AewBV+k4WTiMrudJ+h6lHFI+9QZSoyN4GY4VnzzskkS2EiZKQhDIlXj Y5PsuPM3lbVnBk9Czi1B7RHnwafObykLormyzfCFI4BIpOKZ0cQvWHXCvqXmXFQ8vLUsAN X-Received: by 2002:a05:7301:7c0e:b0:2b0:4c12:d74d with SMTP id 5a478bee46e88-2b6fd746d53mr1663983eec.15.1768931767667; Tue, 20 Jan 2026 09:56:07 -0800 (PST) Received: from ?IPv6:2a03:83e0:115c:1:b08c:bb3d:92b9:704d? ([2620:10d:c090:500::3:93b1]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b6c2de1f29sm16004104eec.15.2026.01.20.09.56.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 09:56:07 -0800 (PST) Message-ID: <00d9e1ea7e4eef7a7891200a03e99083cdbd066c.camel@gmail.com> Subject: Re: [PATCH bpf-next v3 1/2] bpf: Fix memory access flags in helper prototypes From: Eduard Zingerman To: Zesen Liu , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Matt Bobrowski , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Daniel Xu Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, netdev@vger.kernel.org, Shuran Liu , Peili Gao , Haoran Ni Date: Tue, 20 Jan 2026 09:56:03 -0800 In-Reply-To: <20260120-helper_proto-v3-1-27b0180b4e77@gmail.com> References: <20260120-helper_proto-v3-0-27b0180b4e77@gmail.com> <20260120-helper_proto-v3-1-27b0180b4e77@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.2 (3.58.2-1.fc43) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2026-01-20 at 16:28 +0800, Zesen Liu wrote: > After commit 37cce22dbd51 ("bpf: verifier: Refactor helper access type tr= acking"), > the verifier started relying on the access type flags in helper > function prototypes to perform memory access optimizations. >=20 > Currently, several helper functions utilizing ARG_PTR_TO_MEM lack the > corresponding MEM_RDONLY or MEM_WRITE flags. This omission causes the > verifier to incorrectly assume that the buffer contents are unchanged > across the helper call. Consequently, the verifier may optimize away > subsequent reads based on this wrong assumption, leading to correctness > issues. >=20 > For bpf_get_stack_proto_raw_tp, the original MEM_RDONLY was incorrect > since the helper writes to the buffer. Change it to ARG_PTR_TO_UNINIT_MEM > which correctly indicates write access to potentially uninitialized memor= y. >=20 > Similar issues were recently addressed for specific helpers in commit > ac44dcc788b9 ("bpf: Fix verifier assumptions of bpf_d_path's output buffe= r") > and commit 2eb7648558a7 ("bpf: Specify access type of bpf_sysctl_get_name= args"). >=20 > Fix these prototypes by adding the correct memory access flags. >=20 > Fixes: 37cce22dbd51 ("bpf: verifier: Refactor helper access type tracking= ") > Co-developed-by: Shuran Liu > Signed-off-by: Shuran Liu > Co-developed-by: Peili Gao > Signed-off-by: Peili Gao > Co-developed-by: Haoran Ni > Signed-off-by: Haoran Ni > Signed-off-by: Zesen Liu > --- Acked-by: Eduard Zingerman