From patchwork Wed Nov 6 10:49:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 13864367 X-Patchwork-Delegate: plautrba@redhat.com Received: from server02.seltendoof.de (server02.seltendoof.de [168.119.48.163]) (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 9A56D1DE3B2 for ; Wed, 6 Nov 2024 10:49:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.48.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730890160; cv=none; b=OTxcoN9tSX2AeXgS6AW4gPn1QVUVlFyYTgr9ViGWlNc1EL4zuLlnC8ncZKV50gcG7zttDgCGcPtNKMclkERGz4JeCwGkyDjc9ZTzrxHSbMJCOEtitYCWBsVHCSq9TzImSiqCwG8HDP2OhlPeduCd2iCkkGUvkltjny5KwI47H90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730890160; c=relaxed/simple; bh=939sve5knLWcvhb9DJNFwfCraC+ptcompKt9YJyJCew=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=I4F1FAXTfuAMa6z82a6VbiA3qgrd2OwIfM/8cTQkh3D+Q3h7NUH9HDzj6B5uxQo1HoYnb2Qai6EJh8A0Ywp2306h0zJzLyIhhpEVEGqJkNluscXDtzzfR3kR68EbmBBWCAuZS23DiF7vyDHI18TW+3grhrG5LJBKcfHw7RysWjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=seltendoof.de; spf=pass smtp.mailfrom=seltendoof.de; dkim=pass (2048-bit key) header.d=seltendoof.de header.i=@seltendoof.de header.b=s9y0L+ta; arc=none smtp.client-ip=168.119.48.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=seltendoof.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=seltendoof.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=seltendoof.de header.i=@seltendoof.de header.b="s9y0L+ta" From: =?utf-8?q?Christian_G=C3=B6ttsche?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seltendoof.de; s=2023072701; t=1730890150; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OwUOgDsu53EnLYhxQg04Em4CMkFyJhi5nzxQ50yK8ww=; b=s9y0L+taQGm8oZD3ZmBirQjg2hfee0eeSHtCuV+Z0uTQGw8hKali2rCyw/KPoKjcnCsVz+ 5F167QeZ1miTno+YiZUkut2Z+81SHOuwHLvaYLo3OiwzJ6GspRfMLNfqQW52xovYf7Enr2 +6OAtpxK7G20ecNBoFwULNFCBkf+//OkigzWwcHJuYBVe5JOPWfTggEHHyxJx8efHRSOoT hUiJiKvgPJUN5WroumbwGlZWmawXE+yH0amvDF8T4cvZifAQ8YUkd7YOtlpcsWELuMvE8i ZCiaUe4Qi1Op9o1vhcHbBVlwJtGLCvp22cqEeAGcNJW8CKjt2Ig4/m5mwPo9Hg== To: selinux@vger.kernel.org Cc: =?utf-8?q?Christian_G=C3=B6ttsche?= Subject: [PATCH] checkpolicy: avoid leak of identifier on required attribute Date: Wed, 6 Nov 2024 11:49:06 +0100 Message-ID: <20241106104906.29847-1-cgoettsche@seltendoof.de> Reply-To: cgzones@googlemail.com Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christian Göttsche Example policy generated by fuzzer: class s sid k class s { i } optional{ require{ attribute i; } } type m; typealias m alias i; typeai Reported-by: oss-fuzz (issue 377576480) Signed-off-by: Christian Göttsche Acked-by: James Carter --- checkpolicy/policy_define.c | 1 + 1 file changed, 1 insertion(+) diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c index 9aae8378..96414d46 100644 --- a/checkpolicy/policy_define.c +++ b/checkpolicy/policy_define.c @@ -1322,6 +1322,7 @@ static int add_aliases_to_type(type_datum_t * type) aliasdatum->primary = type->s.value; aliasdatum->flavor = TYPE_ALIAS; + free(id); break; } default:{