From nobody Sun Dec 08 19:15:16 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Y5vpF05jhz5f3kk; Sun, 08 Dec 2024 19:15:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y5vpD6g0Yz4Gk2; Sun, 8 Dec 2024 19:15:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733685316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=p2mCNJnqMo2CzVN4BWKjs9cMF9aThcivINiIG1VYQYc=; b=r7U+Pbr1mMqnB8bqlbcFXMvCRSvVsdKwGVzD2AmbJ9joK+9C3xWZ6Z4zv+OrOmoUjR5p49 zCQlTEugIkoD+uqSht6lHSeFcHJaqW0LRQoBkx5u9gg2YVg/0i6VLSjhva0EKv9Mv9WHnQ 1ZcTlScXf5MQLb37bdOQYztpVHVo9l65Df5+qXyMuZ2f6/Mn4eCyoTrtfyvING1d9QHjGN 8GufkTHK9tCIqQ/tBOw2DYVO2IkdCAa+UEV7N6j9ECMPoBm9+d80+NoNy3v1KIuGrblzGJ lguCK+hmO9HcjfaIuUFrYs0xDltZbpLBY/sYhzwm1vXfvjiE6d/BmSn1jLSdyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733685316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=p2mCNJnqMo2CzVN4BWKjs9cMF9aThcivINiIG1VYQYc=; b=H7HExKQSe6pn0pl8xnlyytSMY/sod5Xnf8H7Klq3A79HYvbGdkIMIJrFtXyEatzvznkpfe cfFMO/dpMMzRrf1RAfUy91tPYjGxJOzrSdEEHtzEWTjqdRCpU19iVO+m1DPM5b3CJBx0XJ xHqjUziF7FGSCxZCwlQuSU9auChYCPJzSGASaipnlkMoxZWwWidL5E0xlak+rUz3jgX9eD 0VgbXr+kcKsXBhSs3IUMPOoVUmGZb8Jhto7Ko1Tt91K5qG5wdUBX17V8Eq3seYl8CuJaNt heBp9FZxbiF3BLPiQhxrGK8HMyojjAuLAT76OpHVPM0pAIevi6NlEz5rwTrAJA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733685316; a=rsa-sha256; cv=none; b=Vqe+wGYA5Zlmae03jseJ4FEM3q9J1vww+mPNEmheUVrbmJeo0Z20DSY5xQDMgQ7UlMfcMo ZqDWc2M7vLI+936vgqBj8cZuqvHmyGmQH7UtBPHkjafLRpDRCrT/jk5KdoH0v/0F7TCkPJ DV0RodgOMVWwaj41zMnMue6G6EgRkg5RjtdtUpFBriBLYh7kNH/RQXz7hItJOpAInTsR0n XtixOEC3hDeI5eULn6bTRZt3edQ6up/gFuxFWp19Pn/YNgShza7xI9sJEhDuazrJ52Tcmz V+8OugB5idqxw88hLauJh3Db2WKv88Jv6eIUvhelXnKrJ/Bw/4Nz/fLWE1r2tw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Y5vpD6GM0z14j4; Sun, 8 Dec 2024 19:15:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4B8JFGlf072429; Sun, 8 Dec 2024 19:15:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B8JFGQc072426; Sun, 8 Dec 2024 19:15:16 GMT (envelope-from git) Date: Sun, 8 Dec 2024 19:15:16 GMT Message-Id: <202412081915.4B8JFGQc072426@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Maxim Sobolev Subject: git: 1e99be5dcda2 - main - libc: lib_malloc_aligned(): add a missing NULL check List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: sobomax X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1e99be5dcda222d47a77715e190a381a14f46ece Auto-Submitted: auto-generated The branch main has been updated by sobomax: URL: https://cgit.FreeBSD.org/src/commit/?id=1e99be5dcda222d47a77715e190a381a14f46ece commit 1e99be5dcda222d47a77715e190a381a14f46ece Author: Maxim Sobolev AuthorDate: 2024-12-08 19:08:43 +0000 Commit: Maxim Sobolev CommitDate: 2024-12-08 19:14:36 +0000 libc: lib_malloc_aligned(): add a missing NULL check For some reason return value of the __je_bootstrap_malloc() is not checked and then de-referenced few lines below, causing a SEGV if an early allocation fails. MFC after: 1 month --- lib/libc/gen/tls.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index 3c1a5472c0e5..30b4fc583c98 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -113,6 +113,8 @@ libc_malloc_aligned(size_t size, size_t align) align = sizeof(void *); mem = __je_bootstrap_malloc(size + sizeof(void *) + align - 1); + if (mem == NULL) + return (NULL); res = (void *)roundup2((uintptr_t)mem + sizeof(void *), align); *(void **)((uintptr_t)res - sizeof(void *)) = mem; return (res);