Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp411479rdb; Sat, 17 Feb 2024 14:45:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUTIcd0atYwvLAwb1o49OgkNDGtwC4FDS16JndL0huoSxYDKBtWIL/2yhu3gHHGrVm3tyo8/7zuN9ofb9J4VX0//M3KOj0XMPOuQm1mRw== X-Google-Smtp-Source: AGHT+IFMGiS3pvEHw+OMnMQyDaHmQNoVNI7tXx0nPahIyX1Cw+ILxYzYNmPoJ+tjKbyfcjqGdYlR X-Received: by 2002:a05:6a20:3156:b0:1a0:5c40:1730 with SMTP id 22-20020a056a20315600b001a05c401730mr7569700pzk.28.1708209921501; Sat, 17 Feb 2024 14:45:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708209921; cv=pass; d=google.com; s=arc-20160816; b=Gm1zHn/c8zevtQEiD8vsvUCr42WeoR5Ek0AaU1bRtCNjnhYZm55Mpq6GZxWj/c9AQ0 fgPFyxa7amWAitG7oVyrQZbDWAx5qzkeVWP7SnjqD7YwwcfCYSqW/LBukPwRA9ycqQFP ooVl+4DT5YUNs1VzphCOR4t2p3WI3tZ2wsi5kpCoAbwe0QKzHxVN9o0IRWC6Cmq9RxLW 4z/X0hwVmVYe2LNYJQ1xf/JjeNs9/8rUd+gFaTc3l9fUgYeczfu/83YMlKl8cyg7Sx+F jeBXsKtqjswNrIndztswYe1aZ/+TdMWIa2Q8qLXDv+goE8TyItfjNbK3iiAdiQnxXRWq WY3Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6zYveub7yYw/4yOK4qfAyNaSqjm09WW1iA3q80zNNrI=; fh=9la4g83qvO2qAaCbn6sh2tOlLYg/MoUKo7X31z5HTts=; b=l9cFYLjqGm2gxrKg18T2YZaRwiA6MqxmNbccDpB9q0aGry1qlz3xiBNBThtPRX2Eph se3NUXFYczba/u2/CIKMxGo3PHXhwwTaLpmQ2t4x5hm82xmmM/QZa+5j0eJ3jzAzwiml yoVCvxxOvMM/2gJSAEYJDpFWCniffhdpkiTpI7Di9VhPYvrcfa2temmIPM4u8tyiKJAH 8Sff/vQuDDZcZqJ38IwEwx0pdmWSt9R0PP5cOPm4PyRo3Gd/D69vbXOT2cwEqQjDV9IZ hN74Soe3jlpoTJkoU8W1zZ8XaYn8pzVne+KqxRSAZRwDhp7HqXhvlHfqQNQc6c2kbRof Dblg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kzRoPuDU; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-70110-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70110-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id dq4-20020a056a020f8400b005dc071d13c7si1986437pgb.273.2024.02.17.14.45.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 14:45:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70110-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kzRoPuDU; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-70110-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70110-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 34756282665 for ; Sat, 17 Feb 2024 22:45:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CB5B80042; Sat, 17 Feb 2024 22:45:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="kzRoPuDU" Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 E277E6D1A8 for ; Sat, 17 Feb 2024 22:45:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708209908; cv=none; b=kzp6wm3L7M+dqnzSktsGVisRMiem0aOmalqfgqUwR3SwXtOXVgIOWzaBmzQWMG7DL3GZIxWL2DmmOO5dm4rzPKZm5xQu+Haro7UczkdNsoKCfw3rkPE/WIRiUp32m8TmjJ5J2gq/FBKmntVd6dzBP+sxVz6QdW3CgSBUIUuv51Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708209908; c=relaxed/simple; bh=urM+nLCqAhqOanY4utAYiFvmTeBTP9vM1GuLdCAu7dU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Nom6Xy89Ht5owEMHrBIoEb30MuxC6F7FRnfrYPLz3g+zubI8ip9kxqplfLJKJjcqaE0DMAoPiTgfz765gHU9jqCqTaItudRR7dmwMfMga3RLlDF2qORqUlTPJCgy7TvT+bbUQUXkQ5utFjAbQ3wPYxU6Ft3kJnVL5esCjqi8KMw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=kzRoPuDU; arc=none smtp.client-ip=209.85.215.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso1721936a12.3 for ; Sat, 17 Feb 2024 14:45:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1708209905; x=1708814705; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=6zYveub7yYw/4yOK4qfAyNaSqjm09WW1iA3q80zNNrI=; b=kzRoPuDU1k7WdDDWHWFIgd4yz75FvLnn0aJYYAL3SndOZpcv77XLMTIQHNuPvOVqat 7BW2yeWSAjm6YhG6dGfoN+Nvg3BpRWI50TU4gzN1WhHL9xk2ALAZZ+XWx2CEJGyT/XPS Aiu1M30MDTXYfHh2xiIWjTJnyBDOVUQLOqN1U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708209905; x=1708814705; 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=6zYveub7yYw/4yOK4qfAyNaSqjm09WW1iA3q80zNNrI=; b=L2V1I7ZO+Fi5xOQwLNXykVoikX7gaWtgASYeIT3Hykk1ciuUMK4oc+tN+A/WUssz2A mfxvSKLmD4p6YRYsGAcBDHgivKkwSQxPJWwtwGbAI3GN1/CAlNcb+4hDkhPCnCy4SNVK vHXlYUtsU9+wl64lGM4+yMzjmvV00hN3t9vZnEQJwgVqAkhvMtbNjqjcQ6BZlxxFIPLR r4bQ88dT6/bGLMDgH3bFpkBUZiFE0A0eqmnt7JCFEdnKk6ei+Bx/aFizZllchh6n/QpK ZeYH4T8s7CC5HGcjgHedc7Dqzhew6S/w1kkdHGqcXZrpxJLUtqe93UvAeOU6ElVHWC82 UhuQ== X-Forwarded-Encrypted: i=1; AJvYcCWc7KwO3QGQAZlB8BYS4Gx99DXmDHNYAE3rn0Zqx1IK0SMYhgTXauO0pczBMA+46ZTTMEXDnfLdA76CBFLNlsIk/gwLbP/badETbjKN X-Gm-Message-State: AOJu0YyMGrGJ+1s7I3iHk3ie74BAx92DuvBVf4qk0rrd6HZ5zF+oAFJx UATePAXBqnWF9EvZY3ZZ1JqUM4Poh2oS0iSAt5O10V/qt5SPi4Q956wCwjredQ== X-Received: by 2002:a05:6a20:9c97:b0:19e:bca3:213f with SMTP id mj23-20020a056a209c9700b0019ebca3213fmr11331029pzb.52.1708209905129; Sat, 17 Feb 2024 14:45:05 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id w3-20020a17090a528300b002990d91d31dsm2270321pjh.15.2024.02.17.14.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 14:45:04 -0800 (PST) Date: Sat, 17 Feb 2024 14:45:03 -0800 From: Kees Cook To: Christophe Leroy Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , "David S. Miller" , David Ahern , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, "linux-hardening @ vger . kernel . org" Subject: Re: [PATCH bpf-next] bpf: Check return from set_memory_rox() and friends Message-ID: <202402171444.C121486@keescook> References: <63322c8e8454de9b240583de58cd730bc97bb789.1708165016.git.christophe.leroy@csgroup.eu> 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=us-ascii Content-Disposition: inline In-Reply-To: <63322c8e8454de9b240583de58cd730bc97bb789.1708165016.git.christophe.leroy@csgroup.eu> On Sat, Feb 17, 2024 at 11:24:07AM +0100, Christophe Leroy wrote: > arch_protect_bpf_trampoline() and alloc_new_pack() call > set_memory_rox() which can fail, leading to unprotected memory. > > Take into account return from set_memory_XX() functions and add > __must_check flag to arch_protect_bpf_trampoline(). > > Signed-off-by: Christophe Leroy Thanks for doing this! This seems to hit all the right error paths that I can see. Reviewed-by: Kees Cook -- Kees Cook