Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp741938ybg; Fri, 12 Jun 2020 13:25:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1ou7QM9raUJoDUMGeYqw4wUTwOVU93tHj8ZdUtyg1Ft3jEvtBHRSm9xYTNqluVPRQJ8dO X-Received: by 2002:a05:6402:2207:: with SMTP id cq7mr13939562edb.186.1591993518501; Fri, 12 Jun 2020 13:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591993518; cv=none; d=google.com; s=arc-20160816; b=Nqtl9tBvSzGHY+B1WW0RsKXunivhfUbr+rQMs5q66wCQY7f4saMlMIHunI3Bm7Gf0A A43yOv60jq1jw4VjazzP88+7bWlRblEesjFf701SuXnhxzAmKf2jNsaqjXjjfpJue0uO OYVplqwbfyQ17yOugiQl7t8eFcL5PcEcQKp7vhdgI/QFNZnQUJ24nOOF5Il93G2DAU87 F7RDYNrD5Qz0TMJ/LiCRVyB5GNZnmSx58H/xjs0Y8Yotzya9X48TA8ShiUE8qYQosuUS s9pfYBo3ORnAhAKDVgh4Hyz2AmC0xFheCQUpJ6ztklA1ZtJmbmjoMpYt9zyDXnlRGbNT 08CQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=e7FPq3nO6B1maCulGzahMUgGvOzcx8PXF95wcQrwkyM=; b=D1Y++FiZF8eIAvCzePEzs33NFh7aC9EHRSiQ5AD0jJWkZ9Z/DyS58NBIbMNnvRoqZH xqkaTyKUnpGktm46rMFBrIPzwQ+xM0RqLKHaVUS6IfllQQvAEkgzmwHoTB+/TA7zogh9 59k9LZ5MB1Lixf+eSyhYsBvGMJGzRbynBlrYVa9ikqwVjyMBRUUdiA/VWLP6SlY2mi1m ilWusxT9MxR19BX+ZVu7F/5xvVuIvpU705QSq+ZE91eDQ8P+qj3mMIc9+0yule+F8woO zSv+RDz9TlbTH7LRB0941fbZl0oIH2cbr4PHMo3gvjHLASpJ0Ic/qVxE+I/6RMKkuRU5 im4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TNROsMZL; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch2si4069667edb.511.2020.06.12.13.24.53; Fri, 12 Jun 2020 13:25:18 -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=@redhat.com header.s=mimecast20190719 header.b=TNROsMZL; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726372AbgFLUUt (ORCPT + 99 others); Fri, 12 Jun 2020 16:20:49 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22991 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726309AbgFLUUs (ORCPT ); Fri, 12 Jun 2020 16:20:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591993247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e7FPq3nO6B1maCulGzahMUgGvOzcx8PXF95wcQrwkyM=; b=TNROsMZLjjS2ZWsMVMjr98JFcHjykDwWPgildiUUSTQBwmHxP2IscfAii+RBEa3L+DS5UU 45DvFoH+fYwPz2fjd75YASvNLsy3AN9+0Okt75jJzTwLRkaOM4xkun3Aqy3VfC5LVOKStd qbwZ4HZyry1hJkHwfPAmO/Ly92xZdpI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-93I2KMh6Nt-Efum2afEK1g-1; Fri, 12 Jun 2020 16:20:42 -0400 X-MC-Unique: 93I2KMh6Nt-Efum2afEK1g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3A5C801504; Fri, 12 Jun 2020 20:20:40 +0000 (UTC) Received: from carbon (unknown [10.40.208.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B6595C660; Fri, 12 Jun 2020 20:20:33 +0000 (UTC) Date: Fri, 12 Jun 2020 22:20:31 +0200 From: Jesper Dangaard Brouer To: Gaurav Singh Cc: brouer@redhat.com, Alexei Starovoitov , Daniel Borkmann , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , KP Singh , netdev@vger.kernel.org (open list:XDP (eXpress Data Path)), bpf@vger.kernel.org (open list:XDP (eXpress Data Path)), linux-kernel@vger.kernel.org (open list) Subject: Re: [PATCH] xdp_rxq_info_user: Fix null pointer dereference. Replace malloc/memset with calloc. Message-ID: <20200612222031.515d5338@carbon> In-Reply-To: <20200612185328.4671-1-gaurav1086@gmail.com> References: <20200611150221.15665-1-gaurav1086@gmail.com> <20200612185328.4671-1-gaurav1086@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 12 Jun 2020 14:53:27 -0400 Gaurav Singh wrote: > Memset on the pointer right after malloc can cause a > null pointer deference if it failed to allocate memory. > A simple fix is to replace malloc/memset with a calloc() > > Fixes: 0fca931a6f21 ("samples/bpf: program demonstrating access to xdp_rxq_info") > Signed-off-by: Gaurav Singh Acked-by: Jesper Dangaard Brouer -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer