Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp67346pxb; Mon, 13 Sep 2021 13:07:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1m9+sjHCEPAEAn1BDwojPtnLdZSd6x3CcGptLQ8aTZbkgH9ust5QBeG/3FRf9gLgM/Esf X-Received: by 2002:a17:906:7b54:: with SMTP id n20mr14401798ejo.525.1631563669527; Mon, 13 Sep 2021 13:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631563669; cv=none; d=google.com; s=arc-20160816; b=tKXaY7LDjEtr3PDmg2nyfa/afcT3KT8uQRLOtyTPdZEnKcNqhqw19lJM58pklFuZWO 7qUovS/3kURkfruDuwD8FbjbMHDMvDNQZisX0nUvvivYnbUGm75yxWUprf5yLObZz/yH fp8nbMySas6PDuM2lkd4Bk+tZsrm6LkzyBHwyLtTBOjGGSxIzZvuxAA+dUFW/KSZKOsi qoNYUaXs4zj4gxH77jVNSbTStt2TKy+Pat5S3SKaR9lutzeamMTqUqdCUZir8clwXu0N 7DEAfUQor3kcwxxZru7uXGIzc+DslxbvLUmoucs0C4Wl8Bx8m6bu0uYUu13jzm7gAjh2 Gtlw== 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=p7RwDKIYsRziGNFYQ+pZeq6E+Cg7lMLqrY+v3fTCPdtrEf+N3D8NT7t20Oo7854OtR 4PiLC+zxaWPiiXJF8lXCC1DVsNhTBL0CpwYSzSz/bmA4LjAK5KM7En9U6TotRG8mBHwh sU7LSQsrcYkRmKepxSmMnuQH3WVQt+PXLkVtsC6p/na7gqohawHoAwKPl6AYGlW4o/OE CU2oY31MSvd9+tq9282zKhitZCPTGjvzQXOxC4FLl2lMV194Yzyonkaxkir3eiW2L1mv qMnKHLLLykktRw+tba8NArvv74TKMaVJbzQkqh/6raUw75ofIi0w27Og6a5XO3EPUEvJ ju/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="0IyovGn/"; 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 h91si5942355edd.104.2021.09.13.13.07.26; Mon, 13 Sep 2021 13:07:49 -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="0IyovGn/"; 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 S243392AbhIMNrQ (ORCPT + 99 others); Mon, 13 Sep 2021 09:47:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:40602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241124AbhIMNmD (ORCPT ); Mon, 13 Sep 2021 09:42:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 878316135D; Mon, 13 Sep 2021 13:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539802; bh=e3e5napruXIrkiDjQDDOcdyWnCKtkl4GGRK1tVVhW7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0IyovGn/HzszcWYvjVZ6Y1772681EizpRBppNDs1Cw8DBDokJrEF1361CLUt9DpTP ieFFuWlx0Fn+Nj0NK1QaLbk6rg/51JL0Q5LZNCJ7SZ2HOIin/kQTu5PxstlLdmDqQs 92VA2Yrz61wYpyBkRF73tT1uICtVG6mXzQjepJ8g= 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.10 165/236] lockd: Fix invalid lockowner cast after vfs_test_lock Date: Mon, 13 Sep 2021 15:14:30 +0200 Message-Id: <20210913131105.991491498@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@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