Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3068557pxb; Fri, 12 Feb 2021 08:25:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPkVAa5YXdvkTWwqG0LgWx6q7Yetn6oXVTEfvv1HPoKI/j8n6iOvOxh792C8sUy5EjzLOp X-Received: by 2002:aa7:c6d9:: with SMTP id b25mr4319009eds.84.1613147137378; Fri, 12 Feb 2021 08:25:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613147137; cv=none; d=google.com; s=arc-20160816; b=et+tpmdKPFzoi7As0cLG2tD1kXYQxZ61dn9hzlHObdXdUFoHU/ICnCImyCLe6FaQPu Yh2zrSmCukmAS2MNFjo7+joeQ8GrQccrsfGBKnaTtbClwegcvhURNU2M6OzNh95n9Ck2 fMyrJJH6zKJB67f1eFEp0Z6X8Pxb78tfL9+J1M+7yiEVaCD2Zmag9in1Ue3wgb5ea0Wy LF+EVvwzXELwM5beDOpKpnSSqaq1QJyxpQuJU+SzgEGwrHtYr9wHTVrR1kg4sP7w+lQk kDsLX0daEhaW328zucj/ytQGhiJqdVqYfK9H+9Jgjzr5dVAgRT2mX+xNdffq/gNbacju bXgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Jw4NurIl1+3qcsuNc2GWsoviHsiltiInkMZqfXhG6y8=; b=liqx01YPy/B+FA9/mEgDIg9zlQFY/U9XqyFJefvqatwzUSn7XD71tEu5ka+81B8f7Q TEkk6FAs3WZirF6//4eqho6Xq9Ar+NVT+ZJZC38PBRRZuNlV5EZoyNDD+qqGj48Hdck/ s0YmwYVPIR4UnHrrecUVVvIHVbF2uNl6iRuO1qFMPB5lw/QBzrWi4s7CjjWaxoXZxozA LQdPF4q1K+K9NMT2hS8MZc8mesCX0ucZvMddOzB4199IzvEcF8nAiR1tITguQZrbNhhI YB3XM1qqq377FdLR5HHzHdP4V9BEnXdRlRCJZd++RV1AaMSehAx649guTRR+HKeH4Tt2 2Vrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BvA3dK6z; 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 u21si6742081edy.32.2021.02.12.08.25.13; Fri, 12 Feb 2021 08:25:37 -0800 (PST) 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=BvA3dK6z; 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 S229797AbhBLQXW (ORCPT + 99 others); Fri, 12 Feb 2021 11:23:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:35240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbhBLQXU (ORCPT ); Fri, 12 Feb 2021 11:23:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 53D1464E00; Fri, 12 Feb 2021 16:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613146959; bh=cGis2STI/FXiZ6D9aq1qL5hwCPADBv6IX2lNQypgg48=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BvA3dK6zB63Q3prs2eh8ASE5tD8BKIpOsT97w1RGrtG0ZysJy23Hr0l+2xTjdc3Zx szVDsbRzOcvP7MLWbhrsQmfta5zXh5PiKZcGqv6GYoI1f7+DsA5GDg52yR9ZvTMNoR Mn1wN3rNi3P1Zw6PozC4A/c8aCzjRwcGYwYc0DPw= Date: Fri, 12 Feb 2021 17:22:37 +0100 From: Greg KH To: Min Li Cc: "derek.kiernan@xilinx.com" , "dragan.cvetic@xilinx.com" , "arnd@arndb.de" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH net-next v2] misc: Add Renesas Synchronization Management Unit (SMU) support Message-ID: References: <1613092575-17311-1-git-send-email-min.li.xe@renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 12, 2021 at 04:02:14PM +0000, Min Li wrote: > > > > xilinx_sdfec.c has: > > > > static int xsdfec_dev_open(struct inode *iptr, struct file *fptr) > > { > > return 0; > > } > > > > Which isn't even needed at all, but it is NOT trying to keep people from > > calling open multiple times. > > > > As for why the above logic does not work in your driver, think of what > > happens if someone opens the character device node, and then calls > > dup(2) on it and passes that file descriptor off to another program. Or just > > calls it multiple times from different threads in the same program. > > The kernel does not know what is happening here, and so, "do not allow to > > be opened multiple times" does not do anything to keep userspace from > > actually writing to the device node from multiple processes or threads. > > > > So don't even try, it's not worth it. > > > > > I mean if an application failed at opening the device, how can it > > > proceed to talk the device without a file descriptor? > > > > See above for how to do this. > > > > thanks, > > > > greg k-h > > Hi Greg > > Thanks for your insight for this. Now I can see this change doesn't prevent deliberate hacker from opening the driver multiple times. > > What I had in mind is that it does prevent some unintentional mistake like some one accidentally opens the application twice. The second > one would fail due to the change here. Do not add kernel code that does not work for it's intended purpose :) thanks, greg k-h