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,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 8033EC433DF for ; Fri, 3 Jul 2020 20:15:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 302B020724 for ; Fri, 3 Jul 2020 20:15:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aRFBpJRq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 302B020724 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 BBB7D8D009A; Fri, 3 Jul 2020 16:15:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B45AE8D0030; Fri, 3 Jul 2020 16:15:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A342C8D009A; Fri, 3 Jul 2020 16:15:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0117.hostedemail.com [216.40.44.117]) by kanga.kvack.org (Postfix) with ESMTP id 8E0008D0030 for ; Fri, 3 Jul 2020 16:15:29 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 594A7180AD806 for ; Fri, 3 Jul 2020 20:15:29 +0000 (UTC) X-FDA: 76997869578.14.hill64_1a120a226e94 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 2D20D18229837 for ; Fri, 3 Jul 2020 20:15:29 +0000 (UTC) X-HE-Tag: hill64_1a120a226e94 X-Filterd-Recvd-Size: 4618 Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 3 Jul 2020 20:15:28 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id k4so27379822oik.2 for ; Fri, 03 Jul 2020 13:15:28 -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=Vm57swlwKWyoBTfBszQQnUcHptchHcams2m9s5hPAK8=; b=aRFBpJRq1GQdvos/V6sxgaFVjiKqYRXvoj7qtdv3up1ApXYDwfEjWZv+0iEdKuquFo xxBJjcCuFqtq4qzJP3xcShfsqL+MR/9niZjm2QlpN9UDsIn41mzCIbZNi0hBLCvPJ562 w4KprshMddATpJ7YLI9Bhm87AFZxno5GtSNrs25uuLC0zsK8Rwogfgje2AQ2Dxl9FS16 xR2B9s/PPd1tT0z4sdF0f7tIBSP9kwobUUBdsYct29Hx3Z9aTEGQgRkcnJY6CuYXO3+y XEwlVoxRximI5+MH1NaMVcieRrHB6cQ39UF7PXHAJeB2OTnPwRxgo76PvYTpGt7BSJOm Tjnw== 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=Vm57swlwKWyoBTfBszQQnUcHptchHcams2m9s5hPAK8=; b=kRKGxMXopOLHywJ55na+HHSVuYWU/8/7MJl2RVx/AT0vgAnx4haClrOqkEtUYRZr5A kEISbon4z4RCZPobvrAza+Sn2vk9rzi/F7rM2xEPVRUEYHUbWyOGgL5bks77p6uLHazx KcUQ5QxpnUAQK9YeaGFRhDK/MVuy1kfn5a5sh+f+cxD2myp87s8nQpEsKth9W11Inw+Y S68N4ZU5LWHt1oAkTYcQ263TFeLOmDTWBWzFytg5dtJeUYtO9gbfyvYLzJx7WACltJfd 4i/6rtwXIZhmC1JS/WJm0p8FZKU3/r4XEdkYAlFxbZNyGrcjPZ1+/gJJJX89zLTUybri dMJQ== X-Gm-Message-State: AOAM530a6XpSkZTLti52jqcPCGqpUcYXfhz57pkZJV2z6OdmQbijAqla xlW5xYsfiQhco07EAY/6VDlXjQ== X-Google-Smtp-Source: ABdhPJxm571qZ7uRSeoTo9vO/peNXWGuAoyh3f+MZ5iOHjpBNAPZ0pCSb+8PJBEtC8mjvlgyXCE4yA== X-Received: by 2002:aca:4556:: with SMTP id s83mr24531101oia.17.1593807327832; Fri, 03 Jul 2020 13:15:27 -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 e13sm191463otk.68.2020.07.03.13.15.25 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Fri, 03 Jul 2020 13:15:26 -0700 (PDT) Date: Fri, 3 Jul 2020 13:15:12 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Chengguang Xu cc: Andrew Morton , Daniel Xu , hughd@google.com, linux-mm@kvack.org Subject: Re: [PATCH] mm/shmem: fix freeing new_attr in shmem_initxattrs() In-Reply-To: <20200703122043.c931cf9e0c85878ccc4e53f1@linux-foundation.org> Message-ID: References: <20200703065636.20897-1-cgxu519@mykernel.net> <20200703122043.c931cf9e0c85878ccc4e53f1@linux-foundation.org> 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: 2D20D18229837 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 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. Hugh