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=-10.1 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL 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 1E511C433DF for ; Sat, 4 Jul 2020 02:21:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFDD72068F for ; Sat, 4 Jul 2020 02:21:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qYwdbMJL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFDD72068F Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3DDAC8D000C; Fri, 3 Jul 2020 22:21:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 38D8C8D0001; Fri, 3 Jul 2020 22:21:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A3398D000C; Fri, 3 Jul 2020 22:21:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 150FB8D0001 for ; Fri, 3 Jul 2020 22:21:04 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 82A181DE1 for ; Sat, 4 Jul 2020 02:21:03 +0000 (UTC) X-FDA: 76998790806.23.place44_5701b4426e96 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 5B6BC37606 for ; Sat, 4 Jul 2020 02:21:03 +0000 (UTC) X-HE-Tag: place44_5701b4426e96 X-Filterd-Recvd-Size: 5635 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Sat, 4 Jul 2020 02:21:02 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id l6so30338715qkc.6 for ; Fri, 03 Jul 2020 19:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=EBelg8rUHkoBK6BygeTY9TBG5a6llEBLIpHu4go8s9M=; b=qYwdbMJLD8+RAtZOE80q2RzCIyjQ7j6teYUvWAjNMq4Oy5+SykO6+gIgVjaEUGOlZg exaM0F+PR50trQgKXz1r0ITt0v72dtuU+0Y7Zr6Xc4l3+1lYMNjYTTPpdAv1dwIrzAr0 VC1wgwawSJOr4+1dtIyuDFffxGxDc681tNr3XZWVaUx53FRfuiR4l3KlAXUS6bBSzgyG jjpVCvF6pyahDNtO52gONMMrD3/PkJ1lR+XBPgNflTyB4AzC602o4Qm07E300eJwrRZj 29m3VwymPjxg5kOXHHkTKRYS8/zoIeL0OGkPhhnWgWB+2Nj6TeHWIxW9dH+MH9vhlaEp hlcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=EBelg8rUHkoBK6BygeTY9TBG5a6llEBLIpHu4go8s9M=; b=kOWLGUw+jizGtcIaktNipyzDmM9mVEmp9b3U9zQufLaIPKrHYXB/f5owVbr/c3dNoz JtG5kZ/kR/Uk6i5W4fXPr1jf9eZCJukURQ4LHwiEGq1eQSBNRRRwxe/wqv2goi6PvnyG DkLtmBtP59nIcfw0AZP1JQR89ph7xCl6I63qFskD8CmfwPRrEJjHMi8z+sraBA1zwMZ7 a5/PCmHpuJYEKkwTtkgeBzfngpqxp6ytfvx1upSpwgDsdZP7aXQ3ovSJl/vg6/yeyxES wJeO0JXCeeshSbdIOvr6jjTDKJNdXuciKXB9TKru7BDRmWODJqk0Ti11EqpqhjUJDKyz ly/g== X-Gm-Message-State: AOAM533wt1XxX6D1Eu+WTYZ2GZpnBL/5B40NUB6DIug3wT5NFGnPKUDS CICmh1C7WO106SOLXpMYzxa6LA== X-Google-Smtp-Source: ABdhPJxtKUast0yoWLWoUrEB7oTw1fhG2DNczxVRYpkxB297LIxs311YAmDE1nj2Tnva9wHhoj604Q== X-Received: by 2002:a37:a605:: with SMTP id p5mr34731619qke.428.1593829261840; Fri, 03 Jul 2020 19:21:01 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id y22sm9730334qky.84.2020.07.03.19.20.59 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Fri, 03 Jul 2020 19:21:00 -0700 (PDT) Date: Fri, 3 Jul 2020 19:20:44 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: cgxu cc: Hugh Dickins , Andrew Morton , Daniel Xu , linux-mm@kvack.org Subject: Re: [PATCH] mm/shmem: fix freeing new_attr in shmem_initxattrs() In-Reply-To: <72d2c8fd-9f07-a48c-cb92-f3f0ba2f26b4@mykernel.net> Message-ID: References: <20200703065636.20897-1-cgxu519@mykernel.net> <20200703122043.c931cf9e0c85878ccc4e53f1@linux-foundation.org> <72d2c8fd-9f07-a48c-cb92-f3f0ba2f26b4@mykernel.net> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Rspamd-Queue-Id: 5B6BC37606 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Sat, 4 Jul 2020, cgxu wrote: > 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. So it has. Well, I'd prefer you to make one patch for all the fallout, sent to Andrew, Cc'ed to the people Cc'ed on fdc85222d58e and me; then Andrew will drop mm-shmem-fix-freeing-new_attr-in-shmem_initxattrs.patch in favor of the new patch - which will be fixing more of mm/shmem too (it calls the buggy inline function). But if you or Andrew disagree, no problem, better to fix it piece by piece than not at all! Thanks, Hugh