Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2172918ybm; Thu, 23 May 2019 12:33:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpUQWEFYJm4IIaliLCY0BX6Gjx6ICABaeJz7/qU3okCZzNAStUwiX57EjM4rN8V4rXd1fr X-Received: by 2002:a17:902:6bc8:: with SMTP id m8mr98739341plt.227.1558640001606; Thu, 23 May 2019 12:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558640001; cv=none; d=google.com; s=arc-20160816; b=kLnlBVbvPfkPG/2CXQ0IShFK0Dhf9NiP/LGNi5xJB8JWnB5K0znZTid4FYfZowlI8N HNSzE8s7XZwMr2C9fW0GL88z0qCU47aKxMDjPW7fZ/3+st8Qmy98zrF3Pem9fyCNSKSQ X8qLesHqzJX+XnfeIqst3WClYzRDJ2uio9rgARzZML5Do95TYJKKJ/H/LuX4+7fBOXyp iU8pb/xLcK0X+4ptylawTNcFI1ax7hrOmBPXvo48etresnG7XtyYJPi3S1U2V3vk1SbI NifS8E0EJkZTJSPP0OPrQDdFwfJdYuBzQJMjVi957SoPFRcVOCgyLif9vO7o0/wZ37Iu hUOw== 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=ENgkRNwFxXbNmozx2EKipzg4GmoYDCAXoPMulKKPZFc=; b=APn/vmYc2H7f/6WT4VKGz/DuiqlIKoJeYToK/WR/PH0pbahGrGRHBrlIAStEPFIQfe tKwVqWsdHMl3D0rsweZ5TyfQNdhXHVSWhVQe14Bw6FQA8ydEJwKOLNKaFXSErtjoIaWq 8oxtudlkH4tVukRQKsHLjNe9FIUsnQfVOB8Y/l+vow1YwTwcmeOwhJDQCM2Cb0FVGbK7 IDqwjLXYdKLl61apThu/mYavvl610o37T/h8viaO9s62AozqAzOKYyBfFRnLL+VbWIQM whEJ3eBA6ljeFDth9BrOZHzCYVWA8OOwqZEbxWAQIetHwhWKgjfq0Y+m51j6/ZIg5sn0 E+sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E4aQBnao; 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 a33si543082plc.283.2019.05.23.12.33.07; Thu, 23 May 2019 12:33:21 -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=E4aQBnao; 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 S2391676AbfEWTbT (ORCPT + 99 others); Thu, 23 May 2019 15:31:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:44992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403757AbfEWTbP (ORCPT ); Thu, 23 May 2019 15:31:15 -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 01AD8217D9; Thu, 23 May 2019 19:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558639874; bh=EhYtP/rpvE8jWFvUYVqzJ7BQ2mvQOotty2PPRp7l7Lw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E4aQBnao+9liy8uvVpCI3u7Giyw7oHlvtqGnFVZJuSYqoIEbIvq8c2fxJEnrThow9 oW0/9BmPkHtmLaktH8r3dIWGidnLwFVnaldvQ7g1xnqWw/EdhgPPspsHtlGVWaDLdc gVz+VfpmwUv2bLOjaCb12ZKOv5OEyguVDcOiQdOc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chenbo Feng , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH 5.1 116/122] bpf: relax inode permission check for retrieving bpf program Date: Thu, 23 May 2019 21:07:18 +0200 Message-Id: <20190523181720.917555214@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181705.091418060@linuxfoundation.org> References: <20190523181705.091418060@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: Chenbo Feng commit e547ff3f803e779a3898f1f48447b29f43c54085 upstream. For iptable module to load a bpf program from a pinned location, it only retrieve a loaded program and cannot change the program content so requiring a write permission for it might not be necessary. Also when adding or removing an unrelated iptable rule, it might need to flush and reload the xt_bpf related rules as well and triggers the inode permission check. It might be better to remove the write premission check for the inode so we won't need to grant write access to all the processes that flush and restore iptables rules. Signed-off-by: Chenbo Feng Signed-off-by: Alexei Starovoitov Signed-off-by: Daniel Borkmann Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -518,7 +518,7 @@ out: static struct bpf_prog *__get_prog_inode(struct inode *inode, enum bpf_prog_type type) { struct bpf_prog *prog; - int ret = inode_permission(inode, MAY_READ | MAY_WRITE); + int ret = inode_permission(inode, MAY_READ); if (ret) return ERR_PTR(ret);