From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6175EC432C3 for ; Wed, 27 Nov 2019 06:47:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DD62120674 for ; Wed, 27 Nov 2019 06:47:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD62120674 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3D66E6B034C; Wed, 27 Nov 2019 01:47:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 385D56B034D; Wed, 27 Nov 2019 01:47:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29B896B034E; Wed, 27 Nov 2019 01:47:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id 11A6C6B034C for ; Wed, 27 Nov 2019 01:47:10 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id C65DE180AD80F for ; Wed, 27 Nov 2019 06:47:09 +0000 (UTC) X-FDA: 76201125378.05.swing97_215554b58cc1b X-HE-Tag: swing97_215554b58cc1b X-Filterd-Recvd-Size: 2551 Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 Nov 2019 06:47:08 +0000 (UTC) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 028AC1D2611040F19A2B; Wed, 27 Nov 2019 14:47:05 +0800 (CST) Received: from [127.0.0.1] (10.173.220.96) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Wed, 27 Nov 2019 14:46:56 +0800 Subject: Re: [PATCH] mm/shmem.c: don't set 'seals' to 'F_SEAL_SEAL' in shmem_get_inode To: Hugh Dickins CC: , , , , , References: <20191127040051.39169-1-yukuai3@huawei.com> From: "yukuai (C)" Message-ID: Date: Wed, 27 Nov 2019 14:46:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.220.96] X-CFilter-Loop: Reflected X-Bogosity: Ham, tests=bogofilter, spamicity=0.047963, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2019/11/27 12:24, Hugh Dickins Wrote: > On Wed, 27 Nov 2019, yu kuai wrote: > >> 'seals' is set to 'F_SEAL_SEAL' in shmem_get_inode, which means "prevent >> further seals from being set", thus sealing API will be useless and many >> code in shmem.c will never be reached. For example: > > The sealing API is not useless, and that code can be reached. > >> >> shmem_setattr >> if ((newsize < oldsize && (info->seals & F_SEAL_SHRINK)) || >> (newsize > oldsize && (info->seals & F_SEAL_GROW))) >> return -EPERM; >> >> So, initialize 'seals' to zero is more reasonable. >> >> Signed-off-by: yu kuai > > NAK. > > See memfd_create in mm/memfd.c (code which originated in mm/shmem.c, > then was extended to support hugetlbfs also): sealing is for memfds, > not for tmpfs or hugetlbfs files or SHM. Without thinking about it too > hard, I believe that to allow sealing on tmpfs files would introduce > surprising new behaviors on them, which might well raise security issues; > and also be incompatible with the guarantees intended by sealing. Thank you for your response. Yu Kuai