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=-2.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 7B8EDC433DF for ; Sat, 4 Jul 2020 02:02:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B700320EDD for ; Sat, 4 Jul 2020 02:02:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mykernel.net header.i=cgxu519@mykernel.net header.b="YjRsap1D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B700320EDD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mykernel.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2D3E38D0009; Fri, 3 Jul 2020 22:02:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 283CF8D0001; Fri, 3 Jul 2020 22:02:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 198FD8D0009; Fri, 3 Jul 2020 22:02:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id 034E48D0001 for ; Fri, 3 Jul 2020 22:02:11 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5D424181AC9C6 for ; Sat, 4 Jul 2020 02:02:11 +0000 (UTC) X-FDA: 76998743262.07.fear63_52166dd26e96 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 363661803F9AD for ; Sat, 4 Jul 2020 02:02:11 +0000 (UTC) X-HE-Tag: fear63_52166dd26e96 X-Filterd-Recvd-Size: 4467 Received: from sender2-op-o12.zoho.com.cn (sender2-op-o12.zoho.com.cn [163.53.93.243]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Sat, 4 Jul 2020 02:02:08 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1593827986; cv=none; d=zoho.com.cn; s=zohoarc; b=nfQT6Fy64NA8BO7B1z93Rn8LorL7BDIbC/Hprdd+dIpcRcXG97cx8c1Vu+NVT8pZkmhP+WXrxIDEtUaOHRxiI7IZIa5Fcs79iG6tu+LOvLIUgTB4qx2kTH+3b59LyfvUG9iuOjgZgWM97ApHEqV3nAz+A8kPPuFwf5ATT0aPGYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1593827986; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=QtlaZY3fGPcPsGkrh4YMUtX3OMbelKO/n9bKjnT0fTc=; b=bpLJKfUxg41T9M/JRtizH55zO611ZLUrodczXRKJ5BxqoLn6hWWyDCbmqpHe/TZN+hc0yGZxO7PO4j5h8bPnjxo/1tVc2IR7WsrbuOzCofVKuESwSEI0iKJ3ar4asSx5PRyrlU6g6voWHhr9IKGmLzgmJZHotekw7OZJYbaIfvI= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1593827986; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=QtlaZY3fGPcPsGkrh4YMUtX3OMbelKO/n9bKjnT0fTc=; b=YjRsap1DkCOFLvOweSkWOXv+We51Jgi6LMCeZsCoq3gCOLNVb8DqZDfBT7LxxbT3 WVwZYtZal1BQMkKITzjOEPF9lMoUA93cx9FeGzTEMQ/0mmD9Sa1NSPKgSp1oEeEvk7y 1Jy0DDTYi2N8kszMpsVb/IsZvteHH/F0WnnDDFw0= Received: from [172.16.132.209] (183.237.64.250 [183.237.64.250]) by mx.zoho.com.cn with SMTPS id 1593827984568345.8793517228403; Sat, 4 Jul 2020 09:59:44 +0800 (CST) Subject: Re: [PATCH] mm/shmem: fix freeing new_attr in shmem_initxattrs() To: Hugh Dickins Cc: Andrew Morton , Daniel Xu , linux-mm@kvack.org References: <20200703065636.20897-1-cgxu519@mykernel.net> <20200703122043.c931cf9e0c85878ccc4e53f1@linux-foundation.org> From: cgxu Message-ID: <72d2c8fd-9f07-a48c-cb92-f3f0ba2f26b4@mykernel.net> Date: Sat, 4 Jul 2020 09:59:31 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-ZohoCNMailClient: External X-Rspamd-Queue-Id: 363661803F9AD X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 7/4/20 4:15 AM, Hugh Dickins wrote: > On Fri, 3 Jul 2020, Andrew Morton wrote: >> On Fri, 3 Jul 2020 14:56:36 +0800 Chengguang Xu wrote: >> >>> new_attr is allocated with kvmalloc() so should be freed >>> with kvfree(). >>> >>> ... >>> >>> --- a/mm/shmem.c >>> +++ b/mm/shmem.c >>> @@ -3178,7 +3178,7 @@ static int shmem_initxattrs(struct inode *inode, >>> new_xattr->name = kmalloc(XATTR_SECURITY_PREFIX_LEN + len, >>> GFP_KERNEL); >>> if (!new_xattr->name) { >>> - kfree(new_xattr); >>> + kvfree(new_xattr); >>> return -ENOMEM; >>> } >> Indeed. Maybe simple_xattr_alloc() should have been called >> simple_xattr_kvmalloc(). > That would give a better hint, true. But it's been simple_xattr_alloc() > for a while, and "alloc" doesn't claim "kmalloc" or "__get_free_page" > or whatever, so its new users ought to check, and its old users ought > to be updated when a change is made. > > This is a > Fixes: fdc85222d58e ("kernfs: kvmalloc xattr value instead of kmalloc") > Cc: stable@vger.kernel.org # v5.7 > > (Though I hope the restricted use of xattrs on tmpfs cannot actually > get into multi-page allocations.) > > It's a good catch, Chengguang, thank you: but isn't your patch > incomplete? It looks like this omission goes beyond mm/shmem: > include/linux/xattr.h contains a simple_xattrs_free(), used by > both shmem and kernfs, which also says "kfree(xattr)" still. > > Please extend and re-subject and re-Cc your fix to cover that > too (and check nothing else has been missed) - thanks. Thanks for pointing that out, I overlooked that part. Since this patch has already merged to Andrew's tree, I would like to make another patch to handle rest of the fixing and that probably can go into vfs-tree or others. Thanks, cgxu