Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9095037pxu; Mon, 28 Dec 2020 06:31:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGMgLOmHd7AqgiA3MGntOnB94gcmO4ndqcyVbi7DufZdVAZVxvuVUkcGcAmwPfLv1E+4Qn X-Received: by 2002:aa7:c919:: with SMTP id b25mr41327732edt.108.1609165874028; Mon, 28 Dec 2020 06:31:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165874; cv=none; d=google.com; s=arc-20160816; b=jYeocF/Sa79mPx9AAscrn6vOi7+M1sSt/j/kJMHUCKoNko4EmgYoRJVdtNg1d0StL2 Lyylu8hOvBLYXzrY6lBvqlzEUuyezwX5Hcju8J8RqJVX/SIyhwxgb+zwjg2J2jrbKMa5 6yMOAEJvfF4vH0624QKLrgrTyw7ZThQk6Ih596wnJhN5+kk5q7hN1t3x5NzHk7VV0djO zA7W6dev6FGSKLtUxWFsHYHgJPHuIBox1Gv5mkzTSBJ9d6/fpumDtTau6WhLCHthxBH+ sQmeAYGQEmHJLqlSQsTxBr4OYYL4N6Tj/+/7slDfhrxgtUzoZYPjiNAQDBcjDstw15AQ RFww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WWbUwaTG78eVxUpVJzPxsJpUu4Apc7yS9H63o0ohqJw=; b=XGOnBOyp8SKDbT71MpEEDEASwlQ+C++LlsJCKPQMqUSqtQqiCrrDWS136MRySalwek gFlwHBjlgYAYhurHaYXH6qVCzcK8XzpMuMDLsIcKL2ZhmR7dJfA9YuzBI7yFPQtqxyhZ PjS+pN6NNPd7KD1uiGPCPuhUxkeMdAZvN56/QhxZZ8VRCWbrb0C46la4LQrTbu0pukoh uhQ6zFtRAWvsPbKEM9FA+h6Z/cClGSEVWHDODiWu9RrC52YNCLnqHbtBjQA0BTGovDd8 XItqlfwq/hbTNLj4hSEfO5633MdIOJ4/XsLRWhzUZAgeN9u8+fT/vVuUx4t2QgmnjeNw ZH4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XI5esLmJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r20si20619469edi.479.2020.12.28.06.30.51; Mon, 28 Dec 2020 06:31:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XI5esLmJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502602AbgL1O2x (ORCPT + 99 others); Mon, 28 Dec 2020 09:28:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:36690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502554AbgL1O2s (ORCPT ); Mon, 28 Dec 2020 09:28:48 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 615C1221F0; Mon, 28 Dec 2020 14:28:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165687; bh=IQ6vgFz9x4ScKW4PKMTUZSzjyHMKBWg0BaUAwIo9Bg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XI5esLmJbU5hCEthC5VYwGNxYS9bkcBPtL78RMYyMnkOgCruVcrxg8eSIhJDJtZb0 IJq/bIMnwqgrIQvBKqH4Js/wE3xu0AWciNfWrt+qJf39dMTBQWEteJC+ZVk1B/WdwV VUlbQNwZDyod635TJeqqjyDQD5t51zHIwq2tm4hM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anton Ivanov , Richard Weinberger Subject: [PATCH 5.10 620/717] um: Remove use of asprinf in umid.c Date: Mon, 28 Dec 2020 13:50:18 +0100 Message-Id: <20201228125050.632289154@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anton Ivanov commit 97be7ceaf7fea68104824b6aa874cff235333ac1 upstream. asprintf is not compatible with the existing uml memory allocation mechanism. Its use on the "user" side of UML results in a corrupt slab state. Fixes: 0d4e5ac7e780 ("um: remove uses of variable length arrays") Cc: stable@vger.kernel.org Signed-off-by: Anton Ivanov Signed-off-by: Richard Weinberger Signed-off-by: Greg Kroah-Hartman --- arch/um/os-Linux/umid.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) --- a/arch/um/os-Linux/umid.c +++ b/arch/um/os-Linux/umid.c @@ -137,20 +137,13 @@ static inline int is_umdir_used(char *di { char pid[sizeof("nnnnnnnnn")], *end, *file; int dead, fd, p, n, err; - size_t filelen; + size_t filelen = strlen(dir) + sizeof("/pid") + 1; - err = asprintf(&file, "%s/pid", dir); - if (err < 0) - return 0; + file = malloc(filelen); + if (!file) + return -ENOMEM; - filelen = strlen(file); - - n = snprintf(file, filelen, "%s/pid", dir); - if (n >= filelen) { - printk(UM_KERN_ERR "is_umdir_used - pid filename too long\n"); - err = -E2BIG; - goto out; - } + snprintf(file, filelen, "%s/pid", dir); dead = 0; fd = open(file, O_RDONLY);