Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp220138pxb; Mon, 13 Sep 2021 17:29:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt2TxaZfvHpAXm20l9WAqn+oH7WocNWfrWvRfFQ65EJ2sqGfXmKVia16uC0SINlpFybS4q X-Received: by 2002:a02:630f:: with SMTP id j15mr12155268jac.62.1631579393214; Mon, 13 Sep 2021 17:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631579393; cv=none; d=google.com; s=arc-20160816; b=pB3FcK2TCVYuKkIH9R1c6KmP9VCR+nfa+FO0JNOyxM7zjaZBoLgjspUiV49fgLW0uA zTwZTpx/giL2fvgoUTTJUyKN6UQXwS7JnyvK6TONPdviMAe8t65bUAmG5VxrfGNN4gCw dEgQe/2KBsaib4bmi0GsTBzY+5tnSkg/E72Zwz3DhVJnImi0T+gej7ltvxhyFy7Rmvkc /V6pWVzJF5vp86g+fBtwm8OZJukrDQSHqB7blXiCimKEM7ViTLhfbX4ckiuXE5VnfXUX h1flqkSXc3VTPoQdN62E7q40FSMS4jbULENLUMGTb6lITdEDnXHcRnC3eoSZlKNsqtyG Qfzg== 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=XAHFVpvfSEnN5PqVeAK5Cg/3nyDMSOUx/Z8FIQV4+6U5VFlYwk8vdmbZUjFACse281 wPjxnJ8Pgv/+/9kJcylrRTRXXtTO2GKGPvDSUoetlISDtGFUq8TnxnEOG+mJKZClX0lP nqaIPLXu+Ay/ebfesrKfYru0vWHZ1KmWWTXcnC8RsA4/RvjgvIBoH7yTdqbojYUFqyKg sLT2eSEPsX7fSBBl0S2VdfqMEEWW5CY69cGXqS4XQnf3eZmzQzHH6MI+svZkWUttLBpP bpYY4cBNvFwQ1FJl/Fx5CUxySYuA+zDPsy/5RI8KnjwtjdO6D2PtnWHBzBRYQwCIesBC 8Gbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KgvWN9JM; 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 k35si8275062jac.46.2021.09.13.17.29.42; Mon, 13 Sep 2021 17:29:53 -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=KgvWN9JM; 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 S1345169AbhIMOQe (ORCPT + 99 others); Mon, 13 Sep 2021 10:16:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:34374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240852AbhIMOLP (ORCPT ); Mon, 13 Sep 2021 10:11:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B758561AA6; Mon, 13 Sep 2021 13:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540528; bh=e3e5napruXIrkiDjQDDOcdyWnCKtkl4GGRK1tVVhW7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KgvWN9JMkyem5rNA5pIHGRyvyjGXuHLo2Z5MLC3c8cg6XHDTJyYgX40tF+FkCsJTn g482iu90TSQd1fNZ2Wl0xk+LguC+w2bdeUVnmmbBBVbC++GBESeEBBh7UpBrQo/d7y HU2RbbJTknIAa4f0xw/rN7apAQpoMGvZRvmVw74U= 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.13 198/300] lockd: Fix invalid lockowner cast after vfs_test_lock Date: Mon, 13 Sep 2021 15:14:19 +0200 Message-Id: <20210913131116.062088268@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@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