From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Schmidt Subject: Re: [PATCH net 1/7] bnx2x: prevent crash when accessing PTP with interface down Date: Mon, 6 Mar 2017 15:04:22 +0100 Message-ID: <1af37eff-26dd-8f3f-5f2e-ec2ab39055a3@redhat.com> References: <20170303160834.4125-1-mschmidt@redhat.com> <20170303160834.4125-2-mschmidt@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: "Elior, Ariel" To: "Mintz, Yuval" , "netdev@vger.kernel.org" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:39382 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754279AbdCFOrO (ORCPT ); Mon, 6 Mar 2017 09:47:14 -0500 In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: Dne 5.3.2017 v 10:43 Mintz, Yuval napsal(a): >> It is possible to crash the kernel by accessing a PTP device while its >> associated bnx2x interface is down. Before the interface is brought up, the >> timecounter is not initialized, so accessing it results in NULL dereference. >> >> Fix it by checking if the interface is up. >> >> Use -ENETDOWN as the error code when the interface is down. >> -EFAULT in bnx2x_ptp_adjfreq() did not seem right. >> >> Tested using phc_ctl get/set/adj/freq commands. >> >> Signed-off-by: Michal Schmidt > > While I have no objections to the patch contents, does it even make > sense to try adjusting frequencies on a DOWNed interface? > Wouldn't it make more sense checking this in the calling context > Instead? The caller does not know. A PTP device is not necessarily associated with a net device. Michal