From patchwork Thu Sep 21 02:24:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 142775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4695262vqi; Thu, 21 Sep 2023 01:36:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzOdXtkX+h72gFhKkMbP0Ufq5L1gVIBiKXlelav7/pSmhqOi6t5nktgK35p/m2rG3s+G3a X-Received: by 2002:a25:d788:0:b0:d85:bc17:eba5 with SMTP id o130-20020a25d788000000b00d85bc17eba5mr3206651ybg.43.1695285393302; Thu, 21 Sep 2023 01:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695285393; cv=none; d=google.com; s=arc-20160816; b=dpRvUPbQdf135TTB0Up8JFQLW7MzjDWMDT/HLstU5Y8can1xnM5DroEMZFiudDf6po hAsGEb4lSlm4mqDvpRKv7CYDHwqzax/kFSfGWfyJTll5frSOpjzqLHU3bE4fOQXO1BQ7 ep89IMndoCdW6i8Njo/pye7Cq+KlG1PYRPCEo9At7ciKsc1wEsLNiIIaTu9U0uKyXeIE XgL0trzDEVSFxE3KTV3NLA3TUlrkETTAjhNIt4UeuYIV9J3ZSrfp1vem0hZ/MLQYjbXE pR+W37bDGofpmr3mpKyG4K8fFzcDhIpJRW1IlZAJ5hOKYGyYKWae8nQqZDmYEehqf5/v PTvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Tc0bjCqixzwYqyqmCYYQsNKe2jTu81OkpkWyIhDzUrA=; fh=pk1qL8mZrRtG/GvbzmAt8OjRV5sXDJEUd31lCHwv5X0=; b=Ctuc3f6xe28dzqOs8drdTY1LHZZoQq6FyfvVfk3B59hMz8lxn3nKkVhbzt3NyW/Sla wysSczdajqzA4LFO2IuxobP2AX0Y1g1ulEoP9N9QYhTNcadiYmwWKCkrANiZLnJ1d5Oi aR8gwaegYZUVS2Eh785liWhPundzQIK4lGD1cpeK/wPOuodkEKfnM1QVK4joIm1aMomm ZreSKnTSNq40SvzQ6l1GJg9ZdEfbrPS7bLU5Z+mCehT+irx/MJj+0PKtX1YwgDEB8oQU WbjjsXsHGDUV2OqEoAK+aRpeTlrWaKYLHcBs/qh4aDk35lOlE5u1GONUwXdWfmINTYtd pT/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dx4LJoBs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id x32-20020a634860000000b0056a36ac322fsi903399pgk.514.2023.09.21.01.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 01:36:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dx4LJoBs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 334F2829E90C; Wed, 20 Sep 2023 19:28:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229600AbjIUC1v (ORCPT + 29 others); Wed, 20 Sep 2023 22:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjIUC1r (ORCPT ); Wed, 20 Sep 2023 22:27:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76A80D3 for ; Wed, 20 Sep 2023 19:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695263217; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Tc0bjCqixzwYqyqmCYYQsNKe2jTu81OkpkWyIhDzUrA=; b=dx4LJoBs60HkqxdRbqzZC+T/uz08hdBEz/Zl73XksXYAqhzE1yU8l5OlbkCipdL9YWYUcx 85BEQ4Wof/wdW4d/1ND6EEqqdMB32zN7jK29aV7MnoEyC1kzQ5NPFYZlR43O1/ZbJT9cAy 4pS6mDYG6nbH/66uRw4OAcqxik+LE2s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-Zz11l0T_MlS-2Rmm89xoxg-1; Wed, 20 Sep 2023 22:26:54 -0400 X-MC-Unique: Zz11l0T_MlS-2Rmm89xoxg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 005A8101A53B; Thu, 21 Sep 2023 02:26:54 +0000 (UTC) Received: from li-a71a4dcc-35d1-11b2-a85c-951838863c8d.ibm.com.com (unknown [10.72.113.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C51E40C2064; Thu, 21 Sep 2023 02:26:49 +0000 (UTC) From: xiubli@redhat.com To: miklos@szeredi.hu Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Xiubo Li Subject: [PATCH] fuse: pass ATTR_KILL_SUID/ATTR_KILL_SGID mode bits to user space Date: Thu, 21 Sep 2023 10:24:36 +0800 Message-ID: <20230921022436.1191166-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 20 Sep 2023 19:28:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777635576571973496 X-GMAIL-MSGID: 1777635576571973496 From: Xiubo Li Such as for the xfstest-dev's generic/684 test case it will clear suid and sgid if the fallocate request is commit by an unprivileged user. We need to pass the ATTR_KILL_SUID/ATTR_KILL_SGID flags to userspace. Signed-off-by: Xiubo Li --- fs/fuse/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index f67bef9d83c4..73dcf54efbff 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1938,11 +1938,11 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry, attr->ia_mode = inode->i_mode; if (inode->i_mode & S_ISUID) { - attr->ia_valid |= ATTR_MODE; + attr->ia_valid |= ATTR_KILL_SUID | ATTR_MODE; attr->ia_mode &= ~S_ISUID; } if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { - attr->ia_valid |= ATTR_MODE; + attr->ia_valid |= ATTR_KILL_SGID | ATTR_MODE; attr->ia_mode &= ~S_ISGID; } }