Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp43972rbb; Fri, 23 Feb 2024 11:06:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWBwDS0citJ/Q5U6DT3lGWaQZmGKCG+IuwfiBJ6TSAs0RIKO4zsEvMHeXRjuyNwfaYFv/9kyDCH2gHNIor5oNzgOsQXEZ+lkJcMQnIL4g== X-Google-Smtp-Source: AGHT+IH/rj6znsbSzxoCVU2d7bUFr46rn67DmVtJIeIgaEospViB7z8SWmXW1pL3kVOvcb+KTGTF X-Received: by 2002:ac2:5d24:0:b0:512:e4f4:bf2f with SMTP id i4-20020ac25d24000000b00512e4f4bf2fmr425350lfb.15.1708715176750; Fri, 23 Feb 2024 11:06:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708715176; cv=pass; d=google.com; s=arc-20160816; b=ITK/DACrPEhWxP+9180YNOKeZQ9SdiX3tOr3YFtdpfiVYc/lbXbbIto/+pP+WyWMfB 26wabXhrbIpkdm02M8NrKKostU0y1VtzW/3cQFdn7IVpw8isV1WML0efaFASkulElZjp mTBxAXuvWkhWxax9ZY11x+bAmu/3g4EOu5kDTm0ot6asGigh1Ayt2cFdW/WWmYtWO86Q QoB5Az13eKzjcA7FyMdVQBWlHcc4Zy05iYbZNdZPxE9f7qb06F+01tT08d8lhbxCjiwm C4894/PRXuzewdXedTQ4Sfru0z2WD5ZYFkgnSNv0ePMIqDuqQpeNCIcGKnjxal2ylhG9 8r3Q== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79016-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v1-20020a056402184100b0056173831870si6364656edy.321.2024.02.23.11.06.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 11:06:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79016-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79016-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 713ED1F239CB for ; Fri, 23 Feb 2024 19:06:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B183143C78; Fri, 23 Feb 2024 19:06:10 +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=20Sala=C3=BCn?= To: Casey Schaufler , John Johansen , Paul Moore Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Infomaniak-Routing: alpha 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); -- 2.43.0