Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3298763ybb; Tue, 31 Mar 2020 02:22:56 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvl8+uG9cgIFv2USSu/2sH1bKnb0aCJqbVxZnGaf/yxwL6uYQsql41IuqZ+l1EEI8+dk/ku X-Received: by 2002:a9d:1d07:: with SMTP id m7mr11616174otm.167.1585646576303; Tue, 31 Mar 2020 02:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585646576; cv=none; d=google.com; s=arc-20160816; b=LnckNXG9u7zlLORlL9etuA2WFxBfxvPsoB7PVhmStWx+nNCaRBIQLMeTniJuyBR+EY 39nzNPvnr/cvMGxUlffafhYkMk7a+u6pOto3X6DKjkSuBECn/f75ZsFZvugrC3+vuCVY u7cquC0EJj6zaMmMGtZnoN2Xrrg/Smz9BLrq44I4q80OTM3pojCYdftHGP8WrsyDNDxU zo7U9HKJSHQj+qZtzdapag2ieJv8/EY7PTfcLP2LWDbUMCgtsEEc40n2Jgj3dno07cPa TK45yNt/aabeKtGFIx8motkWpE3fOS1p5FU2LZlQ8cxrT02S+v8oGICHD3QAGtQqNm81 K8fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sPMQ+GgBBMvGe8FZBcOrQwjk2Im+89glwAWBknS3xHY=; b=1Fb7FmVvxw2CAi1Z3d19fz3NAsTRJJJXb0i9MHjU9fJR34RRP6ktjJNixRfbN6W2RP T8lx0epigmjY0OBkYFWPJEJWS1OmmoOM9Eemwz+q/8v5N2+Hha+d8f/E/f77Wx2upNrk oLax0qEJARkda25VQSovEM4Azg9+UyHpC1teEzAdBp079zSzu8AMOPyYIlhI9Z3/88Es 5xccLGLcekZovFG92aqrj2g27xzVadP1qFTbN4NlPHH1CSLcavmlMHFRFf6526NG15en W6CR9KcMhRkg9m+KCyvh0/2PAv5b32yIABD8IO+hUefveC2JuBV9dO7B+tqJAqGdVNzy 6v7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XwYu018H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f25si7655211otc.161.2020.03.31.02.22.43; Tue, 31 Mar 2020 02:22:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XwYu018H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731378AbgCaJIn (ORCPT + 99 others); Tue, 31 Mar 2020 05:08:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:51198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730995AbgCaJIh (ORCPT ); Tue, 31 Mar 2020 05:08:37 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F60520787; Tue, 31 Mar 2020 09:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645716; bh=yOKg1tKJy2bt2wOT/yU5kFgS1IBYg+vcjwOpadC+8l0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XwYu018HOPuu5HkPele6HQhjr2r5l08mKxApJogTi8XQb596GunfyQPZeIhHpdywF Cr/tLuT2olA6IoCstLfjRT+NbZENh76lkwFbl6hqGc3NJ8b1PoMx4Wlgmh+JV0ODPi wTg5NbNLQsxopOwR+WnWTDEEji0Fkw7Wm/l2VY6c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrii Nakryiko , Alexei Starovoitov Subject: [PATCH 5.5 141/170] bpf: Initialize storage pointers to NULL to prevent freeing garbage pointer Date: Tue, 31 Mar 2020 10:59:15 +0200 Message-Id: <20200331085438.385948489@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrii Nakryiko commit 62039c30c19dcab96621e074aeeb90da7100def7 upstream. Local storage array isn't initialized, so if cgroup storage allocation fails for BPF_CGROUP_STORAGE_SHARED, error handling code will attempt to free uninitialized pointer for BPF_CGROUP_STORAGE_PERCPU storage type. Avoid this by always initializing storage pointers to NULLs. Fixes: 8bad74f9840f ("bpf: extend cgroup bpf core to allow multiple cgroup storage types") Signed-off-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20200309222756.1018737-1-andriin@fb.com Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -303,8 +303,8 @@ int __cgroup_bpf_attach(struct cgroup *c { struct list_head *progs = &cgrp->bpf.progs[type]; struct bpf_prog *old_prog = NULL; - struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE], - *old_storage[MAX_BPF_CGROUP_STORAGE_TYPE] = {NULL}; + struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE] = {}; + struct bpf_cgroup_storage *old_storage[MAX_BPF_CGROUP_STORAGE_TYPE] = {}; enum bpf_cgroup_storage_type stype; struct bpf_prog_list *pl; bool pl_was_allocated;