From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 D36CC3F9FB; Mon, 19 Feb 2024 15:06:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708355203; cv=none; b=dMe8rxzB5nQaTY6CD5JqMW/C0RnqTHydzWcjpXMnkyGZ0QT91GAoE+vBqz+TIoJvhwROm0YBsQ1R/E3D/pRP4+MdeOCNY7OQEIfvukKqmpwMkIZVkW3Wmf+yOraPDPuaruM1LFjsCNol94nkjQWTW5tCDdKa3unJuYsJY9l7xMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708355203; c=relaxed/simple; bh=nJGhWNzAdmlA3lSqk7zXCDQYN188FpjuKH/iLDfwq2c=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=ad1jEjYAc9WuiVrQvJ4qnHh9A0BtkEI8bZ+py8eHuP5mzKY8DNu3WXLG3+RLeRfTEQyBKVg2G81JMFxytYNQNI3MRtwL8LotOx633l9uBzItpgr6W4HJKuSUG4l6CXLp2tp9+7/Uyr/UX/tTRVAZzMUSIHUZAbrbozJDh/gmiJU= 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=LUODdbyZ; arc=none smtp.client-ip=209.85.221.41 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="LUODdbyZ" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-33d61e39912so167090f8f.3; Mon, 19 Feb 2024 07:06:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708355200; x=1708960000; darn=vger.kernel.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=+yOTnLimYUvPNkTFJn38nSneD1s53IeoM0jyre9BMIA=; b=LUODdbyZc0pEfVSAgx2VGvR6lMov2ggBmoSF/ZjJzEbE7w9PvfkONZmmFTgtMuPWGG 7Z1tTJSL/YOBww6XBbHeAFv3eRcbN1g9us2cc6aL/RmPw3rz25xB6tzwUSiMGTb5ZpER GXfrXVfCdOhKCmZO19VTQOmotMVjHdyema14bct92dqfz9tA+G6Br2YaHCYMuOHrII+9 kb6lXzZ2WOg0viqBwDzqJdmeq7GoZOHFF2o06zKziifQ0pURjF8o51PpM9m+rbJqPAG3 VCj6frLih4Q9SoYWpRARBRfFOVn/+U+BiHqz91rETT89QVUFJC9SVRBmlpEOCjWeKfQA hRGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708355200; x=1708960000; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+yOTnLimYUvPNkTFJn38nSneD1s53IeoM0jyre9BMIA=; b=nT2AO3m2wby4cpEl+tqNEswQD7tvI8gTTXssxm9vUxwHdH2k4Y/xorVsgMd8PsQ0iU 2ZzX6EahM9AvGUtoMdZUJBWsxPBzoF2ePt/knU7gg+k39kPvGa6xvdmKTlQ7kSrhR5su usDCWsBPr5ZQa1HMyAIBytGMd0t7TPc5ntpaHeqNtASbwaLOBnwOcgaPmc0ZTTi8p4yw FTEh75gDAse6/8RdccjrISs0mKmUGf+lGpeCcnj1dnEc4OcD/8jyjdbCUXoFo4B+oR5t MJzZH3kNc1vHHbMUGcnORajLVc1qPDOc7JgqUGQon/6rVIoeQGgvREtNdS5EdojcL6nO bxfQ== X-Forwarded-Encrypted: i=1; AJvYcCWjIc0bkSUAVxTM7kS4zv2ehKxVf64s6kEQb/e9WsEZ2a+TES/NZFW03XRElYl75QZtH8tmrpvJfAulSCc4bl27VkTpJ5VJAW6mxilKqM62PdCx1D8N9mxCQeAhND27zpoYsAi8A68C8K4Eu96dpUmxBvVEz91rS66YVYd6V1ltw6I9XCmGm7KfO++Qq6kYFKJXhPCb9A34IlxPyeJa1wne1c8+R8zSuGN3khJZs9Y7nAI8jc31dOR9ltrGcTDnzYGThg24lqg5yfnLw0fL4F26E4N/qu5pJfNvzfuirjKTAyhyfm2WSSt1Gu6NnJ2welS7j360K79JQElItPZIOSv7nhVJvBil99JN7IpF X-Gm-Message-State: AOJu0YxT+/4jXhCEFolXtkUYErPaO9ky+HjkLU9oiKC9Jy/p0tHw1x22 YgYyAvmsVQj53ik3IyFTH/qiDX2A2qE6Ac5QZ7sUakvuOW9b6Aam X-Google-Smtp-Source: AGHT+IGV3Dv8X5d9m0XBa0wcUYD14lxx+K6CWQDd1wmnBIzjONKraLrRCWecBGSIPRcOqs5nu0aqbw== X-Received: by 2002:a5d:64ea:0:b0:33d:46b6:396a with SMTP id g10-20020a5d64ea000000b0033d46b6396amr3316172wri.4.1708355199934; Mon, 19 Feb 2024 07:06:39 -0800 (PST) Received: from localhost (54-240-197-231.amazon.com. [54.240.197.231]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0033b198efbedsm10518754wrw.15.2024.02.19.07.06.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Feb 2024 07:06:39 -0800 (PST) From: Puranjay Mohan To: Christophe Leroy , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Russell King , Zi Shen Lim , Catalin Marinas , Will Deacon , Tiezhu Yang , Hengqi Chen , Huacai Chen , WANG Xuerui , Johan Almbladh , Paul Burton , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Ilya Leoshkevich , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , "David S. Miller" , Andreas Larsson , Wang YanQing , David Ahern , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: Christophe Leroy , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, netdev@vger.kernel.org, Kees Cook , "linux-hardening @ vger . kernel . org" Subject: Re: [PATCH bpf-next 2/2] bpf: Take return from set_memory_rox() into account with bpf_jit_binary_lock_ro() In-Reply-To: References: <135feeafe6fe8d412e90865622e9601403c42be5.1708253445.git.christophe.leroy@csgroup.eu> Date: Mon, 19 Feb 2024 15:06:36 +0000 Message-ID: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Christophe Leroy writes: > set_memory_rox() can fail, leaving memory unprotected. > > Check return and bail out when bpf_jit_binary_lock_ro() returns > and error. > > Signed-off-by: Christophe Leroy > --- > Previous patch introduces a dependency on this patch because it modifies bpf_prog_lock_ro(), but they are independant. > It is possible to apply this patch as standalone by handling trivial conflict with unmodified bpf_prog_lock_ro(). > --- > arch/arm/net/bpf_jit_32.c | 25 ++++++++++++------------- > arch/arm64/net/bpf_jit_comp.c | 21 +++++++++++++++------ > arch/loongarch/net/bpf_jit.c | 21 +++++++++++++++------ > arch/mips/net/bpf_jit_comp.c | 3 ++- > arch/parisc/net/bpf_jit_core.c | 8 +++++++- > arch/s390/net/bpf_jit_comp.c | 6 +++++- > arch/sparc/net/bpf_jit_comp_64.c | 6 +++++- > arch/x86/net/bpf_jit_comp32.c | 3 +-- > include/linux/filter.h | 4 ++-- > 9 files changed, 64 insertions(+), 33 deletions(-) > Reviewed-by: Puranjay Mohan Thanks, Puranjay Mohan