From patchwork Fri Feb 23 19:05:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= X-Patchwork-Id: 205618 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp788772dyb; Fri, 23 Feb 2024 11:06:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXxyavE3s7eazFJwyM0ZlredtjM3ghWBVbbEyj7uuT31AO3uu6hnGLBP9jeP2d1IaOE1q8csJrNAo5WhYzV04KXrvCoXg== X-Google-Smtp-Source: AGHT+IH7NIKWOzOGFKv9vSfUJQm1vQP09s1LfBjva3b9awxkEH1pJS7+wPm+5kbdEInClm3n0Kxa X-Received: by 2002:a17:90a:51e2:b0:29a:842b:d8b3 with SMTP id u89-20020a17090a51e200b0029a842bd8b3mr714813pjh.7.1708715198651; Fri, 23 Feb 2024 11:06:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708715198; cv=pass; d=google.com; s=arc-20160816; b=uruFaEYJZPYNjaa0v38gFvZm1DxPIMHMFJkZyJHebkHMp3ue2O74XeW9FpJyY2DB9C ZSZ9AkbEWxnB8V/TdOfqrTjNp8KOMWKEwtYxxt/Nbu39rBoAg18Ezaef6wMPStrcM5GG gzoJ1xiUlGHO6yTHQFcLb/Vfbk/5wCs/iu8Sbo9JLTmqVywIokGtVxXCEhnslEYAtE6a S5kjI+F9r5WW9+AOnvLFXh8NR16WxmQ5Nxj4vUeYTnBDGkbjfGs6z4cjfbWInQpTfztF hsIMejMWiGhiDNBHXb+aeeb2OSJuocJqFjkOxAqORNmDqFISVBbMlUTVheYyVQi0bqJ4 dzSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=BSUEogyFCjluFI3KSBFuKHUGIeaHAns7++aIAJSrgw8=; fh=75p7ccQGuT0xN9vNAOHl1M6SKBcYhJIT9hLFptk3jWg=; b=LZeApnoLEg3lITD2d+gBRKcQdT1Ap4Fri0K8/VG0Ixy1d+v8XWiN6JijgXbBGhUupw 7JfYkrLesUtH6yxKq5oX4Y+Au9Rpmc5gI/b1n8wAlQIqB3kEMSAYSv/H9Od5bTl4XWQH 4i+xtLzOl2CtuNNpbX6e97xCpr4fE08TkQp8ynuXRVtR76Zg8xKmHUafQ2lHrB+UdIy/ BYlABXG2BOQ27s88ff0AQpBGvR/uf67Lbp7lKBihP1Pa+OKj1LjVXN6qcTWVWYRK7PbU v+2EEIfOpXFjvt/0lvPYgAajH+SeyJsDPAe3swkX/mQD84S4QxmTkGNXt79WR6NPsjLB QnfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=1N9Om1Cl; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-79016-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79016-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g3-20020a17090a578300b002994211c0c2si1601459pji.81.2024.02.23.11.06.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 11:06:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79016-ouuuleilei=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=@digikod.net header.s=20191114 header.b=1N9Om1Cl; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-79016-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79016-ouuuleilei=gmail.com@vger.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 DAE13287B07 for ; Fri, 23 Feb 2024 19:06:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6082B1448FD; Fri, 23 Feb 2024 19:06:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="1N9Om1Cl" Received: from smtp-190f.mail.infomaniak.ch (smtp-190f.mail.infomaniak.ch [185.125.25.15]) (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 0BCCD142631 for ; Fri, 23 Feb 2024 19:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.25.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708715169; cv=none; b=nyVUf9nRAvJdey2UXK8F5aHIPL8+vdeE8ys1HdFfsz/9lVnyA83kURD4z/urKFFSVdp47/nio3SSiShMZ2VOZsKVwFFCA4R1pQmg2i0ZQp3jI7NCjU/LTSosUBKm3P0UlpidqSkr7nE7n0EsJqAQ1EoVyfWd1SeJAMtXVqoUvz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708715169; c=relaxed/simple; bh=qpzM6NBYR7WpVcp9/HBiZFKK8JElis+2lrx2b9BJFms=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=SLYfZX/1sXOCIW+C/VvTgl8A0/OsNYZilxlC5DzSz7g33Ewj5zmINuoAy+GjRKMlOPLegfIE+86bStdYyVCw8TLv/xaz7LaBap5Od2oUQP9dpGc4R1cSaAcRklc3OlCeAMJLH4B4Z5AD9NDJNzIgap2V/VFRCRPnti8xSrYR1Mg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=1N9Om1Cl; arc=none smtp.client-ip=185.125.25.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Received: from smtp-4-0001.mail.infomaniak.ch (smtp-4-0001.mail.infomaniak.ch [10.7.10.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4ThKGt4rmsz2TC; Fri, 23 Feb 2024 20:05:58 +0100 (CET) Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4ThKGs49MCzjsT; Fri, 23 Feb 2024 20:05:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1708715158; bh=qpzM6NBYR7WpVcp9/HBiZFKK8JElis+2lrx2b9BJFms=; h=From:To:Cc:Subject:Date:From; b=1N9Om1ClO+r+L8Qkam4EJkqyN1SiVBZqs5lER3lgzN2iIjXSyXKUsBnEwslb1urAP jw9IIgIu8sDs1Q4U5Oe/6uKx2AlVRr4rQwt/lIGGpkjJ1kHax1FNIiJsD+DMzXzo78 KnimjfuRbCak8dfFUJl1/GYfQfvSCPQEYotFWX+c= From: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= To: Casey Schaufler , John Johansen , Paul Moore Cc: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , James Morris , "Serge E . Hallyn" , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/2] SELinux: Fix lsm_get_self_attr() Date: Fri, 23 Feb 2024 20:05:45 +0100 Message-ID: <20240223190546.3329966-1-mic@digikod.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Infomaniak-Routing: alpha X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791717748115558063 X-GMAIL-MSGID: 1791717748115558063 selinux_lsm_getattr() may not initialize the value's pointer in some case. As for proc_pid_attr_read(), initialize this pointer to NULL in selinux_getselfattr() to avoid an UAF in the kfree() call. Cc: Casey Schaufler Cc: Paul Moore Cc: stable@vger.kernel.org Fixes: 762c934317e6 ("SELinux: Add selfattr hooks") Signed-off-by: Mickaël Salaün --- security/selinux/hooks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index a6bf90ace84c..338b023a8c3e 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -6559,7 +6559,7 @@ static int selinux_getselfattr(unsigned int attr, struct lsm_ctx __user *ctx, size_t *size, u32 flags) { int rc; - char *val; + char *val = NULL; int val_len; val_len = selinux_lsm_getattr(attr, current, &val);