From nobody Fri Nov 22 12:56:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1716814766; cv=none; d=zohomail.com; s=zohoarc; b=REnqwdjctenXMbMV6WY60Jp9kExZoTuh0LNw/zajiQz2uNthh7rLxbU0Ok1JAW+SUCbT8uxFSCmXdrcpJtSbHAYV3YpLuhrXMTaTRJhhIUX4zdbuKDdZUdRoT6W4fiwPod/i6ZRMMb5rmSFR2gOttG8fQjNbqOQWduP76J9zWW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716814766; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pMe2OjnAw9DOpVmn/tQbHcQU5IfzyQdTOAHTtCD7gi8=; b=YATeami/WOzFsBzIlpfYIXhXpr/+tfqfTaazDmYbq/e/0Ag1pZOOf4ImGqcbQWtVI33FyfJR7wmEPRdTGNnZSwhwXxddOwq5SjxGGV2Qo5KO8HQ+sHkeyTlJJJsTDWwm2M0m3cCgOa0p2BKGmw8RwZW/nwzoHgBhmasJffl3BNA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1716814766078991.7654817483846; Mon, 27 May 2024 05:59:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.730725.1135910 (Exim 4.92) (envelope-from ) id 1sBZwY-0005bY-In; Mon, 27 May 2024 12:59:14 +0000 Received: by outflank-mailman (output) from mailman id 730725.1135910; Mon, 27 May 2024 12:59:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBZwY-0005bR-GI; Mon, 27 May 2024 12:59:14 +0000 Received: by outflank-mailman (input) for mailman id 730725; Mon, 27 May 2024 12:55:33 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBZsz-0004Tb-KA for xen-devel@lists.xenproject.org; Mon, 27 May 2024 12:55:33 +0000 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [2607:f8b0:4864:20::630]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 667be261-1c28-11ef-90a1-e314d9c70b13; Mon, 27 May 2024 14:55:32 +0200 (CEST) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1f44b4404dfso21862055ad.0 for ; Mon, 27 May 2024 05:55:32 -0700 (PDT) Received: from paran-QEMU-Virtual-Machine.. ([118.32.98.101]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f44c757845sm60382005ad.5.2024.05.27.05.55.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:55:30 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 667be261-1c28-11ef-90a1-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716814531; x=1717419331; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pMe2OjnAw9DOpVmn/tQbHcQU5IfzyQdTOAHTtCD7gi8=; b=FvS2KSZd7lE/ejf3q/peyRA7xt55tW0gw5w+/3UNtK89gxHuSZNpXFJkLKXpXaK9fi ktL9zEVoSbPLHDmJ5BXwPKIMBnYy5iyaxrAPBmxjYHwndXvRE9YTKdxT6YFN4OhnErxT /YF58gf766seTiVIcHcX6CjQ86hJ/wy1+Oh311YQpPh6Ux2x6DOzZErKMJKdSJLE8ll/ a5LQ1aopzkXQVoWWvU0r4NWZ1jhoXwHOJHKIRvUPCZVgnihQMpPXQhCPH5Yvj404sNzh vh6S8KG31/sjldYsYLRAqQP6fco35EsmLnJK2HPZjGwT0S/H+7mLyJS1EHodpNFUF6Ze 6Paw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814531; x=1717419331; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pMe2OjnAw9DOpVmn/tQbHcQU5IfzyQdTOAHTtCD7gi8=; b=qfyIdZHWIHwwNWZi/PC/+3GSBBiLBj2yapXaGjbIhtinUghHCeRDxH46RutvvhLs9X ltP6ayIJv5v4G+Civ/7KAnn1Uza/02ik4u2ZRU8TYgxt5WhD7F9eYHxqnGKMTYMvN9wd 7HXnD9Eh6Cv+DpijMEp91HbMh8dCqdPNT1DOr5LyEX9PDpgFI40n6G+IIsxokxRJqHL8 2dLId82mBH8Rg7uxmLKii+jXo6YgB33mV/iank/KOBvsmQ70lJoVYIVpdDyxLch8I2/f bYO92sElmrg1CjFA6EKGTRbZuY/RfJM3l1SmKSLoOVQlKTvHkeOxkiU1UfgBZkeeYlrz M5YQ== X-Forwarded-Encrypted: i=1; AJvYcCUjJTPbPXKbmBfN2fgR96nQgGBGjt/R8yrxKwkwu+pul6at4iSs416vqxaQEjgnbnQiKVAQV0+Lr1Ani+ozS+t20OL68sr96E7N1SJ8Q98= X-Gm-Message-State: AOJu0YwekmPCPnQd+jpcgqMX9BToHLXvEKHfmD/anv2Wq237joqbeev6 LzmcVvdudphT9lbZZfmhPDEdHu+DtfyXniPY4aXf5wmciXvbkpMmcztQMzuXMaI= X-Google-Smtp-Source: AGHT+IEvCWcm6q+tC3X0xxKR+wWh5xFppmrVISfccNDFu9TXeDUUje3ns00KN5KoFpXURDLsUc3FBA== X-Received: by 2002:a17:902:d50c:b0:1f4:b313:3e9a with SMTP id d9443c01a7336-1f4b3134380mr10896515ad.65.1716814530796; Mon, 27 May 2024 05:55:30 -0700 (PDT) From: yskelg@gmail.com To: "Daniel P. Smith" , Anthony PERARD Cc: Austin Kim , shjy180909@gmail.com, xen-devel@lists.xenproject.org, Yunseong Kim Subject: [PATCH] loadpolicy: Verifies memory allocation during policy loading Date: Mon, 27 May 2024 21:54:39 +0900 Message-Id: <20240527125438.66349-1-yskelg@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1716814766445100001 Content-Type: text/plain; charset="utf-8" From: Yunseong Kim memory allocation failure handling in the loadpolicy module. Signed-off-by: Yunseong Kim --- tools/flask/utils/loadpolicy.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/flask/utils/loadpolicy.c b/tools/flask/utils/loadpolicy.c index 76710a256c..7f6bab4dcd 100644 --- a/tools/flask/utils/loadpolicy.c +++ b/tools/flask/utils/loadpolicy.c @@ -58,6 +58,11 @@ int main (int argCnt, const char *args[]) } =20 polMemCp =3D malloc(info.st_size); + if (!polMemCp) { + fprintf(stderr, "Error occurred allocating %ld bytes\n", info.st_s= ize); + ret =3D -ENOMEM; + goto cleanup; + } =20 #ifdef USE_MMAP polMem =3D mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, polFd, 0); --=20 2.34.1