Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1796759ybl; Wed, 28 Aug 2019 22:03:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBKmnrSRauw+mTLUjeVcPKqE5u9fKq1mbyhimHR9SC+XcKB2aKn+IyFJqo9Z5JNdjqIBXB X-Received: by 2002:a17:902:b196:: with SMTP id s22mr8085440plr.241.1567055026915; Wed, 28 Aug 2019 22:03:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567055026; cv=none; d=google.com; s=arc-20160816; b=XWTIcjIn2pBDBA/qzCRtAhuJcRmsdQY5UR1+zGoqGHk+y4/QCfDwO7NmQy2vxArWLe s0YKE5RjNlB1bUKr3H5/lcnBsvsHJixs5SYvE4jwzquSRNCmYl01rpvme0tpjAZxDTgW F7QH4erPIzcXq9MS8B8j0nEgOWEKDuaJ68gKr//ER9M2flfacsAVsh4pJRP1ZYNdV1lH yermQAg80Q8RGFqBfEkdKtColngfiqAGD2+YMb0mqkb2fRCIJUS9HLgLM3tfsUqbySQn zLjxHb968sycHyWeYsp+ugxPmi0FPYpzfN9ICYpgX7036jU6N79NccoPlKnNlA+CLeFl ULUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=LgMi/tOCGdx9z9EgjX0DOVGstnnLhYUUExXCPTNrvk4=; b=aNoFmKHovsm9OWue72yVVyIKQr6TAUrhPqWNbguRpKDNu0GGOQTS/TChM9jsF8lZ9F xx622UPK07zsY2/DdfQzIDcVTRlXzTbyOFWsxIE1UekDxh2A8IId9NGRXniiHBJdBL4m 2MwTvqrTYAt3tDuBBikpG9lUfBlGN0/TrZmCjayWIhAUXPKNp1gMtQ2O5hxllpX79oU6 rvOBzJwBtHH5PjxYFIEE7/FAoyF1GYyOlE0H5PhfjIFNIMH6TKS0e30yTH8HOtMKv8J9 a9YrCAIvXTVLhfivEo4lB34osrIurmiMqdOX/tnwk9HFCQ2jeqx8rWCo9WI+vSIpYQjX yZYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="HGUOE0/G"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si911860plq.1.2019.08.28.22.03.30; Wed, 28 Aug 2019 22:03:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="HGUOE0/G"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725917AbfH2FCl (ORCPT + 99 others); Thu, 29 Aug 2019 01:02:41 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35419 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbfH2FCl (ORCPT ); Thu, 29 Aug 2019 01:02:41 -0400 Received: by mail-pl1-f195.google.com with SMTP id gn20so1014312plb.2; Wed, 28 Aug 2019 22:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=LgMi/tOCGdx9z9EgjX0DOVGstnnLhYUUExXCPTNrvk4=; b=HGUOE0/GrUyV2OTY2CITe3OSYyiH1ZaPEVlYKIDE6D3wUi4KNgXz2F3Nw1NPJQvuQY 4q0hLcS6BC46Ir4eIlxdKcYm7KyFAIivvMpj+HTTjqwCNiKCrCdjcuICwnfZsUujsQEi WvC5l3hqCtW/udICeHHBV1BnYq30TNVsRU14MTPKf1sUA9Ntw4ycWulsHVnyjj9ifCLI yMPwWCnJrEx1ATI7rb75NRu0PGxbI0p46fNrYW73tEzdOcm96sd5vatezLa1lDGNDg+m RqePAZfocxBvODzP9EvUraPX4W/GFY0k2GwTzUYFExEO511lgm6je1sK5cu9yDDP7dRM 74ug== 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:message-id:mime-version :content-disposition:user-agent; bh=LgMi/tOCGdx9z9EgjX0DOVGstnnLhYUUExXCPTNrvk4=; b=jFblr3vrJ1ZSkVTTsAv6U9Xg6BGeoq/SkJObooCOuTa4TMmriN87rXimQu/pgtObu0 ToLYrY4FhjKgN6Tb/7gO9dh7eHA0n0rmlXpBZNeQayrrIZGfrk/t3+jQ1wj6ngRC2qrY iC3hPVpTddYAG3g06Crc6BVwVLRLO9l0xVaXIz95RoNGsC+v+9BOqAOKM60IyuA0CA1m xV3ZEv7der4rpKt8iAneic/ELNWXjx3zeYA31CI7Tjjan15VgvMYWKnItbSzV3wlOhYt zibKB7UEwRYG8U2w/Of+aICWZ3bsITAUsH9B4VxynqM/yvFNgE64nYktKeywydrqCNVX lSSg== X-Gm-Message-State: APjAAAXkw6/g2AdqzBvqFdi9o6YSkZr8JEhmwh77onO+en5GUCVfSb0T /iDJy40tVtox7uip/1uqWmI= X-Received: by 2002:a17:902:ff0c:: with SMTP id f12mr1164440plj.67.1567054960830; Wed, 28 Aug 2019 22:02:40 -0700 (PDT) Received: from localhost ([39.7.51.95]) by smtp.gmail.com with ESMTPSA id s7sm1635703pfb.138.2019.08.28.22.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 22:02:40 -0700 (PDT) Date: Thu, 29 Aug 2019 14:02:37 +0900 From: Sergey Senozhatsky To: Steve French , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: build_path_from_dentry_optional_prefix() may schedule from invalid context Message-ID: <20190829050237.GA5161@jagdpanzerIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Looking at commit "cifs: create a helper to find a writeable handle by path name": ->open_file_lock scope is atomic context, while build_path_from_dentry() can schedule - kmalloc(GFP_KERNEL) spin_lock(&tcon->open_file_lock); list_for_each(tmp, &tcon->openFileList) { cfile = list_entry(tmp, struct cifsFileInfo, tlist); full_path = build_path_from_dentry(cfile->dentry); if (full_path == NULL) { spin_unlock(&tcon->open_file_lock); return -ENOMEM; } if (strcmp(full_path, name)) { kfree(full_path); continue; } kfree(full_path); cinode = CIFS_I(d_inode(cfile->dentry)); spin_unlock(&tcon->open_file_lock); return cifs_get_writable_file(cinode, 0, ret_file); } spin_unlock(&tcon->open_file_lock); Additionally, kfree() can (and should) be done outside of ->open_file_lock scope. -ss