Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp41777pxb; Mon, 13 Sep 2021 12:24:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZMjZabFFLojZ2DJkfktnpV4zDzVdwf9W3/trFn3VT8EflPC3Pf4ZqvUPv2STFE58LS/Ll X-Received: by 2002:a02:878e:: with SMTP id t14mr11029143jai.4.1631561039726; Mon, 13 Sep 2021 12:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631561039; cv=none; d=google.com; s=arc-20160816; b=msFxXyHy7+6E15ai0N1kvDPnWEUQgu9rWNfeWkTji2ibW8A4JYiYfAhq68u2EUYJhm d/oEEwaUgBHcvicC9GDPiyFdJWvfunAXophhw+VkzZyOdg+nMo0R3hPrFUY/4gYidlFd 3vyH1aOD/VChlFITxYm8wyW6ipcAKN3shNkSCxPAJfSAgkODadrcxA5HaXW4Vjpz80JV y12Ic2s3r8fiDBVSfXABH9xNj4lhH3TG4OB81npoSv7SFRl1Gw2C0Y6W5SaQljFnAGsb FVsBjUbBWCmN/D4tkQfNsb4YJiGX4rb7aPmGegdFdJ/PBpSAfMGTtb1NXT0AdE+F0Dez SaGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8IOEFCr52oek7wdtZeWIsTJaqM1Z8nruhrx3fqxjvuY=; b=O9WDrU6KYulOrQnjhT1XumJNkWtn52sWxe5HMDZInWR1y9ZwBeqZprQmxzLSFj8ok5 bOchBXB6RHkGD5qLZCQIoTH3YdoZyUi3RvzZrNPhW2wPTidw697fWy2OqyHlkJ9ZdSPj CWZMBDnCg+bjI7MywuO3rYzF5ugRvoxfFFd5ErL8h4pBTW8Zc2HZutx4ruhE7gqrV80y D7ceDNV/4gFXmbsUjF/ROBTuDaZqYToe0rdbZqiMRu2BDqw2B+KbfbS1eG4/9SsQLcVz PkSQpCKIjPWTP3KUzZvJo/e7KKdzi3gShFd6vNvY1zYUeL/Ok2D7lvTwEMhVpwEPFBnf QFeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i5viaPvA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 20si7055108ioz.25.2021.09.13.12.23.47; Mon, 13 Sep 2021 12:23:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i5viaPvA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240930AbhIMN1P (ORCPT + 99 others); Mon, 13 Sep 2021 09:27:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:38020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240714AbhIMNYz (ORCPT ); Mon, 13 Sep 2021 09:24:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 162FC6121F; Mon, 13 Sep 2021 13:22:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539329; bh=e3e5napruXIrkiDjQDDOcdyWnCKtkl4GGRK1tVVhW7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i5viaPvAguowbCSjmjUfeSmJnBxXYn0pSM7MVAAVWUTfmVL9uFLSn8P15YtKdjUj5 zRUTYMauamPdAKFcPGHWP7zL5EfhLEY7YuiYh/ssjW3nyoPkgdS1oCaeMHiD1C5wGL 7u8tvm7aoHrt2tUvWFVlasIQjClenddiYBZBaB+I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Coddington , Chuck Lever , Sasha Levin Subject: [PATCH 5.4 096/144] lockd: Fix invalid lockowner cast after vfs_test_lock Date: Mon, 13 Sep 2021 15:14:37 +0200 Message-Id: <20210913131051.152078160@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131047.974309396@linuxfoundation.org> References: <20210913131047.974309396@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benjamin Coddington [ Upstream commit cd2d644ddba183ec7b451b7c20d5c7cc06fcf0d7 ] After calling vfs_test_lock() the pointer to a conflicting lock can be returned, and that lock is not guarunteed to be owned by nlm. In that case, we cannot cast it to struct nlm_lockowner. Instead return the pid of that conflicting lock. Fixes: 646d73e91b42 ("lockd: Show pid of lockd for remote locks") Signed-off-by: Benjamin Coddington Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/lockd/svclock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 61d3cc2283dc..498cb70c2c0d 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -634,7 +634,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, conflock->caller = "somehost"; /* FIXME */ conflock->len = strlen(conflock->caller); conflock->oh.len = 0; /* don't return OH info */ - conflock->svid = ((struct nlm_lockowner *)lock->fl.fl_owner)->pid; + conflock->svid = lock->fl.fl_pid; conflock->fl.fl_type = lock->fl.fl_type; conflock->fl.fl_start = lock->fl.fl_start; conflock->fl.fl_end = lock->fl.fl_end; -- 2.30.2