Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp165446pxa; Wed, 26 Aug 2020 07:31:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze7xepoGm3G1sf0+qigx01rjbbtCITwG+IWx2JasUdMJINds4YXKVVn67d8t81H77c5X3S X-Received: by 2002:a17:906:d935:: with SMTP id rn21mr16609370ejb.145.1598452306333; Wed, 26 Aug 2020 07:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598452306; cv=none; d=google.com; s=arc-20160816; b=JxalHfCRQBU5wl3EL6t6lzXLj5Y2NYSRMJ6PpjXZJPxfAX9W8MZxDtgq5yDjZ+Fjr6 XIzVPTpc+0k9vcrbcv48O3LVzlmXbyu91+4WSDzzIEvZo8X61MGhklnHYOFDqUhijA/C tZGBpGXW010A6GAi+O5+CFDrbyb58eiyhH76qaCDfll7cCVv3Q6fOubr3aTpEh5s+gqJ tXCi5PqNlNoW01b87NpJ44kYjzbcsteNFI9mLDKsz87ebWAHnEVAcLAkQl9zBCrNAJOm YqQEoJJ14seYwAJECwf/Cv7pZKS3tpQFSSmpbI7VO9Frp8goA6nX/xg0iXaz4rriJGYA FXZA== 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=g+/JXSFD89dHLATq/bqU0NNbnffI4RIWsrVL2onI+Rg=; b=jkqpJt8+Uvlt5LMA4+8BZNTbaXpSE+kIl7pWdbqUv+/r//uPJl0BhKoaWHXf/PdDU5 57fXnPc1ym9WO5U6P0MzukWAQG7txP44yenNdxNhc6Iy4VbN3bvAlsCpaPI6KX+lmf06 3D0JPtzVVOLAr8vaCrYeYzxTUstmwmrUh/cKoQBr4XI+UjWjWiVYh+fuX+hxXUzTojZ8 XE435AdRMDPvnIiQnpT084nYEwb2s4jypHrjqI6JNvpP2HQ2NmJz8uTnn/OqUdnePaCH aqXde4m0o4jOMwYy1GB/zU6vVdrteAgbM0lSOONq+KS/zhUCCgNRonhzQFzdCno14X2e ygXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HHqn7Zn2; 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=fail (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 q7si1569942ejb.505.2020.08.26.07.31.23; Wed, 26 Aug 2020 07:31:46 -0700 (PDT) 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=@kernel.org header.s=default header.b=HHqn7Zn2; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729731AbgHZMGi (ORCPT + 99 others); Wed, 26 Aug 2020 08:06:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:38612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729521AbgHZMDb (ORCPT ); Wed, 26 Aug 2020 08:03:31 -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 7F6AC20B1F; Wed, 26 Aug 2020 12:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598443411; bh=XFf6WD/mS3WUjtPuRD+AuZx4AOOaYLXdV+Z07SqZ1wE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HHqn7Zn2QIXZyPsX+BSLQ77zSPv+GExF4MMu/XxlI792/R+GkQeJShNKmDde0WxBw f16OSMqaubwkAvJhJBP+aCErUYRQkLulFoYpln02F8qAESBdIE/+YYfTtGITNvi+9a HClJmmkIeuEhK8t3t7vS27Cv/vKlIN6xzTmnDxhY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , "David S. Miller" Subject: [PATCH 5.8 14/16] netlink: fix state reallocation in policy export Date: Wed, 26 Aug 2020 14:02:51 +0200 Message-Id: <20200826114911.918676140@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200826114911.216745274@linuxfoundation.org> References: <20200826114911.216745274@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: Johannes Berg [ Upstream commit d1fb55592909ea249af70170c7a52e637009564d ] Evidently, when I did this previously, we didn't have more than 10 policies and didn't run into the reallocation path, because it's missing a memset() for the unused policies. Fix that. Fixes: d07dcf9aadd6 ("netlink: add infrastructure to expose policies to userspace") Signed-off-by: Johannes Berg Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/netlink/policy.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/netlink/policy.c +++ b/net/netlink/policy.c @@ -51,6 +51,9 @@ static int add_policy(struct nl_policy_d if (!state) return -ENOMEM; + memset(&state->policies[state->n_alloc], 0, + flex_array_size(state, policies, n_alloc - state->n_alloc)); + state->policies[state->n_alloc].policy = policy; state->policies[state->n_alloc].maxtype = maxtype; state->n_alloc = n_alloc;