From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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.lore.kernel.org (Postfix) with ESMTPS id 5B921C4332F for ; Wed, 16 Nov 2022 17:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NXvRUoxlY2E4MGE0FAOK0nO0C41SK+jQ/Ud0sUYT78U=; b=P1eCgwi0o4ficx xPYyFsgYjQBxuYXk8qtHeIXgsypSuDK72f7bCTZhnFwK01QvwYapVl7YU7sbU0KRYsHXv2XFkdocB DhJ75wM+DoNoO6yxocqkcxrJv/jxND7rJk0gUsY22K9BgwN9OX2GIm3xJ5o7JawJIcs1R4Xo87/lI F9rU9cY1nhJsGVnL9TSV4XTGTOctDdvpgUC2aeBEQXD52bGI5blLJvfOz2KeUvMFS0hLbJuqBtaoO WxSB4MQdE0q3JbJSl8DCp/cGQHHmiPbVQwxkTYAuYjMhlURXRAHjzMD8FJrpghBnLMQqccIbsn4W0 46KRUeRlnkg1YvD8JV5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovMWq-006dDb-77; Wed, 16 Nov 2022 17:48:52 +0000 Received: from out2.migadu.com ([188.165.223.204]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovMWm-006dBJ-5e for linux-arm-kernel@lists.infradead.org; Wed, 16 Nov 2022 17:48:50 +0000 Date: Wed, 16 Nov 2022 17:48:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1668620926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XmW9WCvz+s/qLEawf6fSBFXtTILAUrT47yXR3/eJuXA=; b=gHOya6+ikm8w73hzuv3v8gYs1nwKsVXAiDPYeHh25rYtsls8WnfmYPtLeNtJZoyISRHBLT ovYBecRu4QtPVPemAsppXx0Z0S/INA9VcgBZ5hzHUeeWV5EHNPl0dwzYNtsJmLU7qTKEeo S+Uoppf66b4Pw0ULuegq2accZeXeKQk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Quentin Perret Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Sudeep Holla , Andrew Walbran , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH 03/12] KVM: arm64: Block unsafe FF-A calls from the host Message-ID: References: <20221116170335.2341003-1-qperret@google.com> <20221116170335.2341003-4-qperret@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221116170335.2341003-4-qperret@google.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221116_094848_381783_8799712D X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Sorry, hit send a bit too early. Reviewing the patch itself: On Wed, Nov 16, 2022 at 05:03:26PM +0000, Quentin Perret wrote: [...] > +static bool ffa_call_unsupported(u64 func_id) > +{ > + switch (func_id) { > + /* Unsupported memory management calls */ > + case FFA_FN64_MEM_RETRIEVE_REQ: > + case FFA_MEM_RETRIEVE_RESP: > + case FFA_MEM_RELINQUISH: > + case FFA_MEM_OP_PAUSE: > + case FFA_MEM_OP_RESUME: > + case FFA_MEM_FRAG_RX: > + case FFA_FN64_MEM_DONATE: > + /* Indirect message passing via RX/TX buffers */ > + case FFA_MSG_SEND: > + case FFA_MSG_POLL: > + case FFA_MSG_WAIT: > + /* 32-bit variants of 64-bit calls */ > + case FFA_MSG_SEND_DIRECT_REQ: > + case FFA_MSG_SEND_DIRECT_RESP: > + case FFA_RXTX_MAP: > + case FFA_MEM_DONATE: > + case FFA_MEM_RETRIEVE_REQ: > + return true; > + } > + > + return false; > +} Wouldn't an allowlist behave better in this case? While unlikely, you wouldn't want EL3 implementing some FFA_BACKDOOR_PVM SMC that falls outside of the denylist and is passed through. > +bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt) > +{ > + DECLARE_REG(u64, func_id, host_ctxt, 0); > + struct arm_smccc_res res; > + > + if (!is_ffa_call(func_id)) > + return false; > + > + switch (func_id) { > + /* Memory management */ > + case FFA_FN64_RXTX_MAP: > + case FFA_RXTX_UNMAP: > + case FFA_MEM_SHARE: > + case FFA_FN64_MEM_SHARE: > + case FFA_MEM_LEND: > + case FFA_FN64_MEM_LEND: > + case FFA_MEM_RECLAIM: > + case FFA_MEM_FRAG_TX: > + break; > + } What is the purpose of this switch? > + > + if (!ffa_call_unsupported(func_id)) > + return false; /* Pass through */ Another (tiny) benefit of implementing an allowlist is that it avoids the use of double-negative logic like this. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel