Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1307119rdb; Fri, 16 Feb 2024 11:17:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWOyua4JLw4W1Ah4pO7DPZ2n0hYvtbq3djqCYpCGqDQletlaeP93eHm59nd12rVYI6/FfYWWfmiww8qw6/INvZX3ocgjql1vGHK+LPy9g== X-Google-Smtp-Source: AGHT+IGMoV3nudNQh42+wcD9xdjN0nAY6lCeolkbgr7APDRjOP91NkY1fEg5QQcsUJY0dO74dJIF X-Received: by 2002:a05:6a21:9207:b0:19b:81be:34e4 with SMTP id tl7-20020a056a21920700b0019b81be34e4mr7520263pzb.50.1708111046411; Fri, 16 Feb 2024 11:17:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708111046; cv=pass; d=google.com; s=arc-20160816; b=rrRrfmyLXGHloUDodIx4KVjcW8R7KnQXg91IsvWNOcbLSuGlkGLxPb7E1r/Vktjm0G NCxwEoZLYLCtB/3ZGlAO0dEogKBJFxxUG4pMnA6nyieIIpddAV8t08LuyXKf5RAZ+XWy UcElbVVm1KTjZCSBY1k1Lz7C+KZU+zsp9IKQibje+7urycwyhXxT0xzuGKTwBnPAnxBH 8tSnmksqZiNUAgb+URFlDiVSsiBjckVpqAiSad3ox6Df0gNuq2RXQxCTjikXoBJuOj6Q ur8vLmXYvhO93OZGtyc3+cgPm69SUNJvEQI+CKWvjLT56M2sj9DTjF2YLNRUyZbNl+uP ZOww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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=zm17Aa/JqozFDFprYkW1jzkLivImpQkuYJ6UV/JX6II=; fh=1xKuJkCZr47m9cwoUlscynv8uCfzuzCQ2iekgkKSSgI=; b=iwiVioA19exIDKEDlLKVQb4EFT3F18KFvLJtR0CJPs0zv21hIoVCfzIMPO/Fp2VzBa JYgUMIyjl9DGcrMPCUo0IngklKyF1OnpHOucDsIdE06FmvbZ3GUNnuiXpZKn3dZoG/Lr yGl3qAakH1gtOvstbeWi1XVZxTmdRwozAPrH7ri6bmoJqZgc4ik/XzyYukUWu9YiqlY2 FJWJBRzJxLVZZAjX2+K5jSx/hqEQDICaaJiWM4ClQtb+Az0MDWLTQzrqQYz0X/60VZ0h YzJTPICymXhZ6XeZFnFZ9sm6tlOlJSY+Gjk2+bwpCYJkpvkiFIHyK8gsGdcLgdnMiiTS cM8w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="sBB/HeoT"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-69234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s20-20020a656914000000b005d8c18c7c65si294525pgq.671.2024.02.16.11.17.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 11:17:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="sBB/HeoT"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-69234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 15827281EA5 for ; Fri, 16 Feb 2024 19:17:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA5D4136646; Fri, 16 Feb 2024 19:17:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="sBB/HeoT" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 001411350ED; Fri, 16 Feb 2024 19:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708111039; cv=none; b=e67cBdYr1NteFC7vtt9+qUi9RdbhZF4Sz+lpsKsq+uc0Gs8jOqzn1MoOFE2SGjhMalby7OVbQrReTMu6Wzws+ITKkJIV7mftUeTrlhvuobe+Ad67jCHguMwIv/VfrDEFv3UR0veDx067wzmNsgTUwu7VGmXG4uur7UsYJOk6lfA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708111039; c=relaxed/simple; bh=qnVycgC6PT38wLbjka6ATJ/Q+9q7NmRau89BQzqRAjE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YSoQrNqx58frxMhJUOda5bfgWb41FfgIhxIsWNV8wxoD6tk5bJb8j4TAfP8DXAZe+mkF+qnkPkeH57QdwB9eclfHctYWWOSt4dXwy5OKFRZOgrFQiBkDJb1C0u/PNm0GIjTntGscNq03yetiOFFHkVFU5SfPX6VGXQO6RqyNGyw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=sBB/HeoT; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=zm17Aa/JqozFDFprYkW1jzkLivImpQkuYJ6UV/JX6II=; b=sBB/HeoT+q+N1cJzi4ck5dQhg1 YVIp/c8ZFZNKtqamLOtntvw3La2y7reLIxfgQeL2TWhtxe29i8iD/FJL3W/RqFi2AIrxpXjVd3CiP hC0PcwNRhQXVdXUT7ogVam/gKYRNUWPTnyEHAyGkwnjy1viCHVr1iepAro14pb/Fk5DDNvOSM78JF jfERmd9XkWTjLkXDAPgVADLjcz4TbYFsk9XdQiPNnNT+6XpgD5l+ZZ03aXr6wkk48i9MGhmvBDvQQ fjzGlhUBvPe49oqyz9Ay8BhWr+9W5kb3HicrlOIXMWp9Sflt1cZ2sz6YV7r5XAsPYkKbNEOhj+TJL IiDt5lTQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rb3i0-00000003TL5-0ctN; Fri, 16 Feb 2024 19:17:16 +0000 Date: Fri, 16 Feb 2024 11:17:16 -0800 From: Luis Chamberlain To: Christophe Leroy Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , "linux-hardening @ vger . kernel . org" , Marek Szyprowski , Mark Rutland Subject: Re: [PATCH v2] module: Don't ignore errors from set_memory_XX() Message-ID: References: <21037bf38438a285f5dff9501668f1675bc45989.1708070781.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: <21037bf38438a285f5dff9501668f1675bc45989.1708070781.git.christophe.leroy@csgroup.eu> Sender: Luis Chamberlain On Fri, Feb 16, 2024 at 09:14:27AM +0100, Christophe Leroy wrote: > set_memory_ro(), set_memory_nx(), set_memory_x() and other helpers > can fail and return an error. In that case the memory might not be > protected as expected and the module loading has to be aborted to > avoid security issues. > > Check return value of all calls to set_memory_XX() and handle > error if any. > > Add a check to not call set_memory_XX() on NULL pointers as some > architectures may not like it allthough numpages is always 0 in that > case. This also avoid a useless call to set_vm_flush_reset_perms(). > > Link: https://github.com/KSPP/linux/issues/7 > Signed-off-by: Christophe Leroy Applied and pushed, thanks! Luis