Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1829215pxb; Sat, 23 Jan 2021 07:00:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzX+spRrHQQ7bccftApZSLWGwv42izVFAFjKGE06bKlB+5Caom0TddyKlnkYYIQsKT0xMY4 X-Received: by 2002:a17:906:4c48:: with SMTP id d8mr945975ejw.358.1611414016253; Sat, 23 Jan 2021 07:00:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611414016; cv=none; d=google.com; s=arc-20160816; b=pZxUxxOJdlIfu9mXf3ydl9zHPvrntvMnBBABCMQPmt4j0MvJV+2coxALqka9f+yNJh vUoXrZbA1D2fbFPAv7yCSx1mWQPbOEEWiKPNxc7nxNwXZkfg5pY+BmDkw58PSfq2c0C+ hfL7I0Z+dXoYeCDdf5gfKGI9HaefZ+w5RoXjkrTyEHccJ0HYewZ10eMuFpCgpRjORhbL cEIWx760kpVNoGRE4BpKJgHGHjV237ZHhm+hnZ79Tew+DRqFTZ+btkCE6MYyYWjQvINP fcga0qEqQRvH6CmfzkkZyuEKiMDp91YbKthh7nlJ7bvqmSNTF8z4mS9CGRwOgh5gPOl5 ywbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=A7TxAqI1x3mXmiP3OaieHVYTcijvueKMPxYOVnglenU=; b=pr1DOUR5u7oKqiJB6QN1k+MHd+r3HjgGb8ICmnpu86L8wL0117gFS4/wwaFVEq9K4l RoRZxVhjA0V83rRDpjUcL+TTD8B+w/u+EmSNdf11GCdigh1mN8zFGMcXCuNnBPl32AVT HEJ3Ea3Gq5nuZp3HHRghMl3eD8nmNAuNQDpuLSdjPLWjANxRXaEO/6fOEiNK71M1AyDM +QnkUlZAg2e99WeuwUCdKTwYJr8/M8jxDhuK0QqID8Uca/FygIeWCcQlcYZospQ16dXL rdw6Nw3kxq+NaQkHc/namDVrMYcLtjm6g2TFCv5rGZ7kWmpr7+NhOOln8Yyeo9IWYBh/ NGEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rJk6k5hZ; 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 kl10si1368852ejc.291.2021.01.23.06.59.38; Sat, 23 Jan 2021 07:00:16 -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=rJk6k5hZ; 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 S1725891AbhAWO6C (ORCPT + 99 others); Sat, 23 Jan 2021 09:58:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:39460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725274AbhAWO57 (ORCPT ); Sat, 23 Jan 2021 09:57:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F095722AAA; Sat, 23 Jan 2021 14:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1611413838; bh=mJ8Vk7OPDZudag1atvRjpfC0hiXiUkqHVgV0cu7w/68=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rJk6k5hZY7Mw5I1Qm8FNA33WQfONgqWi/a5fYFTxYzCUcjcV+sJyNfExbxzv7v2GQ 8sbSDWw1kH7+kRjsSh8EcRdO5iBBXzTzWeLJ/olkFS+oeWim//q/iAjMxdtOK9oLxy D+zEGOEUd2031JuCweuqM5/MkBR2rkXmLvI9MfzE= Date: Sat, 23 Jan 2021 15:57:15 +0100 From: Greg Kroah-Hartman To: Marcelo Ricardo Leitner Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Daniel Borkmann , Stanislav Fomichev , Eric Dumazet Subject: Re: [PATCH 5.4 29/33] net, sctp, filter: remap copy_from_user failure error Message-ID: References: <20210122135733.565501039@linuxfoundation.org> <20210122135734.750091426@linuxfoundation.org> <20210122165545.GJ3863@horizon.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210122165545.GJ3863@horizon.localdomain> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 22, 2021 at 01:55:45PM -0300, Marcelo Ricardo Leitner wrote: > On Fri, Jan 22, 2021 at 03:12:45PM +0100, Greg Kroah-Hartman wrote: > > From: Daniel Borkmann > > > > [ no upstream commit ] > > > > Fix a potential kernel address leakage for the prerequisite where there is > > a BPF program attached to the cgroup/setsockopt hook. The latter can only > > be attached under root, however, if the attached program returns 1 to then > > run the related kernel handler, an unprivileged program could probe for > > kernel addresses that way. The reason this is possible is that we're under > > set_fs(KERNEL_DS) when running the kernel setsockopt handler. Aside from > > old cBPF there is also SCTP's struct sctp_getaddrs_old which contains > > pointers in the uapi struct that further need copy_from_user() inside the > > handler. In the normal case this would just return -EFAULT, but under a > > temporary KERNEL_DS setting the memory would be copied and we'd end up at > > a different error code, that is, -EINVAL, for both cases given subsequent > > validations fail, which then allows the app to distinguish and make use of > > this fact for probing the address space. In case of later kernel versions > > this issue won't work anymore thanks to Christoph Hellwig's work that got > > rid of the various temporary set_fs() address space overrides altogether. > > One potential option for 5.4 as the only affected stable kernel with the > > least complexity would be to remap those affected -EFAULT copy_from_user() > > error codes with -EINVAL such that they cannot be probed anymore. Risk of > > breakage should be rather low for this particular error case. > > > > Fixes: 0d01da6afc54 ("bpf: implement getsockopt and setsockopt hooks") > > Reported-by: Ryota Shiga (Flatt Security) > > Signed-off-by: Daniel Borkmann > > Cc: Stanislav Fomichev > > Cc: Eric Dumazet > > Cc: Marcelo Ricardo Leitner > > Signed-off-by: Greg Kroah-Hartman > > For sctp bits, > Acked-by: Marcelo Ricardo Leitner Thanks for the review!