Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5578698img; Wed, 27 Mar 2019 11:03:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkqaapW8Wdkr2EDIZJX0jcdo7Jycz51lcgp0sXyfErZHHb3+w3sk/owtY5twcM4TH4prTS X-Received: by 2002:a62:ea0f:: with SMTP id t15mr37303703pfh.124.1553709818200; Wed, 27 Mar 2019 11:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553709818; cv=none; d=google.com; s=arc-20160816; b=cD2hdG1rygiBbcS4NeSQWnDEgYiFM68dgmHoYOrn8dsDLPIblxpE4V2fV6FanSeNn5 aUAJcay4TZcgSvKzN2a2iNk5GNfV62FC661NoM2/NmJgNKG++ulwBR7ImkFOWV9Jia6j Uy8nQGlDNuV/3r10yDblUGKfarDSotci1e5Czr0yFui2d3fpONeaSnOdJwqKHR0WEUjm j/PiXHyZaXOiaYo5rqH+HfhJiuuGefHLG4sLtLrUZras6ZODM+3v0OsgGOVY49ylxcvI HzVWLzd131Nx37kkxgeLiDv48U+ZTTFwtacKDYcV4VQ4UAH1UBl4EpNCfEcBugiP2gqm LfdA== 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:date:subject:cc:to:from :dkim-signature; bh=/+/ClQs/hbfcxdt4NUWEKG7gB+3CKqKHl+hpj6bP3fs=; b=wEp4ItGQbo8I/CIRKvqEyr7MVUNnkjh4Mc6zX0Ibl6MWcFf7AqusrKyAVAkSwdxsZi fyHZaSj2pkwa8ojYLEQfCs59+AKuCZWNEO7bFXtTpnzEI4LbafNWhOrnmdPq3NquQ7bh nj2yJeUDt1qwOT1OmBOgxyjmWP0Hoyd2L44rhkCyn/WuukQUgSVTI68ohf5yRmOjahPn O6LAtGnvh+VRqgSy1bJTz63WcS5vPqIGC1ZW4io5rN31fwYidRFiW6CHWgv6lBomq0j3 QnBk2QjZaFREn40Ys9M633YZbAPMZvKVBcp5UvAJp0R7qacB6UP3jplDGg7nHmQ2X/0+ Sf/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ujTB8Hey; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t69si19122923pfa.7.2019.03.27.11.03.21; Wed, 27 Mar 2019 11:03:38 -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=ujTB8Hey; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730769AbfC0SCa (ORCPT + 99 others); Wed, 27 Mar 2019 14:02:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:42338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728329AbfC0SC1 (ORCPT ); Wed, 27 Mar 2019 14:02:27 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA6E72147C; Wed, 27 Mar 2019 18:02:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709746; bh=GB/tzb7UrmxmQDwStdqyaUgKDv2/kefDkBPjoOdWj90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ujTB8Heyiikv2PloWo9nS0lDUNTyqEPOXUnc10QXpTPDLCO0q8MGyYTJowkkBo6ko pFYkBFh7s5WWjNZPK7iLdqENfg837DGUk57OFjNlSyIygpLQJk0+0kUYPbiIwkPJvB lo7hA9Ua0cRED6KGW2JW+h85Uu1cvIUPeJqdh3RA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Daniel Borkmann , Sasha Levin , netdev@vger.kernel.org, bpf@vger.kernel.org, xdp-newbies@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 016/262] xsk: fix to reject invalid flags in xsk_bind Date: Wed, 27 Mar 2019 13:57:51 -0400 Message-Id: <20190327180158.10245-16-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Björn Töpel [ Upstream commit f54ba391d88f5a5d032175b4c308c176e34b80b7 ] Passing a non-existing flag in the sxdp_flags member of struct sockaddr_xdp was, incorrectly, silently ignored. This patch addresses that behavior, and rejects any non-existing flags. We have examined existing user space code, and to our best knowledge, no one is relying on the current incorrect behavior. AF_XDP is still in its infancy, so from our perspective, the risk of breakage is very low, and addressing this problem now is important. Fixes: 965a99098443 ("xsk: add support for bind for Rx") Signed-off-by: Björn Töpel Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- net/xdp/xsk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index 85e4fe4f18cc..f3031c8907d9 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -407,6 +407,10 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len) if (sxdp->sxdp_family != AF_XDP) return -EINVAL; + flags = sxdp->sxdp_flags; + if (flags & ~(XDP_SHARED_UMEM | XDP_COPY | XDP_ZEROCOPY)) + return -EINVAL; + mutex_lock(&xs->mutex); if (xs->dev) { err = -EBUSY; @@ -425,7 +429,6 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len) } qid = sxdp->sxdp_queue_id; - flags = sxdp->sxdp_flags; if (flags & XDP_SHARED_UMEM) { struct xdp_sock *umem_xs; -- 2.19.1