LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 02/16] riscv: Use INITRAMFS_GENERIC_UNLOAD.
From: Shea Levy @ 2018-03-24 17:44 UTC (permalink / raw)
  To: linux-alpha, linux-kernel, linux-snps-arc, linux-c6x-dev,
	uclinux-h8-devel, linux-m68k, nios2-dev, openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-sh, user-mode-linux-devel
  Cc: Shea Levy
In-Reply-To: <20180324174458.26423-1-shea@shealevy.com>

Signed-off-by: Shea Levy <shea@shealevy.com>
---
 arch/riscv/Kconfig   | 1 +
 arch/riscv/mm/init.c | 6 ------
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index c22ebe08e902..ab1b4cee84fc 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -37,6 +37,7 @@ config RISCV
 	select THREAD_INFO_IN_TASK
 	select RISCV_TIMER
 	select GENERIC_IRQ_MULTI_HANDLER
+	select INITRAMFS_GENERIC_UNLOAD
 
 config MMU
 	def_bool y
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index c77df8142be2..36f83fe8a726 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -62,9 +62,3 @@ void free_initmem(void)
 {
 	free_initmem_default(0);
 }
-
-#ifdef CONFIG_BLK_DEV_INITRD
-void free_initrd_mem(unsigned long start, unsigned long end)
-{
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
-- 
2.16.2

^ permalink raw reply related

* [PATCH 07/16] h8300: Use INITRAMFS_GENERIC_UNLOAD
From: Shea Levy @ 2018-03-24 17:44 UTC (permalink / raw)
  To: linux-alpha, linux-kernel, linux-snps-arc, linux-c6x-dev,
	uclinux-h8-devel, linux-m68k, nios2-dev, openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-sh, user-mode-linux-devel
  Cc: Shea Levy
In-Reply-To: <20180324174458.26423-1-shea@shealevy.com>

Signed-off-by: Shea Levy <shea@shealevy.com>
---
 arch/h8300/Kconfig   | 1 +
 arch/h8300/mm/init.c | 7 -------
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 091d6d04b5e5..58c9b6b1df16 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -24,6 +24,7 @@ config H8300
 	select HAVE_ARCH_HASH
 	select CPU_NO_EFFICIENT_FFS
 	select DMA_DIRECT_OPS
+	select INITRAMFS_GENERIC_UNLOAD
 
 config CPU_BIG_ENDIAN
 	def_bool y
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 015287ac8ce8..37574332b202 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -102,13 +102,6 @@ void __init mem_init(void)
 }
 
 
-#ifdef CONFIG_BLK_DEV_INITRD
-void free_initrd_mem(unsigned long start, unsigned long end)
-{
-	free_reserved_area((void *)start, (void *)end, -1, "initrd");
-}
-#endif
-
 void
 free_initmem(void)
 {
-- 
2.16.2

^ permalink raw reply related

* Re: RFC on writel and writel_relaxed
From: Sinan Kaya @ 2018-03-24 15:06 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Oliver
  Cc: linuxppc dev list, linux-rdma@vger.kernel.org, Marc Zyngier,
	Will Deacon
In-Reply-To: <1521854570.16434.358.camel@kernel.crashing.org>

On 3/23/2018 9:22 PM, Benjamin Herrenschmidt wrote:
>> Yes, I'm %100 sure. The answer is both writel() and barrier() generates
>> a write barrier instruction. I found this by searching the kernel disassembly
>> for back to back "dsb st" instruction.
> I'm not sure you are correct here. As I wrote below, the implementatoin
> of writel() contains an *explicit" memory barrier which is completely
> different to a barrier() instruction:

OK. I did some directed tests and I'm taking it back. 
barrier() is a compiler reordering statement only.

What got me confused was this sequence:

wmb()
barrier()
writel()

I thought that the second barrier instruction was coming from barrier() but
it was actually coming from writel().

-- 
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply

* Re: DMA Mapping Error in ppc64
From: Benjamin Herrenschmidt @ 2018-03-24  8:19 UTC (permalink / raw)
  To: Jared Bents, Oliver; +Cc: linuxppc-dev
In-Reply-To: <CAM=7fberG6pwy5kz1h=xnNWO4AeSbCR-N-Yw079qMB1tnhSzvQ@mail.gmail.com>

On Fri, 2018-03-23 at 07:41 -0500, Jared Bents wrote:
> Thank you for the advice.  Looks like I get to try to rewrite the ath9k and ath10k drivers to use dma_alloc_coherent() instead of kmemdup() and dev_alloc_skb()

Euh no... dev_alloc_skb() is the right thing to do for receive
packets for a device driver.

The arch should be able to map that for DMA, even if include
bounce buffers via swiotlb.

Cheers,
Ben.

> On Thu, Mar 22, 2018 at 8:19 PM, Oliver <oohall@gmail.com> wrote:
> > On Fri, Mar 23, 2018 at 1:37 AM, Jared Bents
> > <jared.bents@rockwellcollins.com> wrote:
> > > Thank you for the response but unfortunately, it looks like I already
> > > have that and it is being used.  To verify, I commented that out and
> > > got the failure "dma_direct_alloc_coherent: No suitable zone for pfn
> > > 0xe0000".  Below is the code flow for function
> > > ath10k_pci_hif_exchange_bmi_msg which is showing the first dma mapping
> > > error.
> > >
> > > ath10k_pci_hif_exchange_bmi_msg -> dma_map_single ->
> > > dma_map_single_attrs -> swiotlb_map_page -> dma_capable (returns
> > > false)
> > >
> > >
> > > dma_capable is what reports the failure in that flow.
> > >
> > > static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
> > > {
> > > #ifdef CONFIG_SWIOTLB
> > >     struct dev_archdata *sd = &dev->archdata;
> > >
> > >    if (sd->max_direct_dma_addr && addr + size > sd->max_direct_dma_addr)
> > >         return false;
> > > #endif
> > >
> > >     if (!dev->dma_mask)
> > >         return false;
> > >
> > >     return addr + size - 1 <= *dev->dma_mask;
> > > }
> > > Getting the below values:
> > > addr = 1ee376218
> > > size = 4
> > > sd->max_direct_dma_addr = e0000000 which is I believe DMA window size (e0000000)
> > >
> > > when executed sd->max_direct_dma_addr(e0000000) && addr(1ee376218) +
> > > size(4) becomes e0000004 which is > sd->max_direct_dma_addr (e0000000)
> > >
> > >
> > > So even though limit_zone_pfn(ZONE_DMA32, 1UL << (31 - PAGE_SHIFT)) is
> > > being used in arch/powerpc/platforms/85xx/corenet_generic.c,
> > 
> > > kmemdup(req, req_len, GFP_KERNEL) is returning an address that when
> > > sent to dma_map_single(), results in a bad map.
> > 
> > You need to use (GFP_KERNEL | GFP_DMA32) to constrain the allocations
> > to ZONE_DMA32. Without that the kmemdup() will allocate from any zone
> > so you'll probably get an unmappable address.
> > 
> > That said, the driver probably shouldn't be using kmemdup() here.
> > DMA-API.txt pretty explicitly says that drivers should not assume that
> > dma_map_single() will work with arbitrary memory. It should be using
> > dma_alloc_coherent() or a dma pool here.
> > 
> > > - Jared
> > >
> > > On Wed, Mar 21, 2018 at 11:54 PM, Oliver <oohall@gmail.com> wrote:
> > >> On Thu, Mar 22, 2018 at 8:00 AM, Jared Bents
> > >> <jared.bents@rockwellcollins.com> wrote:
> > >>> Hi all,
> > >>>
> > >>> Apologies for the amount of information but we've been debugging this
> > >>> for a while and I wanted to get what we are seeing captured as much as
> > >>> possible.  We are a T1042 processor and have a total 8GB DDR and our
> > >>> kernel version is fsl-sdk-v2.0-1703 (linux v4.1.35) as that is the
> > >>> latest version supplied by NXP.
> > >>>
> > >>> A while ago we ported from 32 bit to 64 bit.  Everything continued to
> > >>> work except the ath10k module we have.  So as a first step, we checked
> > >>> to see if an ath9k module also failed to work and it was also no
> > >>> longer working.  The ath10k is working fine on a 32 bit system but
> > >>> it's not working on 64 bit system as we are getting dma mapping errors
> > >>> when trying to initialize the wifi modules.
> > >>>
> > >>> pci_bus 0002:01: bus scan returning with max=01
> > >>> pci_bus 0002:01: busn_res: [bus 01] end is updated to 01
> > >>> pci_bus 0002:00: bus scan returning with max=01
> > >>> ath10k_pci 0000:01:00.0: unable to get target info from device
> > >>> ath10k_pci 0000:01:00.0: could not get target info (-5)
> > >>> ath10k_pci 0000:01:00.0: could not probe fw (-5)
> > >>> ath10k_pci 0001:01:00.0: Direct firmware load for
> > >>> ath10k/cal-pci-0001:01:00.0.bin failed with error -2
> > >>>
> > >>>
> > >>> First, we have tried the mainline kernel (v4.15)  to see if that would
> > >>> fix the issue, it did not.  So I made a patch for the ath10k driver to
> > >>> restrict to just GFP_DMA areas when allocating memory or creating
> > >>> sk_buffs and have attached it.  The ath10k wifi modules now initialize
> > >>> correctly but when I try to connect them and send traffic, they get a
> > >>> DMA mapping error from the sk_buff that it receives from elsewhere in
> > >>> the kernel.  So while the driver appears to be fixable with the patch,
> > >>> the modules are still unusable due to data being sent to the driver
> > >>> when ath10k_tx is called and it tries to dma map with the provided
> > >>> skb.  Also, according to the ath10k mailing list, GFP_DMA is not
> > >>> supposed to be used in general.  The error below is the same sort of
> > >>> dma mapping error that is seen when initializing the modules without
> > >>> the patch to OR with GFP_DMA.
> > >>>
> > >>> ath10k_pci 0001:01:00.0: failed to transmit packet, dropping: -5
> > >>>
> > >>>
> > >>> We asked on the ath10k mailing list if anyone else is having this
> > >>> problem and no one else seems to have the issue but they are using
> > >>> different architectures (ARM or X86). As a result, it does not seem to
> > >>> be a driver issue to us but something within the PowerPC arch.  So we
> > >>> dug a little deeper to try to find what addresses being mapped are
> > >>> working and what address being mapped are not working.
> > >>>
> > >>> We found that when the virtual address of data pointer (a member of
> > >>> sk_buff) is above ~3.7 GB RAM address range then return address from
> > >>> dma_map_single API is failed to validate in dma_mapping_error
> > >>> function.
> > >>>
> > >>> We also noticed that in a 64bit machine sometimes ping is working and
> > >>> because of the virtual address is under ~3.7GAM RAM address range.  So
> > >>> if we set mem=2048M in the bootargs, the ath10k module works
> > >>> perfectly, however this isn't a real solution since it cuts our
> > >>> available RAM from 8GB to 2GB.
> > >>
> > >> I think there's a known issue with the freescale PCIe root complex
> > >> where it can't DMA beyond the 4GB mark. There's a workaround in
> > >> the form of limit_zone_pfn() which you can use to put the lower 4GB into
> > >> ZONE_DMA32 and allocate from there rather than ZONE_NORMAL.
> > >> For details of how to use it have a look at corenet_gen_setup_arch() in
> > >> arch/powerpc/platforms/85xx/corenet_generic.c
> > >>
> > >> Hope that helps,
> > >> Oliver
> 
> 

^ permalink raw reply

* Re: [PATCH] cxl: disable the lazy approach for irqs in POWERVM environment.
From: Benjamin Herrenschmidt @ 2018-03-24  8:14 UTC (permalink / raw)
  To: christophe lombard, linuxppc-dev, fbarrat, vaibhav,
	andrew.donnellan
In-Reply-To: <fd18ea29-18f9-ae02-4e26-535ee189f739@linux.vnet.ibm.com>

On Fri, 2018-03-23 at 17:17 +0100, christophe lombard wrote:
> Le 23/03/2018 à 03:14, Benjamin Herrenschmidt a écrit :
> > On Thu, 2018-03-22 at 17:37 +0100, Christophe Lombard wrote:
> > > The cxl driver cannot disable the interrupt at the device level and has
> > > to use disable_irq[_nosync] instead.
> > > To avoid the implementation of the lazy optimisation (the interrupt is
> > > marked disabled, but the hardware is left unmasked), we can disable it,
> > > for a particular irq line, by calling
> > > 'irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY)'.
> > 
> > Why do you need that ? What's wrong with the lazy approach ? It makes
> > disable_irq/enable_irq faster...
> > 
> > You shouldn't need that unless your device is generating a *LOT* of
> > irqs while disabled.
> > 
> 
> An issue on POWERVM (CAPI) has been introduced with the following patch
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bf22ff45bed664aefb5c4e43029057a199b7070c 
> 
> The PSL or AFU interrupts are never received by the cxl driver because 
> the interrupts are never unmasked.
> 
> Without this patch (genirq: Avoid unnecessary low level irq function 
> calls), the callback desc->irq_data.chip->irq_unmask(&desc->irq_data); 
> (= ics_rtas_unmask_irq()) is called by default through irq_enable().

I don't see why this would change with the patch... 

> The cxl driver disables the interrupts before attaching the process 
> element and enables the interrupts after that.

How ? Using disable_irq or something else ?

> In the current code, irq_enable() unmasks the irq only if the irq state 
> is IRQD_IRQ_MASKED but it does not.

Sorry I don't really parse your sentence. You mean there's a disconnect
between the "HW" (or pHyp) state of the interrupt and the
IRQD_IRQ_MASKED flag ? That shouldn't happen... if that's the case the
bug is elsewhere, what is causing the disconnect in the first place ?

> Call irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY) allows forcing 
> irq_disable() to update the irq state to IRQD_IRQ_MASKED and by default
> irq_enable() will unmask the irq through ics_rtas_unmask_irq().

Hrm. I don't quite understand. You shouldn't need that, I suspect you
are papering over a different bug but I'm not 100% certain as I don't
completely understand what's happening.

Cheers,
Ben.
> 
> 
> 
> > > Signed-off-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
> > > ---
> > >   drivers/misc/cxl/guest.c | 1 +
> > >   1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/drivers/misc/cxl/guest.c b/drivers/misc/cxl/guest.c
> > > index f58b4b6c..dc476e1 100644
> > > --- a/drivers/misc/cxl/guest.c
> > > +++ b/drivers/misc/cxl/guest.c
> > > @@ -389,6 +389,7 @@ static void disable_afu_irqs(struct cxl_context *ctx)
> > >   		hwirq = ctx->irqs.offset[r];
> > >   		for (i = 0; i < ctx->irqs.range[r]; hwirq++, i++) {
> > >   			virq = irq_find_mapping(NULL, hwirq);
> > > +			irq_set_status_flags(virq, IRQ_DISABLE_UNLAZY);
> > >   			disable_irq(virq);
> > >   		}
> > >   	}

^ permalink raw reply

* "powerpc_debugfs_root" not exist on linux-4.4.123 for powerpc arch.
From: Sombat Tragolgosol @ 2018-03-24  5:55 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 555 bytes --]

My system: ps3
OS: Gentoo linux

Today, I've tried to update my Linux kernel jump from 4.4.100 to 4.4.123.
I'm not sure and perhaps this source tree is still active maintenance. If
not I'm really sorry for my disturbance.

Compile source problems:

1) missing "debugfs.h" on arch/powerpc/include/asm path
2) setup-64.c need to be fixed for adding debugfs.h on above path

I find "github.com/torvalds/linux" adding a year ago, but it is still
missing for current linux-4.4.123 source tree.

For another version higher, I don't try yet.

Thanks in advance.

[-- Attachment #2: Type: text/html, Size: 782 bytes --]

^ permalink raw reply

* Re: RFC on writel and writel_relaxed
From: Benjamin Herrenschmidt @ 2018-03-24  1:23 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Oliver, Sinan Kaya,
	open list:LINUX FOR POWERPC (32-BIT AND 64-BIT),
	linux-rdma@vger.kernel.org
In-Reply-To: <20180323163510.GC13033@ziepe.ca>

On Fri, 2018-03-23 at 10:35 -0600, Jason Gunthorpe wrote:
> On Fri, Mar 23, 2018 at 12:52:02AM +1100, Benjamin Herrenschmidt wrote:
> 
> > > >  - Make writel_relaxed() be a simple store without barriers, and
> > > > readl_relaxed() be "eieio, read, eieio", thus allowing write combining
> > > > to happen between successive writel_relaxed on WC space (no change on
> > > > normal NC space) while maintaining the ordering between relaxed reads
> > > > and writes. The flip side is a (slight) increased overhead of
> > > > readl_relaxed.
> > > 
> > > Are there many drivers that actually do writeX() on WC space?
> > > memory-barriers.txt
> > > pretty much says that all bets are off and no ordering guarantees can be assumed
> > > when using readX/writeX on prefetchable IO memory. It seems sketchy enough to
> > > give me some pause, but maybe it works fine elsewhere.
> > 
> > I don't know whether any does it, but I want to provide a way for a
> > driver to somewhat reliably obtain write combine semantics without
> > having to hand code endian swap and other horrors involved with using
> > __raw_* accessors.
> 
> Many of the drivers in drivers/infiniband work with write combining
> memory.
> 
> The usual pattern is a desire to push 32 or 64 bytes to the WC BAR as
> efficiently as possible, ideally in a single PCI-E TLP.
> 
> A memcpy_to_wc primitive could probably cover these use cases, no need
> to redesign the IO accessors..
> 
> The WC memory is never read, so read/write order is not important to
> any infiniband driver.
> 
> What is very important is keeping the WC behavior isolated within the
> spinlock. WC to the same addresses cannot be permitted in this pattern:
> 
>    writel(addr = 0);
>    mmiowmb();
>    spin_unlock();
>    spin_lock()
>    writel(addr = 0);
> 
> The CPU must always generate two PCI-E TLPs to the device.

On powerpc you'll never get write combining with writel. So that at
least is covered.

> This is a super performance critical operation for most drivers and
> directly impacts network performance.
> 
> Jason

^ permalink raw reply

* Re: RFC on writel and writel_relaxed
From: Benjamin Herrenschmidt @ 2018-03-24  1:22 UTC (permalink / raw)
  To: Sinan Kaya, Oliver
  Cc: linuxppc dev list, linux-rdma@vger.kernel.org, Marc Zyngier,
	Will Deacon
In-Reply-To: <9c7d3d35-ddaf-60ee-1430-19b5c3f66813@codeaurora.org>

On Fri, 2018-03-23 at 09:42 -0400, Sinan Kaya wrote:
> On 3/22/2018 8:16 PM, Benjamin Herrenschmidt wrote:
> > On Thu, 2018-03-22 at 12:51 -0500, Sinan Kaya wrote:
> > > On 3/22/2018 8:52 AM, Benjamin Herrenschmidt wrote:
> > > > > > No, it's not sufficient.
> > > > 
> > > > Just to clarify ... barrier() is just a compiler barrier, it means the
> > > > compiler will generate things in the order they are written. This isn't
> > > > sufficient on archs with an OO memory model, where an actual memory
> > > > barrier instruction needs to be emited.
> > > 
> > > Surprisingly, ARM64 GCC compiler generates a write barrier as
> > > opposed to preventing code reordering.
> > > 
> > > I was curious if this is an ARM only thing or not. 
> > 
> > Are you sure of that ? I thought it's the ARM implementation of writel
> > that had an explicit write barrier in it:
> 
> Yes, I'm %100 sure. The answer is both writel() and barrier() generates
> a write barrier instruction. I found this by searching the kernel disassembly
> for back to back "dsb st" instruction.

I'm not sure you are correct here. As I wrote below, the implementatoin
of writel() contains an *explicit" memory barrier which is completely
different to a barrier() instruction:
> 
> > #define writel(v,c)		({ __iowmb(); writel_relaxed((v),(c)); })
> > 
> > And __iowmb() is 
> > 
> > #define __iowmb()		wmb()
> > 
> > Note, I'm a bit dubious about this in ARM:
> > 
> > #define readl(c)		({ u32 __v = readl_relaxed(c); __iormb(); __v; }
> > 
> > Will, Marc, on powerpc, we put a sync *before* the read in readl etc...
> > 
> > The reasoning was there could be some DMA setup followed by a side
> > effect readl rather than a side effect writel to trigger a DMA. Granted
> > I wouldn't expect modern devices to be that stupid, but I have vague
> > memory of some devices back in the day having that sort of read ops.
> > 
> > In general, I though the model offerred by x86 and thus by Linux
> > readl/writel was full synchronization both before and after the MMIO,
> > vs either other MMIO or all other forms of ops (cachable memory, locks
> > etc...).
> > 
> > Also, can't the above readl_relaxed leak out of a lock ?
> 
> I think you are asking about PPC, correct? 

No, I'm asking about ARM.

> I read somewhere that PPC implementation keeps track of MMIO accesses and
> has an implicit barrier inside the spin_unlock() code for such accesses.
> Isn't this true?

Yes, I wrote that code :-) We keep track of writes and put an implicit
stronger barrier in unlock on ppc64 because drivers never get mmiowb
right.

Cheers,
Ben.

> > 
> > Cheers,
> > Ben.
> > 
> > 
> 
> 

^ permalink raw reply

* Re: [bug?] Access was denied by memory protection keys in execute-only address
From: Ram Pai @ 2018-03-24  0:44 UTC (permalink / raw)
  To: Li Wang
  Cc: Cyril Hrubis, Jan Stancek, Michael Ellerman, ltp, linux-mm,
	linuxppc-dev@lists.ozlabs.org
In-Reply-To: <CAEemH2c4p7FqYs9L9X0SyjUvg5Z3pfwsokurJmzq+=y1h2OwbA@mail.gmail.com>

On Fri, Mar 23, 2018 at 05:27:06PM +0800, Li Wang wrote:
>    On Thu, Mar 22, 2018 at 3:09 PM, Ram Pai <[1]linuxram@us.ibm.com> wrote:
> 
>      On Wed, Mar 21, 2018 at 02:53:00PM +0800, Li Wang wrote:
>      >    On Wed, Mar 21, 2018 at 5:58 AM, Ram Pai
>      <[1][2]linuxram@us.ibm.com> wrote:
>      >    that why not disable the pkey_execute_disable_supported on p8
.snip..

>      machine?
> 
>      It turns out to be a testcase bug.  On Big endian powerpc ABI, function
>      ptrs are basically pointers to function descriptors.  The testcase
>      copies functions which results in function descriptors getting copied.
>      You have to apply the following patch to your test case for it to
>      operate as intended.  Thanks to Michael Ellermen for helping me out.
>      Otherwise I would be scratching my head for ever.
> 
>    ​Thanks for the explanation, I learned something new about this. :)
> 
>    And the worth to say, seems the patch only works on powerpc arch,
>    others(x86_64, etc)
>    that does not works well, so a simple workaround is to isolate the code
>    changes
>    to powerpc system?

yes. this code has to be made applicable to powerpc Big-endian code
only.  The powerpc little-endian code remains unchanged.

RP

^ permalink raw reply

* [PATCH 1/4] ethernet: Use octal not symbolic permissions
From: Joe Perches @ 2018-03-23 22:54 UTC (permalink / raw)
  To: Vince Bridgers, Tom Lendacky, Rasesh Mody, Harish Patil,
	Dept-GELinuxNICDev, Ariel Elior, everest-linux-l2,
	Siva Reddy Kallam, Prashant Sreedharan, Michael Chan,
	Sudarsana Kalluru, Sunil Goutham, Robert Richter,
	Santosh Raspatur, Ganesh Goudar, Casey Leedom,
	Dariusz Marcinkiewicz, Sathya Perla, Ajit Khaparde,
	Sriharsha Basavapatna, Somnath Kotur, Douglas Miller,
	Thomas Falcon, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Jeff Kirsher, Thomas Petazzoni, Mirko Lindner,
	Stephen Hemminger, Tariq Toukan, Jiri Pirko, Ido Schimmel,
	Chris Lee, Manish Chopra, Rahul Verma, Byungho An, Girish K S,
	Vipul Pandya, Solarflare linux maintainers, Edward Cree,
	Bert Kenward, Giuseppe Cavallaro, Alexandre Torgue
  Cc: Jakub Kicinski, netdev, linux-kernel, nios2-dev, linux-arm-kernel,
	linuxppc-dev, intel-wired-lan, linux-rdma, oss-drivers
In-Reply-To: <cover.1521845235.git.joe@perches.com>

Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/ethernet/8390/apne.c                   |   2 +-
 drivers/net/ethernet/8390/lib8390.c                |   2 +-
 drivers/net/ethernet/8390/ne.c                     |   2 +-
 drivers/net/ethernet/8390/ne2k-pci.c               |   2 +-
 drivers/net/ethernet/8390/smc-ultra.c              |   2 +-
 drivers/net/ethernet/8390/stnic.c                  |   2 +-
 drivers/net/ethernet/8390/wd.c                     |   2 +-
 drivers/net/ethernet/altera/altera_tse_main.c      |   6 +-
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c           |  10 +-
 drivers/net/ethernet/amd/xgbe/xgbe-main.c          |   2 +-
 drivers/net/ethernet/broadcom/bnx2.c               |   2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |  12 +--
 drivers/net/ethernet/broadcom/sb1250-mac.c         |  10 +-
 drivers/net/ethernet/broadcom/tg3.c                |   6 +-
 drivers/net/ethernet/brocade/bna/bnad.c            |   2 +-
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c    |  10 +-
 drivers/net/ethernet/cavium/thunder/nicvf_main.c   |   2 +-
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c    |   6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 112 ++++++++++-----------
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c    |  10 +-
 drivers/net/ethernet/ec_bhf.c                      |   2 +-
 drivers/net/ethernet/emulex/benet/be_main.c        |   6 +-
 drivers/net/ethernet/ibm/ehea/ehea_main.c          |   7 +-
 drivers/net/ethernet/ibm/ibmveth.c                 |   2 +-
 drivers/net/ethernet/intel/igb/igb_hwmon.c         |   2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c     |   2 +-
 drivers/net/ethernet/marvell/mvneta.c              |   8 +-
 drivers/net/ethernet/marvell/skge.c                |   2 +-
 drivers/net/ethernet/marvell/sky2.c                |   2 +-
 drivers/net/ethernet/mellanox/mlx4/main.c          |  16 +--
 drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c   |  10 +-
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c   |  32 +++---
 .../net/ethernet/netronome/nfp/nfp_net_debugfs.c   |   6 +-
 .../net/ethernet/qlogic/netxen/netxen_nic_main.c   |  14 +--
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c  |  30 +++---
 drivers/net/ethernet/qualcomm/qca_debug.c          |   2 +-
 drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c    |   4 +-
 drivers/net/ethernet/sfc/mcdi_mon.c                |   2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |  26 ++---
 drivers/net/ethernet/sun/niu.c                     |  10 +-
 40 files changed, 194 insertions(+), 195 deletions(-)

diff --git a/drivers/net/ethernet/8390/apne.c b/drivers/net/ethernet/8390/apne.c
index c56ac9ebc08f..fe6c834c422e 100644
--- a/drivers/net/ethernet/8390/apne.c
+++ b/drivers/net/ethernet/8390/apne.c
@@ -117,7 +117,7 @@ static const char version[] =
 static int apne_owned;	/* signal if card already owned */
 
 static u32 apne_msg_enable;
-module_param_named(msg_enable, apne_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
+module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
 struct net_device * __init apne_probe(int unit)
diff --git a/drivers/net/ethernet/8390/lib8390.c b/drivers/net/ethernet/8390/lib8390.c
index 5d9bbde9fe68..c9c55c9eab9f 100644
--- a/drivers/net/ethernet/8390/lib8390.c
+++ b/drivers/net/ethernet/8390/lib8390.c
@@ -113,7 +113,7 @@ static void __NS8390_init(struct net_device *dev, int startp);
 
 static unsigned version_printed;
 static u32 msg_enable;
-module_param(msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
+module_param(msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
 /*
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c
index 44a084b41bf0..ac99d089ac72 100644
--- a/drivers/net/ethernet/8390/ne.c
+++ b/drivers/net/ethernet/8390/ne.c
@@ -77,7 +77,7 @@ static u32 ne_msg_enable;
 module_param_hw_array(io, int, ioport, NULL, 0);
 module_param_hw_array(irq, int, irq, NULL, 0);
 module_param_array(bad, int, NULL, 0);
-module_param_named(msg_enable, ne_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
+module_param_named(msg_enable, ne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(io, "I/O base address(es),required");
 MODULE_PARM_DESC(irq, "IRQ number(s)");
 MODULE_PARM_DESC(bad, "Accept card(s) with bad signatures");
diff --git a/drivers/net/ethernet/8390/ne2k-pci.c b/drivers/net/ethernet/8390/ne2k-pci.c
index 1bdea746926c..42985a82321a 100644
--- a/drivers/net/ethernet/8390/ne2k-pci.c
+++ b/drivers/net/ethernet/8390/ne2k-pci.c
@@ -76,7 +76,7 @@ MODULE_AUTHOR("Donald Becker / Paul Gortmaker");
 MODULE_DESCRIPTION("PCI NE2000 clone driver");
 MODULE_LICENSE("GPL");
 
-module_param_named(msg_enable, ne2k_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
+module_param_named(msg_enable, ne2k_msg_enable, uint, 0444);
 module_param_array(options, int, NULL, 0);
 module_param_array(full_duplex, int, NULL, 0);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
diff --git a/drivers/net/ethernet/8390/smc-ultra.c b/drivers/net/ethernet/8390/smc-ultra.c
index 4e02f6a23575..3fe3b4dfa7c5 100644
--- a/drivers/net/ethernet/8390/smc-ultra.c
+++ b/drivers/net/ethernet/8390/smc-ultra.c
@@ -563,7 +563,7 @@ static int irq[MAX_ULTRA_CARDS];
 
 module_param_hw_array(io, int, ioport, NULL, 0);
 module_param_hw_array(irq, int, irq, NULL, 0);
-module_param_named(msg_enable, ultra_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
+module_param_named(msg_enable, ultra_msg_enable, uint, 0444);
 MODULE_PARM_DESC(io, "I/O base address(es)");
 MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)");
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
diff --git a/drivers/net/ethernet/8390/stnic.c b/drivers/net/ethernet/8390/stnic.c
index aca957d4e121..1f0670cd3ea3 100644
--- a/drivers/net/ethernet/8390/stnic.c
+++ b/drivers/net/ethernet/8390/stnic.c
@@ -71,7 +71,7 @@ static void stnic_init (struct net_device *dev);
 
 static u32 stnic_msg_enable;
 
-module_param_named(msg_enable, stnic_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
+module_param_named(msg_enable, stnic_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
 /* SH7750 specific read/write io. */
diff --git a/drivers/net/ethernet/8390/wd.c b/drivers/net/ethernet/8390/wd.c
index fb17c2c7e1dd..c834123560f1 100644
--- a/drivers/net/ethernet/8390/wd.c
+++ b/drivers/net/ethernet/8390/wd.c
@@ -507,7 +507,7 @@ module_param_hw_array(io, int, ioport, NULL, 0);
 module_param_hw_array(irq, int, irq, NULL, 0);
 module_param_hw_array(mem, int, iomem, NULL, 0);
 module_param_hw_array(mem_end, int, iomem, NULL, 0);
-module_param_named(msg_enable, wd_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
+module_param_named(msg_enable, wd_msg_enable, uint, 0444);
 MODULE_PARM_DESC(io, "I/O base address(es)");
 MODULE_PARM_DESC(irq, "IRQ number(s) (ignored for PureData boards)");
 MODULE_PARM_DESC(mem, "memory base address(es)(ignored for PureData boards)");
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index 527908c7e384..baca8f704a45 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -56,7 +56,7 @@
 static atomic_t instance_count = ATOMIC_INIT(~0);
 /* Module parameters */
 static int debug = -1;
-module_param(debug, int, S_IRUGO | S_IWUSR);
+module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Message Level (-1: default, 0: no output, 16: all)");
 
 static const u32 default_msg_level = (NETIF_MSG_DRV | NETIF_MSG_PROBE |
@@ -65,12 +65,12 @@ static const u32 default_msg_level = (NETIF_MSG_DRV | NETIF_MSG_PROBE |
 
 #define RX_DESCRIPTORS 64
 static int dma_rx_num = RX_DESCRIPTORS;
-module_param(dma_rx_num, int, S_IRUGO | S_IWUSR);
+module_param(dma_rx_num, int, 0644);
 MODULE_PARM_DESC(dma_rx_num, "Number of descriptors in the RX list");
 
 #define TX_DESCRIPTORS 64
 static int dma_tx_num = TX_DESCRIPTORS;
-module_param(dma_tx_num, int, S_IRUGO | S_IWUSR);
+module_param(dma_tx_num, int, 0644);
 MODULE_PARM_DESC(dma_tx_num, "Number of descriptors in the TX list");
 
 
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 100adee778df..7c204f05b418 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -137,21 +137,21 @@ static unsigned int ecc_ded_period = 600;
 
 #ifdef CONFIG_AMD_XGBE_HAVE_ECC
 /* Only expose the ECC parameters if supported */
-module_param(ecc_sec_info_threshold, uint, S_IWUSR | S_IRUGO);
+module_param(ecc_sec_info_threshold, uint, 0644);
 MODULE_PARM_DESC(ecc_sec_info_threshold,
 		 " ECC corrected error informational threshold setting");
 
-module_param(ecc_sec_warn_threshold, uint, S_IWUSR | S_IRUGO);
+module_param(ecc_sec_warn_threshold, uint, 0644);
 MODULE_PARM_DESC(ecc_sec_warn_threshold,
 		 " ECC corrected error warning threshold setting");
 
-module_param(ecc_sec_period, uint, S_IWUSR | S_IRUGO);
+module_param(ecc_sec_period, uint, 0644);
 MODULE_PARM_DESC(ecc_sec_period, " ECC corrected error period (in seconds)");
 
-module_param(ecc_ded_threshold, uint, S_IWUSR | S_IRUGO);
+module_param(ecc_ded_threshold, uint, 0644);
 MODULE_PARM_DESC(ecc_ded_threshold, " ECC detected error threshold setting");
 
-module_param(ecc_ded_period, uint, S_IWUSR | S_IRUGO);
+module_param(ecc_ded_period, uint, 0644);
 MODULE_PARM_DESC(ecc_ded_period, " ECC detected error period (in seconds)");
 #endif
 
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
index d91fa595be98..795e556d4a3f 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
@@ -131,7 +131,7 @@ MODULE_VERSION(XGBE_DRV_VERSION);
 MODULE_DESCRIPTION(XGBE_DRV_DESC);
 
 static int debug = -1;
-module_param(debug, int, S_IWUSR | S_IRUGO);
+module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, " Network interface message level setting");
 
 static const u32 default_msg_level = (NETIF_MSG_LINK | NETIF_MSG_IFDOWN |
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index 5e34b34f7740..9ffc4a8c5fc7 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -87,7 +87,7 @@ MODULE_FIRMWARE(FW_RV2P_FILE_09_Ax);
 
 static int disable_msi = 0;
 
-module_param(disable_msi, int, S_IRUGO);
+module_param(disable_msi, int, 0444);
 MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
 
 typedef enum {
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index b8388e93520a..fd97250d6371 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -97,29 +97,29 @@ MODULE_FIRMWARE(FW_FILE_NAME_E1H);
 MODULE_FIRMWARE(FW_FILE_NAME_E2);
 
 int bnx2x_num_queues;
-module_param_named(num_queues, bnx2x_num_queues, int, S_IRUGO);
+module_param_named(num_queues, bnx2x_num_queues, int, 0444);
 MODULE_PARM_DESC(num_queues,
 		 " Set number of queues (default is as a number of CPUs)");
 
 static int disable_tpa;
-module_param(disable_tpa, int, S_IRUGO);
+module_param(disable_tpa, int, 0444);
 MODULE_PARM_DESC(disable_tpa, " Disable the TPA (LRO) feature");
 
 static int int_mode;
-module_param(int_mode, int, S_IRUGO);
+module_param(int_mode, int, 0444);
 MODULE_PARM_DESC(int_mode, " Force interrupt mode other than MSI-X "
 				"(1 INT#x; 2 MSI)");
 
 static int dropless_fc;
-module_param(dropless_fc, int, S_IRUGO);
+module_param(dropless_fc, int, 0444);
 MODULE_PARM_DESC(dropless_fc, " Pause on exhausted host ring");
 
 static int mrrs = -1;
-module_param(mrrs, int, S_IRUGO);
+module_param(mrrs, int, 0444);
 MODULE_PARM_DESC(mrrs, " Force Max Read Req Size (0..3) (for debug)");
 
 static int debug;
-module_param(debug, int, S_IRUGO);
+module_param(debug, int, 0444);
 MODULE_PARM_DESC(debug, " Default debug msglevel");
 
 static struct workqueue_struct *bnx2x_wq;
diff --git a/drivers/net/ethernet/broadcom/sb1250-mac.c b/drivers/net/ethernet/broadcom/sb1250-mac.c
index ecdef42f0ae6..ef4a0c326736 100644
--- a/drivers/net/ethernet/broadcom/sb1250-mac.c
+++ b/drivers/net/ethernet/broadcom/sb1250-mac.c
@@ -63,24 +63,24 @@ MODULE_DESCRIPTION("Broadcom SiByte SOC GB Ethernet driver");
 
 /* 1 normal messages, 0 quiet .. 7 verbose. */
 static int debug = 1;
-module_param(debug, int, S_IRUGO);
+module_param(debug, int, 0444);
 MODULE_PARM_DESC(debug, "Debug messages");
 
 #ifdef CONFIG_SBMAC_COALESCE
 static int int_pktcnt_tx = 255;
-module_param(int_pktcnt_tx, int, S_IRUGO);
+module_param(int_pktcnt_tx, int, 0444);
 MODULE_PARM_DESC(int_pktcnt_tx, "TX packet count");
 
 static int int_timeout_tx = 255;
-module_param(int_timeout_tx, int, S_IRUGO);
+module_param(int_timeout_tx, int, 0444);
 MODULE_PARM_DESC(int_timeout_tx, "TX timeout value");
 
 static int int_pktcnt_rx = 64;
-module_param(int_pktcnt_rx, int, S_IRUGO);
+module_param(int_pktcnt_rx, int, 0444);
 MODULE_PARM_DESC(int_pktcnt_rx, "RX packet count");
 
 static int int_timeout_rx = 64;
-module_param(int_timeout_rx, int, S_IRUGO);
+module_param(int_timeout_rx, int, 0444);
 MODULE_PARM_DESC(int_timeout_rx, "RX timeout value");
 #endif
 
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index f2593978ae75..08bbb639be1a 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -10799,11 +10799,11 @@ static ssize_t tg3_show_temp(struct device *dev,
 }
 
 
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, tg3_show_temp, NULL,
+static SENSOR_DEVICE_ATTR(temp1_input, 0444, tg3_show_temp, NULL,
 			  TG3_TEMP_SENSOR_OFFSET);
-static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, tg3_show_temp, NULL,
+static SENSOR_DEVICE_ATTR(temp1_crit, 0444, tg3_show_temp, NULL,
 			  TG3_TEMP_CAUTION_OFFSET);
-static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, tg3_show_temp, NULL,
+static SENSOR_DEVICE_ATTR(temp1_max, 0444, tg3_show_temp, NULL,
 			  TG3_TEMP_MAX_OFFSET);
 
 static struct attribute *tg3_attrs[] = {
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
index a843076597ec..69cc3e0119d6 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -46,7 +46,7 @@ module_param(bnad_ioc_auto_recover, uint, 0444);
 MODULE_PARM_DESC(bnad_ioc_auto_recover, "Enable / Disable auto recovery");
 
 static uint bna_debugfs_enable = 1;
-module_param(bna_debugfs_enable, uint, S_IRUGO | S_IWUSR);
+module_param(bna_debugfs_enable, uint, 0644);
 MODULE_PARM_DESC(bna_debugfs_enable, "Enables debugfs feature, default=1,"
 		 " Range[false:0|true:1]");
 
diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
index cebfe3bd086e..933799be0471 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -486,11 +486,11 @@ struct bnad_debugfs_entry {
 };
 
 static const struct bnad_debugfs_entry bnad_debugfs_files[] = {
-	{ "fwtrc",  S_IFREG|S_IRUGO, &bnad_debugfs_op_fwtrc, },
-	{ "fwsave", S_IFREG|S_IRUGO, &bnad_debugfs_op_fwsave, },
-	{ "regrd",  S_IFREG|S_IRUGO|S_IWUSR, &bnad_debugfs_op_regrd, },
-	{ "regwr",  S_IFREG|S_IWUSR, &bnad_debugfs_op_regwr, },
-	{ "drvinfo", S_IFREG|S_IRUGO, &bnad_debugfs_op_drvinfo, },
+	{ "fwtrc",  S_IFREG | 0444, &bnad_debugfs_op_fwtrc, },
+	{ "fwsave", S_IFREG | 0444, &bnad_debugfs_op_fwsave, },
+	{ "regrd",  S_IFREG | 0644, &bnad_debugfs_op_regrd, },
+	{ "regwr",  S_IFREG | 0200, &bnad_debugfs_op_regwr, },
+	{ "drvinfo", S_IFREG | 0444, &bnad_debugfs_op_drvinfo, },
 };
 
 static struct dentry *bna_debugfs_root;
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 7d9c5ffbd041..73fe3881414b 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -63,7 +63,7 @@ module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Debug message level bitmap");
 
 static int cpi_alg = CPI_ALG_NONE;
-module_param(cpi_alg, int, S_IRUGO);
+module_param(cpi_alg, int, 0444);
 MODULE_PARM_DESC(cpi_alg,
 		 "PFC algorithm (0=none, 1=VLAN, 2=VLAN16, 3=IP Diffserv)");
 
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index 185fe8df7628..2edfdbdaae48 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -776,11 +776,11 @@ static ssize_t store_nservers(struct device *d, struct device_attribute *attr,
 
 #define CXGB3_ATTR_R(name, val_expr) \
 CXGB3_SHOW(name, val_expr) \
-static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
+static DEVICE_ATTR(name, 0444, show_##name, NULL)
 
 #define CXGB3_ATTR_RW(name, val_expr, store_method) \
 CXGB3_SHOW(name, val_expr) \
-static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_##name, store_method)
+static DEVICE_ATTR(name, 0644, show_##name, store_method)
 
 CXGB3_ATTR_R(cam_size, t3_mc5_size(&adap->mc5));
 CXGB3_ATTR_RW(nfilters, adap->params.mc5.nfilters, store_nfilters);
@@ -859,7 +859,7 @@ static ssize_t store_##name(struct device *d, struct device_attribute *attr, \
 { \
 	return tm_attr_store(d, buf, len, sched); \
 } \
-static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_##name, store_##name)
+static DEVICE_ATTR(name, 0644, show_##name, store_##name)
 
 TM_ATTR(sched0, 0);
 TM_ATTR(sched1, 1);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index de2ba86eccfd..251d5bdc972f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -2752,7 +2752,7 @@ DEFINE_SIMPLE_DEBUGFS_FILE(tid_info);
 static void add_debugfs_mem(struct adapter *adap, const char *name,
 			    unsigned int idx, unsigned int size_mb)
 {
-	debugfs_create_file_size(name, S_IRUSR, adap->debugfs_root,
+	debugfs_create_file_size(name, 0400, adap->debugfs_root,
 				 (void *)adap + idx, &mem_debugfs_fops,
 				 size_mb << 20);
 }
@@ -2947,65 +2947,65 @@ int t4_setup_debugfs(struct adapter *adap)
 	struct dentry *de;
 
 	static struct t4_debugfs_entry t4_debugfs_files[] = {
-		{ "cim_la", &cim_la_fops, S_IRUSR, 0 },
-		{ "cim_pif_la", &cim_pif_la_fops, S_IRUSR, 0 },
-		{ "cim_ma_la", &cim_ma_la_fops, S_IRUSR, 0 },
-		{ "cim_qcfg", &cim_qcfg_fops, S_IRUSR, 0 },
-		{ "clk", &clk_debugfs_fops, S_IRUSR, 0 },
-		{ "devlog", &devlog_fops, S_IRUSR, 0 },
-		{ "mboxlog", &mboxlog_fops, S_IRUSR, 0 },
-		{ "mbox0", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 0 },
-		{ "mbox1", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 1 },
-		{ "mbox2", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 2 },
-		{ "mbox3", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 3 },
-		{ "mbox4", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 4 },
-		{ "mbox5", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 5 },
-		{ "mbox6", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 6 },
-		{ "mbox7", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 7 },
-		{ "trace0", &mps_trc_debugfs_fops, S_IRUSR | S_IWUSR, 0 },
-		{ "trace1", &mps_trc_debugfs_fops, S_IRUSR | S_IWUSR, 1 },
-		{ "trace2", &mps_trc_debugfs_fops, S_IRUSR | S_IWUSR, 2 },
-		{ "trace3", &mps_trc_debugfs_fops, S_IRUSR | S_IWUSR, 3 },
-		{ "l2t", &t4_l2t_fops, S_IRUSR, 0},
-		{ "mps_tcam", &mps_tcam_debugfs_fops, S_IRUSR, 0 },
-		{ "rss", &rss_debugfs_fops, S_IRUSR, 0 },
-		{ "rss_config", &rss_config_debugfs_fops, S_IRUSR, 0 },
-		{ "rss_key", &rss_key_debugfs_fops, S_IRUSR, 0 },
-		{ "rss_pf_config", &rss_pf_config_debugfs_fops, S_IRUSR, 0 },
-		{ "rss_vf_config", &rss_vf_config_debugfs_fops, S_IRUSR, 0 },
-		{ "sge_qinfo", &sge_qinfo_debugfs_fops, S_IRUSR, 0 },
-		{ "ibq_tp0",  &cim_ibq_fops, S_IRUSR, 0 },
-		{ "ibq_tp1",  &cim_ibq_fops, S_IRUSR, 1 },
-		{ "ibq_ulp",  &cim_ibq_fops, S_IRUSR, 2 },
-		{ "ibq_sge0", &cim_ibq_fops, S_IRUSR, 3 },
-		{ "ibq_sge1", &cim_ibq_fops, S_IRUSR, 4 },
-		{ "ibq_ncsi", &cim_ibq_fops, S_IRUSR, 5 },
-		{ "obq_ulp0", &cim_obq_fops, S_IRUSR, 0 },
-		{ "obq_ulp1", &cim_obq_fops, S_IRUSR, 1 },
-		{ "obq_ulp2", &cim_obq_fops, S_IRUSR, 2 },
-		{ "obq_ulp3", &cim_obq_fops, S_IRUSR, 3 },
-		{ "obq_sge",  &cim_obq_fops, S_IRUSR, 4 },
-		{ "obq_ncsi", &cim_obq_fops, S_IRUSR, 5 },
-		{ "tp_la", &tp_la_fops, S_IRUSR, 0 },
-		{ "ulprx_la", &ulprx_la_fops, S_IRUSR, 0 },
-		{ "sensors", &sensors_debugfs_fops, S_IRUSR, 0 },
-		{ "pm_stats", &pm_stats_debugfs_fops, S_IRUSR, 0 },
-		{ "tx_rate", &tx_rate_debugfs_fops, S_IRUSR, 0 },
-		{ "cctrl", &cctrl_tbl_debugfs_fops, S_IRUSR, 0 },
+		{ "cim_la", &cim_la_fops, 0400, 0 },
+		{ "cim_pif_la", &cim_pif_la_fops, 0400, 0 },
+		{ "cim_ma_la", &cim_ma_la_fops, 0400, 0 },
+		{ "cim_qcfg", &cim_qcfg_fops, 0400, 0 },
+		{ "clk", &clk_debugfs_fops, 0400, 0 },
+		{ "devlog", &devlog_fops, 0400, 0 },
+		{ "mboxlog", &mboxlog_fops, 0400, 0 },
+		{ "mbox0", &mbox_debugfs_fops, 0600, 0 },
+		{ "mbox1", &mbox_debugfs_fops, 0600, 1 },
+		{ "mbox2", &mbox_debugfs_fops, 0600, 2 },
+		{ "mbox3", &mbox_debugfs_fops, 0600, 3 },
+		{ "mbox4", &mbox_debugfs_fops, 0600, 4 },
+		{ "mbox5", &mbox_debugfs_fops, 0600, 5 },
+		{ "mbox6", &mbox_debugfs_fops, 0600, 6 },
+		{ "mbox7", &mbox_debugfs_fops, 0600, 7 },
+		{ "trace0", &mps_trc_debugfs_fops, 0600, 0 },
+		{ "trace1", &mps_trc_debugfs_fops, 0600, 1 },
+		{ "trace2", &mps_trc_debugfs_fops, 0600, 2 },
+		{ "trace3", &mps_trc_debugfs_fops, 0600, 3 },
+		{ "l2t", &t4_l2t_fops, 0400, 0},
+		{ "mps_tcam", &mps_tcam_debugfs_fops, 0400, 0 },
+		{ "rss", &rss_debugfs_fops, 0400, 0 },
+		{ "rss_config", &rss_config_debugfs_fops, 0400, 0 },
+		{ "rss_key", &rss_key_debugfs_fops, 0400, 0 },
+		{ "rss_pf_config", &rss_pf_config_debugfs_fops, 0400, 0 },
+		{ "rss_vf_config", &rss_vf_config_debugfs_fops, 0400, 0 },
+		{ "sge_qinfo", &sge_qinfo_debugfs_fops, 0400, 0 },
+		{ "ibq_tp0",  &cim_ibq_fops, 0400, 0 },
+		{ "ibq_tp1",  &cim_ibq_fops, 0400, 1 },
+		{ "ibq_ulp",  &cim_ibq_fops, 0400, 2 },
+		{ "ibq_sge0", &cim_ibq_fops, 0400, 3 },
+		{ "ibq_sge1", &cim_ibq_fops, 0400, 4 },
+		{ "ibq_ncsi", &cim_ibq_fops, 0400, 5 },
+		{ "obq_ulp0", &cim_obq_fops, 0400, 0 },
+		{ "obq_ulp1", &cim_obq_fops, 0400, 1 },
+		{ "obq_ulp2", &cim_obq_fops, 0400, 2 },
+		{ "obq_ulp3", &cim_obq_fops, 0400, 3 },
+		{ "obq_sge",  &cim_obq_fops, 0400, 4 },
+		{ "obq_ncsi", &cim_obq_fops, 0400, 5 },
+		{ "tp_la", &tp_la_fops, 0400, 0 },
+		{ "ulprx_la", &ulprx_la_fops, 0400, 0 },
+		{ "sensors", &sensors_debugfs_fops, 0400, 0 },
+		{ "pm_stats", &pm_stats_debugfs_fops, 0400, 0 },
+		{ "tx_rate", &tx_rate_debugfs_fops, 0400, 0 },
+		{ "cctrl", &cctrl_tbl_debugfs_fops, 0400, 0 },
 #if IS_ENABLED(CONFIG_IPV6)
-		{ "clip_tbl", &clip_tbl_debugfs_fops, S_IRUSR, 0 },
+		{ "clip_tbl", &clip_tbl_debugfs_fops, 0400, 0 },
 #endif
-		{ "tids", &tid_info_debugfs_fops, S_IRUSR, 0},
-		{ "blocked_fl", &blocked_fl_fops, S_IRUSR | S_IWUSR, 0 },
-		{ "meminfo", &meminfo_fops, S_IRUSR, 0 },
-		{ "crypto", &chcr_stats_debugfs_fops, S_IRUSR, 0 },
+		{ "tids", &tid_info_debugfs_fops, 0400, 0},
+		{ "blocked_fl", &blocked_fl_fops, 0600, 0 },
+		{ "meminfo", &meminfo_fops, 0400, 0 },
+		{ "crypto", &chcr_stats_debugfs_fops, 0400, 0 },
 	};
 
 	/* Debug FS nodes common to all T5 and later adapters.
 	 */
 	static struct t4_debugfs_entry t5_debugfs_files[] = {
-		{ "obq_sge_rx_q0", &cim_obq_fops, S_IRUSR, 6 },
-		{ "obq_sge_rx_q1", &cim_obq_fops, S_IRUSR, 7 },
+		{ "obq_sge_rx_q0", &cim_obq_fops, 0400, 6 },
+		{ "obq_sge_rx_q1", &cim_obq_fops, 0400, 7 },
 	};
 
 	add_debugfs_files(adap,
@@ -3050,11 +3050,11 @@ int t4_setup_debugfs(struct adapter *adap)
 		}
 	}
 
-	de = debugfs_create_file_size("flash", S_IRUSR, adap->debugfs_root, adap,
+	de = debugfs_create_file_size("flash", 0400, adap->debugfs_root, adap,
 				      &flash_debugfs_fops, adap->params.sf_size);
-	debugfs_create_bool("use_backdoor", S_IWUSR | S_IRUSR,
+	debugfs_create_bool("use_backdoor", 0600,
 			    adap->debugfs_root, &adap->use_bd);
-	debugfs_create_bool("trace_rss", S_IWUSR | S_IRUSR,
+	debugfs_create_bool("trace_rss", 0600,
 			    adap->debugfs_root, &adap->trace_rss);
 
 	return 0;
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index 7bd8497fd9be..9a81b52307a9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -2402,11 +2402,11 @@ struct cxgb4vf_debugfs_entry {
 };
 
 static struct cxgb4vf_debugfs_entry debugfs_files[] = {
-	{ "mboxlog",    S_IRUGO, &mboxlog_fops },
-	{ "sge_qinfo",  S_IRUGO, &sge_qinfo_debugfs_fops },
-	{ "sge_qstats", S_IRUGO, &sge_qstats_proc_fops },
-	{ "resources",  S_IRUGO, &resources_proc_fops },
-	{ "interfaces", S_IRUGO, &interfaces_proc_fops },
+	{ "mboxlog",    0444, &mboxlog_fops },
+	{ "sge_qinfo",  0444, &sge_qinfo_debugfs_fops },
+	{ "sge_qstats", 0444, &sge_qstats_proc_fops },
+	{ "resources",  0444, &resources_proc_fops },
+	{ "interfaces", 0444, &interfaces_proc_fops },
 };
 
 /*
diff --git a/drivers/net/ethernet/ec_bhf.c b/drivers/net/ethernet/ec_bhf.c
index 1b79a6defd56..d71cba0842c5 100644
--- a/drivers/net/ethernet/ec_bhf.c
+++ b/drivers/net/ethernet/ec_bhf.c
@@ -602,7 +602,7 @@ static struct pci_driver pci_driver = {
 };
 module_pci_driver(pci_driver);
 
-module_param(polling_frequency, long, S_IRUGO);
+module_param(polling_frequency, long, 0444);
 MODULE_PARM_DESC(polling_frequency, "Polling timer frequency in ns");
 
 MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 5774fb6f8aa0..c697e79e491e 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -34,11 +34,11 @@ MODULE_LICENSE("GPL");
  * Use sysfs method to enable/disable VFs.
  */
 static unsigned int num_vfs;
-module_param(num_vfs, uint, S_IRUGO);
+module_param(num_vfs, uint, 0444);
 MODULE_PARM_DESC(num_vfs, "Number of PCI VFs to initialize");
 
 static ushort rx_frag_size = 2048;
-module_param(rx_frag_size, ushort, S_IRUGO);
+module_param(rx_frag_size, ushort, 0444);
 MODULE_PARM_DESC(rx_frag_size, "Size of a fragment that holds rcvd data.");
 
 /* Per-module error detection/recovery workq shared across all functions.
@@ -5788,7 +5788,7 @@ static ssize_t be_hwmon_show_temp(struct device *dev,
 			       adapter->hwmon_info.be_on_die_temp * 1000);
 }
 
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO,
+static SENSOR_DEVICE_ATTR(temp1_input, 0444,
 			  be_hwmon_show_temp, NULL, 1);
 
 static struct attribute *be_hwmon_attrs[] = {
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c
index 4878b7169e0f..ba580bfae512 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
+++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
@@ -2903,8 +2903,7 @@ static ssize_t ehea_show_port_id(struct device *dev,
 	return sprintf(buf, "%d", port->logical_port_id);
 }
 
-static DEVICE_ATTR(log_port_id, S_IRUSR | S_IRGRP | S_IROTH, ehea_show_port_id,
-		   NULL);
+static DEVICE_ATTR(log_port_id, 0444, ehea_show_port_id, NULL);
 
 static void logical_port_release(struct device *dev)
 {
@@ -3235,8 +3234,8 @@ static ssize_t ehea_remove_port(struct device *dev,
 	return (ssize_t) count;
 }
 
-static DEVICE_ATTR(probe_port, S_IWUSR, NULL, ehea_probe_port);
-static DEVICE_ATTR(remove_port, S_IWUSR, NULL, ehea_remove_port);
+static DEVICE_ATTR(probe_port, 0200, NULL, ehea_probe_port);
+static DEVICE_ATTR(remove_port, 0200, NULL, ehea_remove_port);
 
 static int ehea_create_device_sysfs(struct platform_device *dev)
 {
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index f210398200ec..c1b51edaaf62 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -82,7 +82,7 @@ module_param(rx_flush, uint, 0644);
 MODULE_PARM_DESC(rx_flush, "Flush receive buffers before use");
 
 static bool old_large_send __read_mostly;
-module_param(old_large_send, bool, S_IRUGO);
+module_param(old_large_send, bool, 0444);
 MODULE_PARM_DESC(old_large_send,
 	"Use old large send method on firmware that supports the new method");
 
diff --git a/drivers/net/ethernet/intel/igb/igb_hwmon.c b/drivers/net/ethernet/intel/igb/igb_hwmon.c
index 44b6a68f1af7..d87d27fb9e6e 100644
--- a/drivers/net/ethernet/intel/igb/igb_hwmon.c
+++ b/drivers/net/ethernet/intel/igb/igb_hwmon.c
@@ -147,7 +147,7 @@ static int igb_add_hwmon_attr(struct igb_adapter *adapter,
 		&adapter->hw.mac.thermal_sensor_data.sensor[offset];
 	igb_attr->hw = &adapter->hw;
 	igb_attr->dev_attr.store = NULL;
-	igb_attr->dev_attr.attr.mode = S_IRUGO;
+	igb_attr->dev_attr.attr.mode = 0444;
 	igb_attr->dev_attr.attr.name = igb_attr->name;
 	sysfs_attr_init(&igb_attr->dev_attr.attr);
 
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c
index ef6df3d6437e..24766e125592 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c
@@ -146,7 +146,7 @@ static int ixgbe_add_hwmon_attr(struct ixgbe_adapter *adapter,
 		&adapter->hw.mac.thermal_sensor_data.sensor[offset];
 	ixgbe_attr->hw = &adapter->hw;
 	ixgbe_attr->dev_attr.store = NULL;
-	ixgbe_attr->dev_attr.attr.mode = S_IRUGO;
+	ixgbe_attr->dev_attr.attr.mode = 0444;
 	ixgbe_attr->dev_attr.attr.name = ixgbe_attr->name;
 	sysfs_attr_init(&ixgbe_attr->dev_attr.attr);
 
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 25e9a551cc8c..eaa4bb80f1c9 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -4655,8 +4655,8 @@ MODULE_DESCRIPTION("Marvell NETA Ethernet Driver - www.marvell.com");
 MODULE_AUTHOR("Rami Rosen <rosenr@marvell.com>, Thomas Petazzoni <thomas.petazzoni@free-electrons.com>");
 MODULE_LICENSE("GPL");
 
-module_param(rxq_number, int, S_IRUGO);
-module_param(txq_number, int, S_IRUGO);
+module_param(rxq_number, int, 0444);
+module_param(txq_number, int, 0444);
 
-module_param(rxq_def, int, S_IRUGO);
-module_param(rx_copybreak, int, S_IRUGO | S_IWUSR);
+module_param(rxq_def, int, 0444);
+module_param(rx_copybreak, int, 0644);
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index 31efc47c847e..9c08c3650c02 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -3783,7 +3783,7 @@ static int skge_device_event(struct notifier_block *unused,
 		break;
 
 	case NETDEV_UP:
-		d = debugfs_create_file(dev->name, S_IRUGO,
+		d = debugfs_create_file(dev->name, 0444,
 					skge_debug, dev,
 					&skge_debug_fops);
 		if (!d || IS_ERR(d))
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 9fe85300e7b6..9b77db7c13d0 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4667,7 +4667,7 @@ static int sky2_device_event(struct notifier_block *unused,
 		break;
 
 	case NETDEV_UP:
-		sky2->debugfs = debugfs_create_file(dev->name, S_IRUGO,
+		sky2->debugfs = debugfs_create_file(dev->name, 0444,
 						    sky2_debug, dev,
 						    &sky2_debug_fops);
 		if (IS_ERR(sky2->debugfs))
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 958619ff24ae..5af50191c181 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2994,10 +2994,10 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
 
 	sprintf(info->dev_name, "mlx4_port%d", port);
 	info->port_attr.attr.name = info->dev_name;
-	if (mlx4_is_mfunc(dev))
-		info->port_attr.attr.mode = S_IRUGO;
-	else {
-		info->port_attr.attr.mode = S_IRUGO | S_IWUSR;
+	if (mlx4_is_mfunc(dev)) {
+		info->port_attr.attr.mode = 0444;
+	} else {
+		info->port_attr.attr.mode = 0644;
 		info->port_attr.store     = set_port_type;
 	}
 	info->port_attr.show      = show_port_type;
@@ -3012,10 +3012,10 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
 
 	sprintf(info->dev_mtu_name, "mlx4_port%d_mtu", port);
 	info->port_mtu_attr.attr.name = info->dev_mtu_name;
-	if (mlx4_is_mfunc(dev))
-		info->port_mtu_attr.attr.mode = S_IRUGO;
-	else {
-		info->port_mtu_attr.attr.mode = S_IRUGO | S_IWUSR;
+	if (mlx4_is_mfunc(dev)) {
+		info->port_mtu_attr.attr.mode = 0444;
+	} else {
+		info->port_mtu_attr.attr.mode = 0644;
 		info->port_mtu_attr.store     = set_port_ib_mtu;
 	}
 	info->port_mtu_attr.show      = show_port_ib_mtu;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
index ab710e37af99..84185f8dfbae 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
@@ -218,32 +218,32 @@ static void mlxsw_hwmon_attr_add(struct mlxsw_hwmon *mlxsw_hwmon,
 	switch (attr_type) {
 	case MLXSW_HWMON_ATTR_TYPE_TEMP:
 		mlxsw_hwmon_attr->dev_attr.show = mlxsw_hwmon_temp_show;
-		mlxsw_hwmon_attr->dev_attr.attr.mode = S_IRUGO;
+		mlxsw_hwmon_attr->dev_attr.attr.mode = 0444;
 		snprintf(mlxsw_hwmon_attr->name, sizeof(mlxsw_hwmon_attr->name),
 			 "temp%u_input", num + 1);
 		break;
 	case MLXSW_HWMON_ATTR_TYPE_TEMP_MAX:
 		mlxsw_hwmon_attr->dev_attr.show = mlxsw_hwmon_temp_max_show;
-		mlxsw_hwmon_attr->dev_attr.attr.mode = S_IRUGO;
+		mlxsw_hwmon_attr->dev_attr.attr.mode = 0444;
 		snprintf(mlxsw_hwmon_attr->name, sizeof(mlxsw_hwmon_attr->name),
 			 "temp%u_highest", num + 1);
 		break;
 	case MLXSW_HWMON_ATTR_TYPE_TEMP_RST:
 		mlxsw_hwmon_attr->dev_attr.store = mlxsw_hwmon_temp_rst_store;
-		mlxsw_hwmon_attr->dev_attr.attr.mode = S_IWUSR;
+		mlxsw_hwmon_attr->dev_attr.attr.mode = 0200;
 		snprintf(mlxsw_hwmon_attr->name, sizeof(mlxsw_hwmon_attr->name),
 			 "temp%u_reset_history", num + 1);
 		break;
 	case MLXSW_HWMON_ATTR_TYPE_FAN_RPM:
 		mlxsw_hwmon_attr->dev_attr.show = mlxsw_hwmon_fan_rpm_show;
-		mlxsw_hwmon_attr->dev_attr.attr.mode = S_IRUGO;
+		mlxsw_hwmon_attr->dev_attr.attr.mode = 0444;
 		snprintf(mlxsw_hwmon_attr->name, sizeof(mlxsw_hwmon_attr->name),
 			 "fan%u_input", num + 1);
 		break;
 	case MLXSW_HWMON_ATTR_TYPE_PWM:
 		mlxsw_hwmon_attr->dev_attr.show = mlxsw_hwmon_pwm_show;
 		mlxsw_hwmon_attr->dev_attr.store = mlxsw_hwmon_pwm_store;
-		mlxsw_hwmon_attr->dev_attr.attr.mode = S_IWUSR | S_IRUGO;
+		mlxsw_hwmon_attr->dev_attr.attr.mode = 0644;
 		snprintf(mlxsw_hwmon_attr->name, sizeof(mlxsw_hwmon_attr->name),
 			 "pwm%u", num + 1);
 		break;
diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
index 2521c8c40015..b2d2ec8c11e2 100644
--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
@@ -266,7 +266,7 @@ MODULE_FIRMWARE("myri10ge_rss_eth_z8e.dat");
 
 /* Careful: must be accessed under kernel_param_lock() */
 static char *myri10ge_fw_name = NULL;
-module_param(myri10ge_fw_name, charp, S_IRUGO | S_IWUSR);
+module_param(myri10ge_fw_name, charp, 0644);
 MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name");
 
 #define MYRI10GE_MAX_BOARDS 8
@@ -277,49 +277,49 @@ module_param_array_named(myri10ge_fw_names, myri10ge_fw_names, charp, NULL,
 MODULE_PARM_DESC(myri10ge_fw_names, "Firmware image names per board");
 
 static int myri10ge_ecrc_enable = 1;
-module_param(myri10ge_ecrc_enable, int, S_IRUGO);
+module_param(myri10ge_ecrc_enable, int, 0444);
 MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E");
 
 static int myri10ge_small_bytes = -1;	/* -1 == auto */
-module_param(myri10ge_small_bytes, int, S_IRUGO | S_IWUSR);
+module_param(myri10ge_small_bytes, int, 0644);
 MODULE_PARM_DESC(myri10ge_small_bytes, "Threshold of small packets");
 
 static int myri10ge_msi = 1;	/* enable msi by default */
-module_param(myri10ge_msi, int, S_IRUGO | S_IWUSR);
+module_param(myri10ge_msi, int, 0644);
 MODULE_PARM_DESC(myri10ge_msi, "Enable Message Signalled Interrupts");
 
 static int myri10ge_intr_coal_delay = 75;
-module_param(myri10ge_intr_coal_delay, int, S_IRUGO);
+module_param(myri10ge_intr_coal_delay, int, 0444);
 MODULE_PARM_DESC(myri10ge_intr_coal_delay, "Interrupt coalescing delay");
 
 static int myri10ge_flow_control = 1;
-module_param(myri10ge_flow_control, int, S_IRUGO);
+module_param(myri10ge_flow_control, int, 0444);
 MODULE_PARM_DESC(myri10ge_flow_control, "Pause parameter");
 
 static int myri10ge_deassert_wait = 1;
-module_param(myri10ge_deassert_wait, int, S_IRUGO | S_IWUSR);
+module_param(myri10ge_deassert_wait, int, 0644);
 MODULE_PARM_DESC(myri10ge_deassert_wait,
 		 "Wait when deasserting legacy interrupts");
 
 static int myri10ge_force_firmware = 0;
-module_param(myri10ge_force_firmware, int, S_IRUGO);
+module_param(myri10ge_force_firmware, int, 0444);
 MODULE_PARM_DESC(myri10ge_force_firmware,
 		 "Force firmware to assume aligned completions");
 
 static int myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN;
-module_param(myri10ge_initial_mtu, int, S_IRUGO);
+module_param(myri10ge_initial_mtu, int, 0444);
 MODULE_PARM_DESC(myri10ge_initial_mtu, "Initial MTU");
 
 static int myri10ge_napi_weight = 64;
-module_param(myri10ge_napi_weight, int, S_IRUGO);
+module_param(myri10ge_napi_weight, int, 0444);
 MODULE_PARM_DESC(myri10ge_napi_weight, "Set NAPI weight");
 
 static int myri10ge_watchdog_timeout = 1;
-module_param(myri10ge_watchdog_timeout, int, S_IRUGO);
+module_param(myri10ge_watchdog_timeout, int, 0444);
 MODULE_PARM_DESC(myri10ge_watchdog_timeout, "Set watchdog timeout");
 
 static int myri10ge_max_irq_loops = 1048576;
-module_param(myri10ge_max_irq_loops, int, S_IRUGO);
+module_param(myri10ge_max_irq_loops, int, 0444);
 MODULE_PARM_DESC(myri10ge_max_irq_loops,
 		 "Set stuck legacy IRQ detection threshold");
 
@@ -330,21 +330,21 @@ module_param(myri10ge_debug, int, 0);
 MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
 
 static int myri10ge_fill_thresh = 256;
-module_param(myri10ge_fill_thresh, int, S_IRUGO | S_IWUSR);
+module_param(myri10ge_fill_thresh, int, 0644);
 MODULE_PARM_DESC(myri10ge_fill_thresh, "Number of empty rx slots allowed");
 
 static int myri10ge_reset_recover = 1;
 
 static int myri10ge_max_slices = 1;
-module_param(myri10ge_max_slices, int, S_IRUGO);
+module_param(myri10ge_max_slices, int, 0444);
 MODULE_PARM_DESC(myri10ge_max_slices, "Max tx/rx queues");
 
 static int myri10ge_rss_hash = MXGEFW_RSS_HASH_TYPE_SRC_DST_PORT;
-module_param(myri10ge_rss_hash, int, S_IRUGO);
+module_param(myri10ge_rss_hash, int, 0444);
 MODULE_PARM_DESC(myri10ge_rss_hash, "Type of RSS hashing to do");
 
 static int myri10ge_dca = 1;
-module_param(myri10ge_dca, int, S_IRUGO);
+module_param(myri10ge_dca, int, 0444);
 MODULE_PARM_DESC(myri10ge_dca, "Enable DCA if possible");
 
 #define MYRI10GE_FW_OFFSET 1024*1024
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c b/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c
index cf81cf95d1d8..67cdd8330c59 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c
@@ -231,15 +231,15 @@ void nfp_net_debugfs_vnic_add(struct nfp_net *nn, struct dentry *ddir, int id)
 
 	for (i = 0; i < min(nn->max_rx_rings, nn->max_r_vecs); i++) {
 		sprintf(name, "%d", i);
-		debugfs_create_file(name, S_IRUSR, rx,
+		debugfs_create_file(name, 0400, rx,
 				    &nn->r_vecs[i], &nfp_rx_q_fops);
-		debugfs_create_file(name, S_IRUSR, xdp,
+		debugfs_create_file(name, 0400, xdp,
 				    &nn->r_vecs[i], &nfp_xdp_q_fops);
 	}
 
 	for (i = 0; i < min(nn->max_tx_rings, nn->max_r_vecs); i++) {
 		sprintf(name, "%d", i);
-		debugfs_create_file(name, S_IRUSR, tx,
+		debugfs_create_file(name, 0400, tx,
 				    &nn->r_vecs[i], &nfp_tx_q_fops);
 	}
 }
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index f2e8de607119..8259e8309320 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -2829,9 +2829,9 @@ netxen_show_bridged_mode(struct device *dev,
 }
 
 static const struct device_attribute dev_attr_bridged_mode = {
-       .attr = {.name = "bridged_mode", .mode = (S_IRUGO | S_IWUSR)},
-       .show = netxen_show_bridged_mode,
-       .store = netxen_store_bridged_mode,
+	.attr = { .name = "bridged_mode", .mode = 0644 },
+	.show = netxen_show_bridged_mode,
+	.store = netxen_store_bridged_mode,
 };
 
 static ssize_t
@@ -2861,7 +2861,7 @@ netxen_show_diag_mode(struct device *dev,
 }
 
 static const struct device_attribute dev_attr_diag_mode = {
-	.attr = {.name = "diag_mode", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "diag_mode", .mode = 0644 },
 	.show = netxen_show_diag_mode,
 	.store = netxen_store_diag_mode,
 };
@@ -3006,14 +3006,14 @@ static ssize_t netxen_sysfs_write_mem(struct file *filp, struct kobject *kobj,
 
 
 static const struct bin_attribute bin_attr_crb = {
-	.attr = {.name = "crb", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "crb", .mode = 0644 },
 	.size = 0,
 	.read = netxen_sysfs_read_crb,
 	.write = netxen_sysfs_write_crb,
 };
 
 static const struct bin_attribute bin_attr_mem = {
-	.attr = {.name = "mem", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "mem", .mode = 0644 },
 	.size = 0,
 	.read = netxen_sysfs_read_mem,
 	.write = netxen_sysfs_write_mem,
@@ -3142,7 +3142,7 @@ netxen_sysfs_read_dimm(struct file *filp, struct kobject *kobj,
 }
 
 static const struct bin_attribute bin_attr_dimm = {
-	.attr = { .name = "dimm", .mode = (S_IRUGO | S_IWUSR) },
+	.attr = { .name = "dimm", .mode = 0644 },
 	.size = sizeof(struct netxen_dimm_cfg),
 	.read = netxen_sysfs_read_dimm,
 };
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
index 287d89dd086f..891f03a7a33d 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
@@ -1175,81 +1175,81 @@ static ssize_t qlcnic_83xx_sysfs_flash_write_handler(struct file *filp,
 }
 
 static const struct device_attribute dev_attr_bridged_mode = {
-       .attr = {.name = "bridged_mode", .mode = (S_IRUGO | S_IWUSR)},
-       .show = qlcnic_show_bridged_mode,
-       .store = qlcnic_store_bridged_mode,
+	.attr = { .name = "bridged_mode", .mode = 0644 },
+	.show = qlcnic_show_bridged_mode,
+	.store = qlcnic_store_bridged_mode,
 };
 
 static const struct device_attribute dev_attr_diag_mode = {
-	.attr = {.name = "diag_mode", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "diag_mode", .mode = 0644 },
 	.show = qlcnic_show_diag_mode,
 	.store = qlcnic_store_diag_mode,
 };
 
 static const struct device_attribute dev_attr_beacon = {
-	.attr = {.name = "beacon", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "beacon", .mode = 0644 },
 	.show = qlcnic_show_beacon,
 	.store = qlcnic_store_beacon,
 };
 
 static const struct bin_attribute bin_attr_crb = {
-	.attr = {.name = "crb", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "crb", .mode = 0644 },
 	.size = 0,
 	.read = qlcnic_sysfs_read_crb,
 	.write = qlcnic_sysfs_write_crb,
 };
 
 static const struct bin_attribute bin_attr_mem = {
-	.attr = {.name = "mem", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "mem", .mode = 0644 },
 	.size = 0,
 	.read = qlcnic_sysfs_read_mem,
 	.write = qlcnic_sysfs_write_mem,
 };
 
 static const struct bin_attribute bin_attr_npar_config = {
-	.attr = {.name = "npar_config", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "npar_config", .mode = 0644 },
 	.size = 0,
 	.read = qlcnic_sysfs_read_npar_config,
 	.write = qlcnic_sysfs_write_npar_config,
 };
 
 static const struct bin_attribute bin_attr_pci_config = {
-	.attr = {.name = "pci_config", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "pci_config", .mode = 0644 },
 	.size = 0,
 	.read = qlcnic_sysfs_read_pci_config,
 	.write = NULL,
 };
 
 static const struct bin_attribute bin_attr_port_stats = {
-	.attr = {.name = "port_stats", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "port_stats", .mode = 0644 },
 	.size = 0,
 	.read = qlcnic_sysfs_get_port_stats,
 	.write = qlcnic_sysfs_clear_port_stats,
 };
 
 static const struct bin_attribute bin_attr_esw_stats = {
-	.attr = {.name = "esw_stats", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "esw_stats", .mode = 0644 },
 	.size = 0,
 	.read = qlcnic_sysfs_get_esw_stats,
 	.write = qlcnic_sysfs_clear_esw_stats,
 };
 
 static const struct bin_attribute bin_attr_esw_config = {
-	.attr = {.name = "esw_config", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "esw_config", .mode = 0644 },
 	.size = 0,
 	.read = qlcnic_sysfs_read_esw_config,
 	.write = qlcnic_sysfs_write_esw_config,
 };
 
 static const struct bin_attribute bin_attr_pm_config = {
-	.attr = {.name = "pm_config", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "pm_config", .mode = 0644 },
 	.size = 0,
 	.read = qlcnic_sysfs_read_pm_config,
 	.write = qlcnic_sysfs_write_pm_config,
 };
 
 static const struct bin_attribute bin_attr_flash = {
-	.attr = {.name = "flash", .mode = (S_IRUGO | S_IWUSR)},
+	.attr = { .name = "flash", .mode = 0644 },
 	.size = 0,
 	.read = qlcnic_83xx_sysfs_flash_read_handler,
 	.write = qlcnic_83xx_sysfs_flash_write_handler,
@@ -1276,7 +1276,7 @@ static ssize_t qlcnic_hwmon_show_temp(struct device *dev,
 }
 
 /* hwmon-sysfs attributes */
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO,
+static SENSOR_DEVICE_ATTR(temp1_input, 0444,
 			  qlcnic_hwmon_show_temp, NULL, 1);
 
 static struct attribute *qlcnic_hwmon_attrs[] = {
diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c
index 92b6be9c4429..51d89c86e60f 100644
--- a/drivers/net/ethernet/qualcomm/qca_debug.c
+++ b/drivers/net/ethernet/qualcomm/qca_debug.c
@@ -151,7 +151,7 @@ qcaspi_init_device_debugfs(struct qcaspi *qca)
 			dev_name(&qca->net_dev->dev));
 		return;
 	}
-	debugfs_create_file("info", S_IFREG | S_IRUGO, device_root, qca,
+	debugfs_create_file("info", S_IFREG | 0444, device_root, qca,
 			    &qcaspi_info_ops);
 }
 
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
index fd35d8004a78..a9da1ad4b4f2 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
@@ -57,9 +57,9 @@
 static int debug = -1;
 static int eee_timer = SXGBE_DEFAULT_LPI_TIMER;
 
-module_param(eee_timer, int, S_IRUGO | S_IWUSR);
+module_param(eee_timer, int, 0644);
 
-module_param(debug, int, S_IRUGO | S_IWUSR);
+module_param(debug, int, 0644);
 static const u32 default_msg_level = (NETIF_MSG_DRV | NETIF_MSG_PROBE |
 				      NETIF_MSG_LINK | NETIF_MSG_IFUP |
 				      NETIF_MSG_IFDOWN | NETIF_MSG_TIMER);
diff --git a/drivers/net/ethernet/sfc/mcdi_mon.c b/drivers/net/ethernet/sfc/mcdi_mon.c
index f97da05952c7..f17751559ccc 100644
--- a/drivers/net/ethernet/sfc/mcdi_mon.c
+++ b/drivers/net/ethernet/sfc/mcdi_mon.c
@@ -298,7 +298,7 @@ efx_mcdi_mon_add_attr(struct efx_nic *efx, const char *name,
 	attr->limit_value = limit_value;
 	sysfs_attr_init(&attr->dev_attr.attr);
 	attr->dev_attr.attr.name = attr->name;
-	attr->dev_attr.attr.mode = S_IRUGO;
+	attr->dev_attr.attr.mode = 0444;
 	attr->dev_attr.show = reader;
 	hwmon->group.attrs[hwmon->n_attrs++] = &attr->dev_attr.attr;
 }
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a9856a8bf8ad..9f983dd069d5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -57,36 +57,36 @@
 /* Module parameters */
 #define TX_TIMEO	5000
 static int watchdog = TX_TIMEO;
-module_param(watchdog, int, S_IRUGO | S_IWUSR);
+module_param(watchdog, int, 0644);
 MODULE_PARM_DESC(watchdog, "Transmit timeout in milliseconds (default 5s)");
 
 static int debug = -1;
-module_param(debug, int, S_IRUGO | S_IWUSR);
+module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Message Level (-1: default, 0: no output, 16: all)");
 
 static int phyaddr = -1;
-module_param(phyaddr, int, S_IRUGO);
+module_param(phyaddr, int, 0444);
 MODULE_PARM_DESC(phyaddr, "Physical device address");
 
 #define STMMAC_TX_THRESH	(DMA_TX_SIZE / 4)
 #define STMMAC_RX_THRESH	(DMA_RX_SIZE / 4)
 
 static int flow_ctrl = FLOW_OFF;
-module_param(flow_ctrl, int, S_IRUGO | S_IWUSR);
+module_param(flow_ctrl, int, 0644);
 MODULE_PARM_DESC(flow_ctrl, "Flow control ability [on/off]");
 
 static int pause = PAUSE_TIME;
-module_param(pause, int, S_IRUGO | S_IWUSR);
+module_param(pause, int, 0644);
 MODULE_PARM_DESC(pause, "Flow Control Pause Time");
 
 #define TC_DEFAULT 64
 static int tc = TC_DEFAULT;
-module_param(tc, int, S_IRUGO | S_IWUSR);
+module_param(tc, int, 0644);
 MODULE_PARM_DESC(tc, "DMA threshold control value");
 
 #define	DEFAULT_BUFSIZE	1536
 static int buf_sz = DEFAULT_BUFSIZE;
-module_param(buf_sz, int, S_IRUGO | S_IWUSR);
+module_param(buf_sz, int, 0644);
 MODULE_PARM_DESC(buf_sz, "DMA buffer size");
 
 #define	STMMAC_RX_COPYBREAK	256
@@ -97,7 +97,7 @@ static const u32 default_msg_level = (NETIF_MSG_DRV | NETIF_MSG_PROBE |
 
 #define STMMAC_DEFAULT_LPI_TIMER	1000
 static int eee_timer = STMMAC_DEFAULT_LPI_TIMER;
-module_param(eee_timer, int, S_IRUGO | S_IWUSR);
+module_param(eee_timer, int, 0644);
 MODULE_PARM_DESC(eee_timer, "LPI tx expiration time in msec");
 #define STMMAC_LPI_T(x) (jiffies + msecs_to_jiffies(x))
 
@@ -105,7 +105,7 @@ MODULE_PARM_DESC(eee_timer, "LPI tx expiration time in msec");
  * but allow user to force to use the chain instead of the ring
  */
 static unsigned int chain_mode;
-module_param(chain_mode, int, S_IRUGO);
+module_param(chain_mode, int, 0444);
 MODULE_PARM_DESC(chain_mode, "To use chain instead of ring mode");
 
 static irqreturn_t stmmac_interrupt(int irq, void *dev_id);
@@ -4001,7 +4001,7 @@ static int stmmac_init_fs(struct net_device *dev)
 
 	/* Entry to report DMA RX/TX rings */
 	priv->dbgfs_rings_status =
-		debugfs_create_file("descriptors_status", S_IRUGO,
+		debugfs_create_file("descriptors_status", 0444,
 				    priv->dbgfs_dir, dev,
 				    &stmmac_rings_status_fops);
 
@@ -4013,9 +4013,9 @@ static int stmmac_init_fs(struct net_device *dev)
 	}
 
 	/* Entry to report the DMA HW features */
-	priv->dbgfs_dma_cap = debugfs_create_file("dma_cap", S_IRUGO,
-					    priv->dbgfs_dir,
-					    dev, &stmmac_dma_cap_fops);
+	priv->dbgfs_dma_cap = debugfs_create_file("dma_cap", 0444,
+						  priv->dbgfs_dir,
+						  dev, &stmmac_dma_cap_fops);
 
 	if (!priv->dbgfs_dma_cap || IS_ERR(priv->dbgfs_dma_cap)) {
 		netdev_err(priv->dev, "ERROR creating stmmac MMC debugfs file\n");
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 8dd545fed30d..f081de4f38d7 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -9437,11 +9437,11 @@ static ssize_t show_num_ports(struct device *dev,
 }
 
 static struct device_attribute niu_parent_attributes[] = {
-	__ATTR(port_phy, S_IRUGO, show_port_phy, NULL),
-	__ATTR(plat_type, S_IRUGO, show_plat_type, NULL),
-	__ATTR(rxchan_per_port, S_IRUGO, show_rxchan_per_port, NULL),
-	__ATTR(txchan_per_port, S_IRUGO, show_txchan_per_port, NULL),
-	__ATTR(num_ports, S_IRUGO, show_num_ports, NULL),
+	__ATTR(port_phy, 0444, show_port_phy, NULL),
+	__ATTR(plat_type, 0444, show_plat_type, NULL),
+	__ATTR(rxchan_per_port, 0444, show_rxchan_per_port, NULL),
+	__ATTR(txchan_per_port, 0444, show_txchan_per_port, NULL),
+	__ATTR(num_ports, 0444, show_num_ports, NULL),
 	{}
 };
 
-- 
2.15.0

^ permalink raw reply related

* [PATCH 0/4] net: drivers/net: Use octal permissions
From: Joe Perches @ 2018-03-23 22:54 UTC (permalink / raw)
  To: netdev, linux-can, linux-arm-kernel, nios2-dev, linuxppc-dev,
	intel-wired-lan, linux-rdma, linux-hams, devel, linux-wpan,
	linux-ppp, linux-usb, linux-wireless, wcn36xx, xen-devel, bridge,
	ceph-devel, linux-decnet-user, netfilter-devel, coreteam,
	linux-afs, linux-sctp, linux-nfs, linux-x25, linux-mediatek
  Cc: linux-kernel, oss-drivers, brcm80211-dev-list.pdl,
	brcm80211-dev-list, linux-bluetooth

Using octal and not symbolic permissions is preferred by many as
more readable.

https://lkml.org/lkml/2016/8/2/1945

Rather than getting these piecemeal, just do them all.
Done with checkpatch and some typing.

Joe Perches (4):
  ethernet: Use octal not symbolic permissions
  wireless: Use octal not symbolic permissions
  net: Use octal not symbolic permissions
  drivers/net: Use octal not symbolic permissions

 drivers/net/bonding/bond_procfs.c                  |   2 +-
 drivers/net/bonding/bond_sysfs.c                   |  73 +++++++-------
 drivers/net/bonding/bond_sysfs_slave.c             |   4 +-
 drivers/net/caif/caif_serial.c                     |  32 +++---
 drivers/net/caif/caif_spi.c                        |  16 +--
 drivers/net/caif/caif_virtio.c                     |  16 +--
 drivers/net/can/at91_can.c                         |   3 +-
 drivers/net/can/cc770/cc770.c                      |   4 +-
 drivers/net/can/cc770/cc770_isa.c                  |  16 +--
 drivers/net/can/grcan.c                            |   4 +-
 drivers/net/can/janz-ican3.c                       |   6 +-
 drivers/net/can/sja1000/sja1000_isa.c              |  14 +--
 drivers/net/can/softing/softing_main.c             |   4 +-
 drivers/net/can/spi/mcp251x.c                      |   2 +-
 drivers/net/can/usb/esd_usb2.c                     |   6 +-
 drivers/net/can/vcan.c                             |   2 +-
 drivers/net/ethernet/8390/apne.c                   |   2 +-
 drivers/net/ethernet/8390/lib8390.c                |   2 +-
 drivers/net/ethernet/8390/ne.c                     |   2 +-
 drivers/net/ethernet/8390/ne2k-pci.c               |   2 +-
 drivers/net/ethernet/8390/smc-ultra.c              |   2 +-
 drivers/net/ethernet/8390/stnic.c                  |   2 +-
 drivers/net/ethernet/8390/wd.c                     |   2 +-
 drivers/net/ethernet/altera/altera_tse_main.c      |   6 +-
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c           |  10 +-
 drivers/net/ethernet/amd/xgbe/xgbe-main.c          |   2 +-
 drivers/net/ethernet/broadcom/bnx2.c               |   2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |  12 +--
 drivers/net/ethernet/broadcom/sb1250-mac.c         |  10 +-
 drivers/net/ethernet/broadcom/tg3.c                |   6 +-
 drivers/net/ethernet/brocade/bna/bnad.c            |   2 +-
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c    |  10 +-
 drivers/net/ethernet/cavium/thunder/nicvf_main.c   |   2 +-
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c    |   6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 112 ++++++++++-----------
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c    |  10 +-
 drivers/net/ethernet/ec_bhf.c                      |   2 +-
 drivers/net/ethernet/emulex/benet/be_main.c        |   6 +-
 drivers/net/ethernet/ibm/ehea/ehea_main.c          |   7 +-
 drivers/net/ethernet/ibm/ibmveth.c                 |   2 +-
 drivers/net/ethernet/intel/igb/igb_hwmon.c         |   2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c     |   2 +-
 drivers/net/ethernet/marvell/mvneta.c              |   8 +-
 drivers/net/ethernet/marvell/skge.c                |   2 +-
 drivers/net/ethernet/marvell/sky2.c                |   2 +-
 drivers/net/ethernet/mellanox/mlx4/main.c          |  16 +--
 drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c   |  10 +-
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c   |  32 +++---
 .../net/ethernet/netronome/nfp/nfp_net_debugfs.c   |   6 +-
 .../net/ethernet/qlogic/netxen/netxen_nic_main.c   |  14 +--
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c  |  30 +++---
 drivers/net/ethernet/qualcomm/qca_debug.c          |   2 +-
 drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c    |   4 +-
 drivers/net/ethernet/sfc/mcdi_mon.c                |   2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |  26 ++---
 drivers/net/ethernet/sun/niu.c                     |  10 +-
 drivers/net/hamradio/bpqether.c                    |   3 +-
 drivers/net/hamradio/yam.c                         |   2 +-
 drivers/net/hyperv/netvsc_drv.c                    |   4 +-
 drivers/net/ieee802154/at86rf230.c                 |   2 +-
 drivers/net/phy/spi_ks8995.c                       |   2 +-
 drivers/net/ppp/ppp_generic.c                      |   2 +-
 drivers/net/ppp/pppoe.c                            |   2 +-
 drivers/net/usb/cdc_ncm.c                          |  12 +--
 drivers/net/usb/hso.c                              |   8 +-
 drivers/net/wireless/ath/ath5k/base.c              |   6 +-
 drivers/net/wireless/ath/ath5k/debug.c             |  37 ++-----
 drivers/net/wireless/ath/ath5k/sysfs.c             |   8 +-
 drivers/net/wireless/ath/ath6kl/debug.c            |  43 ++++----
 drivers/net/wireless/ath/ath9k/common-debug.c      |   9 +-
 drivers/net/wireless/ath/ath9k/common-spectral.c   |  10 +-
 drivers/net/wireless/ath/ath9k/debug.c             |  40 ++++----
 drivers/net/wireless/ath/ath9k/debug_sta.c         |   6 +-
 drivers/net/wireless/ath/ath9k/dfs_debug.c         |   4 +-
 drivers/net/wireless/ath/ath9k/htc_drv_debug.c     |  16 +--
 drivers/net/wireless/ath/ath9k/tx99.c              |   4 +-
 drivers/net/wireless/ath/carl9170/debug.c          |   8 +-
 drivers/net/wireless/ath/carl9170/main.c           |   4 +-
 drivers/net/wireless/ath/wcn36xx/debug.c           |   5 +-
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  |   6 +-
 .../wireless/broadcom/brcm80211/brcmsmac/debug.c   |   2 +-
 .../broadcom/brcm80211/brcmsmac/mac80211_if.c      |   2 +-
 drivers/net/wireless/cisco/airo.c                  |   6 +-
 drivers/net/wireless/intel/ipw2x00/ipw2100.c       |  29 +++---
 drivers/net/wireless/intel/ipw2x00/ipw2200.c       |  51 ++++------
 drivers/net/wireless/intel/ipw2x00/libipw_module.c |   2 +-
 drivers/net/wireless/intel/iwlegacy/3945-mac.c     |  35 +++----
 drivers/net/wireless/intel/iwlegacy/4965-mac.c     |  19 ++--
 drivers/net/wireless/intel/iwlegacy/4965-rs.c      |   8 +-
 drivers/net/wireless/intel/iwlegacy/common.c       |   4 +-
 drivers/net/wireless/intel/iwlegacy/debug.c        |  58 ++++++-----
 drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c   |  78 +++++++-------
 drivers/net/wireless/intel/iwlwifi/dvm/rs.c        |  16 +--
 drivers/net/wireless/intel/iwlwifi/fw/debugfs.c    |   2 +-
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c       |  43 ++++----
 .../net/wireless/intel/iwlwifi/mvm/debugfs-vif.c   |  40 +++-----
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c   | 110 ++++++++++----------
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c       |   6 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c        |  12 +--
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c    |  12 +--
 drivers/net/wireless/intersil/p54/main.c           |   2 +-
 drivers/net/wireless/mediatek/mt76/debugfs.c       |  10 +-
 .../net/wireless/mediatek/mt76/mt76x2_debugfs.c    |   8 +-
 drivers/net/wireless/mediatek/mt7601u/debugfs.c    |  16 ++-
 drivers/net/wireless/ralink/rt2x00/rt2500usb.c     |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800pci.c     |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800soc.c     |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800usb.c     |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2x00debug.c   |  64 ++++++------
 drivers/net/wireless/ralink/rt2x00/rt61pci.c       |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt73usb.c       |   2 +-
 drivers/net/wireless/ray_cs.c                      |   8 +-
 drivers/net/wireless/st/cw1200/debug.c             |   6 +-
 drivers/net/wireless/st/cw1200/main.c              |   2 +-
 drivers/net/wireless/ti/wl18xx/main.c              |  27 +++--
 drivers/net/wireless/ti/wlcore/main.c              |   8 +-
 drivers/net/wireless/ti/wlcore/sdio.c              |   2 +-
 drivers/net/wireless/ti/wlcore/sysfs.c             |   7 +-
 drivers/net/xen-netback/xenbus.c                   |   4 +-
 drivers/net/xen-netfront.c                         |   6 +-
 net/8021q/vlanproc.c                               |   6 +-
 net/appletalk/atalk_proc.c                         |   8 +-
 net/atm/atm_sysfs.c                                |  12 +--
 net/atm/clip.c                                     |   2 +-
 net/atm/lec.c                                      |   2 +-
 net/atm/proc.c                                     |   2 +-
 net/ax25/af_ax25.c                                 |   6 +-
 net/bluetooth/rfcomm/tty.c                         |   4 +-
 net/bridge/br_sysfs_br.c                           |   2 +-
 net/bridge/br_sysfs_if.c                           |  36 +++----
 net/can/af_can.c                                   |   2 +-
 net/can/gw.c                                       |   2 +-
 net/ceph/ceph_common.c                             |   2 +-
 net/core/net-procfs.c                              |   6 +-
 net/core/net-sysfs.c                               |  12 +--
 net/core/sock.c                                    |   2 +-
 net/decnet/af_decnet.c                             |   2 +-
 net/decnet/dn_dev.c                                |   2 +-
 net/decnet/dn_neigh.c                              |   2 +-
 net/decnet/dn_route.c                              |   2 +-
 net/dns_resolver/dns_key.c                         |   2 +-
 net/ipv4/arp.c                                     |   2 +-
 net/ipv4/fib_trie.c                                |   6 +-
 net/ipv4/igmp.c                                    |   4 +-
 net/ipv4/ipconfig.c                                |   2 +-
 net/ipv4/netfilter/ipt_CLUSTERIP.c                 |   2 +-
 net/ipv4/ping.c                                    |   2 +-
 net/ipv4/proc.c                                    |   6 +-
 net/ipv4/raw.c                                     |   2 +-
 net/ipv4/route.c                                   |   4 +-
 net/ipv4/tcp_ipv4.c                                |   2 +-
 net/ipv4/udp.c                                     |   2 +-
 net/ipv6/addrconf.c                                |   2 +-
 net/ipv6/anycast.c                                 |   2 +-
 net/ipv6/ip6_flowlabel.c                           |   2 +-
 net/ipv6/mcast.c                                   |   4 +-
 net/ipv6/proc.c                                    |   6 +-
 net/ipv6/raw.c                                     |   2 +-
 net/ipv6/route.c                                   |   2 +-
 net/kcm/kcmproc.c                                  |   4 +-
 net/l2tp/l2tp_ppp.c                                |   2 +-
 net/llc/llc_proc.c                                 |   4 +-
 net/mac80211/rc80211_minstrel.c                    |   2 +-
 net/mac80211/rc80211_minstrel_debugfs.c            |   8 +-
 net/mac80211/rc80211_minstrel_ht_debugfs.c         |   8 +-
 net/netfilter/nf_conntrack_netbios_ns.c            |   2 +-
 net/netfilter/nf_conntrack_snmp.c                  |   2 +-
 net/netfilter/nf_conntrack_standalone.c            |   2 +-
 net/netfilter/nf_log.c                             |   2 +-
 net/netfilter/nf_synproxy_core.c                   |   2 +-
 net/netfilter/xt_IDLETIMER.c                       |   2 +-
 net/netfilter/xt_recent.c                          |   4 +-
 net/netrom/af_netrom.c                             |   6 +-
 net/rose/af_rose.c                                 |   8 +-
 net/rxrpc/af_rxrpc.c                               |   2 +-
 net/sctp/proc.c                                    |  16 +--
 net/sunrpc/auth_gss/svcauth_gss.c                  |   2 +-
 net/sunrpc/cache.c                                 |  10 +-
 net/sunrpc/debugfs.c                               |   6 +-
 net/sunrpc/rpc_pipe.c                              |  42 ++++----
 net/wireless/wext-proc.c                           |   2 +-
 net/x25/x25_proc.c                                 |  12 +--
 net/xfrm/xfrm_proc.c                               |   2 +-
 183 files changed, 906 insertions(+), 969 deletions(-)

-- 
2.15.0

^ permalink raw reply

* Re: [RFC PATCH v2 0/2] Randomization of address chosen by mmap.
From: Rich Felker @ 2018-03-23 19:35 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Ilya Smith, rth, ink, mattst88, vgupta, linux, tony.luck,
	fenghua.yu, jhogan, ralf, jejb, deller, benh, paulus, mpe,
	schwidefsky, heiko.carstens, ysato, davem, tglx, mingo, hpa, x86,
	nyc, viro, arnd, gregkh, deepa.kernel, mhocko, hughd, kstewart,
	pombredanne, akpm, steve.capper, punit.agrawal, paul.burton,
	aneesh.kumar, npiggin, keescook, bhsharma, riel, nitin.m.gupta,
	kirill.shutemov, dan.j.williams, jack, ross.zwisler, jglisse,
	aarcange, oleg, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-ia64, linux-metag, linux-mips,
	linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux,
	linux-mm
In-Reply-To: <20180323192952.GB23763@bombadil.infradead.org>

On Fri, Mar 23, 2018 at 12:29:52PM -0700, Matthew Wilcox wrote:
> On Fri, Mar 23, 2018 at 03:16:21PM -0400, Rich Felker wrote:
> > > Huh, I thought libc was aware of this.  Also, I'd expect a libc-based
> > > implementation to restrict itself to, eg, only loading libraries in
> > > the bottom 1GB to avoid applications who want to map huge things from
> > > running out of unfragmented address space.
> > 
> > That seems like a rather arbitrary expectation and I'm not sure why
> > you'd expect it to result in less fragmentation rather than more. For
> > example if it started from 1GB and worked down, you'd immediately
> > reduce the contiguous free space from ~3GB to ~2GB, and if it started
> > from the bottom and worked up, brk would immediately become
> > unavailable, increasing mmap pressure elsewhere.
> 
> By *not* limiting yourself to the bottom 1GB, you'll almost immediately
> fragment the address space even worse.  Just looking at 'ls' as a
> hopefully-good example of a typical app, it maps:
> 
> 	linux-vdso.so.1 (0x00007ffef5eef000)
> 	libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fb3657f5000)
> 	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb36543b000)
> 	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fb3651c9000)
> 	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb364fc5000)
> 	/lib64/ld-linux-x86-64.so.2 (0x00007fb365c3f000)
> 	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb364da7000)
> 
> The VDSO wouldn't move, but look at the distribution of mapping 6 things
> into a 3GB address space in random locations.  What are the odds you have
> a contiguous 1GB chunk of address space?  If you restrict yourself to the
> bottom 1GB before running out of room and falling back to a sequential
> allocation, you'll prevent a lot of fragmentation.

Oh, you're talking about "with random locations" case. Randomizing
each map just hopelessly fragments things no matter what you do on
32-bit. If you reduce the space over which you randomize to the point
where it's not fragmenting/killing your available vm space, there are
so few degrees of freedom left that it's trivial to brute-force. Maybe
"libs randomized in low 1GB, everything else near-sequential in high
addresses" works half decently, but I have a hard time believing you
can get any ASLR that's significantly better than snake oil in a
32-bit address space, and you certainly do pay a high price in total
available vm space.

Rich

^ permalink raw reply

* Re: [RFC PATCH v2 0/2] Randomization of address chosen by mmap.
From: Matthew Wilcox @ 2018-03-23 19:29 UTC (permalink / raw)
  To: Rich Felker
  Cc: Ilya Smith, rth, ink, mattst88, vgupta, linux, tony.luck,
	fenghua.yu, jhogan, ralf, jejb, deller, benh, paulus, mpe,
	schwidefsky, heiko.carstens, ysato, davem, tglx, mingo, hpa, x86,
	nyc, viro, arnd, gregkh, deepa.kernel, mhocko, hughd, kstewart,
	pombredanne, akpm, steve.capper, punit.agrawal, paul.burton,
	aneesh.kumar, npiggin, keescook, bhsharma, riel, nitin.m.gupta,
	kirill.shutemov, dan.j.williams, jack, ross.zwisler, jglisse,
	aarcange, oleg, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-ia64, linux-metag, linux-mips,
	linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux,
	linux-mm
In-Reply-To: <20180323191621.GC1436@brightrain.aerifal.cx>

On Fri, Mar 23, 2018 at 03:16:21PM -0400, Rich Felker wrote:
> > Huh, I thought libc was aware of this.  Also, I'd expect a libc-based
> > implementation to restrict itself to, eg, only loading libraries in
> > the bottom 1GB to avoid applications who want to map huge things from
> > running out of unfragmented address space.
> 
> That seems like a rather arbitrary expectation and I'm not sure why
> you'd expect it to result in less fragmentation rather than more. For
> example if it started from 1GB and worked down, you'd immediately
> reduce the contiguous free space from ~3GB to ~2GB, and if it started
> from the bottom and worked up, brk would immediately become
> unavailable, increasing mmap pressure elsewhere.

By *not* limiting yourself to the bottom 1GB, you'll almost immediately
fragment the address space even worse.  Just looking at 'ls' as a
hopefully-good example of a typical app, it maps:

	linux-vdso.so.1 (0x00007ffef5eef000)
	libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fb3657f5000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb36543b000)
	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fb3651c9000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb364fc5000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fb365c3f000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb364da7000)

The VDSO wouldn't move, but look at the distribution of mapping 6 things
into a 3GB address space in random locations.  What are the odds you have
a contiguous 1GB chunk of address space?  If you restrict yourself to the
bottom 1GB before running out of room and falling back to a sequential
allocation, you'll prevent a lot of fragmentation.

^ permalink raw reply

* Re: [RFC PATCH v2 0/2] Randomization of address chosen by mmap.
From: Rich Felker @ 2018-03-23 19:16 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Ilya Smith, rth, ink, mattst88, vgupta, linux, tony.luck,
	fenghua.yu, jhogan, ralf, jejb, deller, benh, paulus, mpe,
	schwidefsky, heiko.carstens, ysato, davem, tglx, mingo, hpa, x86,
	nyc, viro, arnd, gregkh, deepa.kernel, mhocko, hughd, kstewart,
	pombredanne, akpm, steve.capper, punit.agrawal, paul.burton,
	aneesh.kumar, npiggin, keescook, bhsharma, riel, nitin.m.gupta,
	kirill.shutemov, dan.j.williams, jack, ross.zwisler, jglisse,
	aarcange, oleg, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-ia64, linux-metag, linux-mips,
	linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux,
	linux-mm
In-Reply-To: <20180323190618.GA23763@bombadil.infradead.org>

On Fri, Mar 23, 2018 at 12:06:18PM -0700, Matthew Wilcox wrote:
> On Fri, Mar 23, 2018 at 02:00:24PM -0400, Rich Felker wrote:
> > On Fri, Mar 23, 2018 at 05:48:06AM -0700, Matthew Wilcox wrote:
> > > On Thu, Mar 22, 2018 at 07:36:36PM +0300, Ilya Smith wrote:
> > > > Current implementation doesn't randomize address returned by mmap.
> > > > All the entropy ends with choosing mmap_base_addr at the process
> > > > creation. After that mmap build very predictable layout of address
> > > > space. It allows to bypass ASLR in many cases. This patch make
> > > > randomization of address on any mmap call.
> > > 
> > > Why should this be done in the kernel rather than libc?  libc is perfectly
> > > capable of specifying random numbers in the first argument of mmap.
> > 
> > Generally libc does not have a view of the current vm maps, and thus
> > in passing "random numbers", they would have to be uniform across the
> > whole vm space and thus non-uniform once the kernel rounds up to avoid
> > existing mappings.
> 
> I'm aware that you're the musl author, but glibc somehow manages to
> provide etext, edata and end, demonstrating that it does know where at
> least some of the memory map lies.

Yes, but that's pretty minimal info.

> Virtually everything after that is
> brought into the address space via mmap, which at least glibc intercepts,

There's also vdso, the program interpreter (ldso), and theoretically
other things the kernel might add. I agree you _could_ track most of
this (and all if you want to open /proc/self/maps), but it seems
hackish and wrong (violating clean boundaries between userspace and
kernel responsibility).

> > Also this would impose requirements that libc be
> > aware of the kernel's use of the virtual address space and what's
> > available to userspace -- for example, on 32-bit archs whether 2GB,
> > 3GB, or full 4GB (for 32-bit-user-on-64-bit-kernel) is available, and
> > on 64-bit archs where fewer than the full 64 bits are actually valid
> > in addresses, what the actual usable pointer size is. There is
> > currently no clean way of conveying this information to userspace.
> 
> Huh, I thought libc was aware of this.  Also, I'd expect a libc-based
> implementation to restrict itself to, eg, only loading libraries in
> the bottom 1GB to avoid applications who want to map huge things from
> running out of unfragmented address space.

That seems like a rather arbitrary expectation and I'm not sure why
you'd expect it to result in less fragmentation rather than more. For
example if it started from 1GB and worked down, you'd immediately
reduce the contiguous free space from ~3GB to ~2GB, and if it started
from the bottom and worked up, brk would immediately become
unavailable, increasing mmap pressure elsewhere.

Rich

^ permalink raw reply

* Re: [RFC PATCH v2 0/2] Randomization of address chosen by mmap.
From: Matthew Wilcox @ 2018-03-23 19:06 UTC (permalink / raw)
  To: Rich Felker
  Cc: Ilya Smith, rth, ink, mattst88, vgupta, linux, tony.luck,
	fenghua.yu, jhogan, ralf, jejb, deller, benh, paulus, mpe,
	schwidefsky, heiko.carstens, ysato, davem, tglx, mingo, hpa, x86,
	nyc, viro, arnd, gregkh, deepa.kernel, mhocko, hughd, kstewart,
	pombredanne, akpm, steve.capper, punit.agrawal, paul.burton,
	aneesh.kumar, npiggin, keescook, bhsharma, riel, nitin.m.gupta,
	kirill.shutemov, dan.j.williams, jack, ross.zwisler, jglisse,
	aarcange, oleg, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-ia64, linux-metag, linux-mips,
	linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux,
	linux-mm
In-Reply-To: <20180323180024.GB1436@brightrain.aerifal.cx>

On Fri, Mar 23, 2018 at 02:00:24PM -0400, Rich Felker wrote:
> On Fri, Mar 23, 2018 at 05:48:06AM -0700, Matthew Wilcox wrote:
> > On Thu, Mar 22, 2018 at 07:36:36PM +0300, Ilya Smith wrote:
> > > Current implementation doesn't randomize address returned by mmap.
> > > All the entropy ends with choosing mmap_base_addr at the process
> > > creation. After that mmap build very predictable layout of address
> > > space. It allows to bypass ASLR in many cases. This patch make
> > > randomization of address on any mmap call.
> > 
> > Why should this be done in the kernel rather than libc?  libc is perfectly
> > capable of specifying random numbers in the first argument of mmap.
> 
> Generally libc does not have a view of the current vm maps, and thus
> in passing "random numbers", they would have to be uniform across the
> whole vm space and thus non-uniform once the kernel rounds up to avoid
> existing mappings.

I'm aware that you're the musl author, but glibc somehow manages to
provide etext, edata and end, demonstrating that it does know where at
least some of the memory map lies.  Virtually everything after that is
brought into the address space via mmap, which at least glibc intercepts,
so it's entirely possible for a security-conscious libc to know where
other things are in the memory map.  Not to mention that what we're
primarily talking about here are libraries which are dynamically linked
and are loaded by ld.so before calling main(); not dlopen() or even
regular user mmaps.

> Also this would impose requirements that libc be
> aware of the kernel's use of the virtual address space and what's
> available to userspace -- for example, on 32-bit archs whether 2GB,
> 3GB, or full 4GB (for 32-bit-user-on-64-bit-kernel) is available, and
> on 64-bit archs where fewer than the full 64 bits are actually valid
> in addresses, what the actual usable pointer size is. There is
> currently no clean way of conveying this information to userspace.

Huh, I thought libc was aware of this.  Also, I'd expect a libc-based
implementation to restrict itself to, eg, only loading libraries in
the bottom 1GB to avoid applications who want to map huge things from
running out of unfragmented address space.

^ permalink raw reply

* Re: [PATCH] powerpc/64s: Fix NULL AT_BASE_PLATFORM when using DT CPU features
From: Gustavo Romero @ 2018-03-23 18:39 UTC (permalink / raw)
  To: Li Yi (Adam), linuxppc-dev
In-Reply-To: <CAN7W-Tbai=VjA6HBVM-2tQwdgk1ebiSZ_d-D2o42Yhz=bJOo-Q@mail.gmail.com>

Hi Yi,

On 03/14/2018 05:34 AM, Li Yi (Adam) wrote:
>> So set it in the DT CPU features code also.
>>
>> This results in eg:
>>    $ LD_SHOW_AUXV=1 /bin/true | grep "AT_.*PLATFORM"
>>    AT_PLATFORM:     power9
>>    AT_BASE_PLATFORM:power9
>>
> 
> Is this issue related with DD2.2 CPU?
> I tested on a Boston system with DD2.1 CPU, with kernel 4.14.23,
> AT_BASE_PLATFORM value is correct:
> 
> [root@boston-sh-04 ~]# LD_SHOW_AUXV=1 /bin/true | grep "AT_.*PLATFORM"
> AT_PLATFORM:     power9
> AT_BASE_PLATFORM:power9
> [root@boston-sh-04 ~]# uname -a
> Linux boston-sh-04 4.14.23 #1 SMP Sat Mar 3 12:14:56 CST 2018 ppc64le
> ppc64le ppc64le GNU/Linux

It's not related to the processor version, rather it's related to if you
are under a VM or running on baremetal. The issue happens on baremetal
when you are using DT to get the CPU features. So I guess the test you
performed above is on a VM? On DD2.1 baremetal AT_BASE_PLATFORM is
missing as on a DD2.2 baremetal (if mpe's patch is not applied):

root@r222l:~# LD_SHOW_AUXV=1 /bin/true | grep "AT_.*PLATFORM"
AT_PLATFORM:     power9
root@r222l:~# lscpu | fgrep Model
Model:               2.1 (pvr 004e 1201)
Model name:          POWER9, altivec supported
root@r222l:~# uname -a
Linux r222l 4.13.0-32-generic #35-Ubuntu SMP Thu Jan 25 09:05:20 UTC 2018 ppc64le ppc64le ppc64le GNU/Linux
   

Regards,
Gustavo

> 
> Thanks,
> -Yi
> 
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>> ---
>>   arch/powerpc/kernel/dt_cpu_ftrs.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/powerpc/kernel/dt_cpu_ftrs.c b/arch/powerpc/kernel/dt_cpu_ftrs.c
>> index 945e2c29ad2d..0bcfb0f256e1 100644
>> --- a/arch/powerpc/kernel/dt_cpu_ftrs.c
>> +++ b/arch/powerpc/kernel/dt_cpu_ftrs.c
>> @@ -720,6 +720,9 @@ static void __init cpufeatures_setup_finished(void)
>>                  cur_cpu_spec->cpu_features |= CPU_FTR_HVMODE;
>>          }
>>
>> +       /* Make sure powerpc_base_platform is non-NULL */
>> +       powerpc_base_platform = cur_cpu_spec->platform;
>> +
>>          system_registers.lpcr = mfspr(SPRN_LPCR);
>>          system_registers.hfscr = mfspr(SPRN_HFSCR);
>>          system_registers.fscr = mfspr(SPRN_FSCR);
>> --
>> 2.14.1
> 

^ permalink raw reply

* Re: [RFC PATCH v2 0/2] Randomization of address chosen by mmap.
From: Rich Felker @ 2018-03-23 18:00 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Ilya Smith, rth, ink, mattst88, vgupta, linux, tony.luck,
	fenghua.yu, jhogan, ralf, jejb, deller, benh, paulus, mpe,
	schwidefsky, heiko.carstens, ysato, davem, tglx, mingo, hpa, x86,
	nyc, viro, arnd, gregkh, deepa.kernel, mhocko, hughd, kstewart,
	pombredanne, akpm, steve.capper, punit.agrawal, paul.burton,
	aneesh.kumar, npiggin, keescook, bhsharma, riel, nitin.m.gupta,
	kirill.shutemov, dan.j.williams, jack, ross.zwisler, jglisse,
	aarcange, oleg, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-ia64, linux-metag, linux-mips,
	linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux,
	linux-mm
In-Reply-To: <20180323124806.GA5624@bombadil.infradead.org>

On Fri, Mar 23, 2018 at 05:48:06AM -0700, Matthew Wilcox wrote:
> On Thu, Mar 22, 2018 at 07:36:36PM +0300, Ilya Smith wrote:
> > Current implementation doesn't randomize address returned by mmap.
> > All the entropy ends with choosing mmap_base_addr at the process
> > creation. After that mmap build very predictable layout of address
> > space. It allows to bypass ASLR in many cases. This patch make
> > randomization of address on any mmap call.
> 
> Why should this be done in the kernel rather than libc?  libc is perfectly
> capable of specifying random numbers in the first argument of mmap.

Generally libc does not have a view of the current vm maps, and thus
in passing "random numbers", they would have to be uniform across the
whole vm space and thus non-uniform once the kernel rounds up to avoid
existing mappings. Also this would impose requirements that libc be
aware of the kernel's use of the virtual address space and what's
available to userspace -- for example, on 32-bit archs whether 2GB,
3GB, or full 4GB (for 32-bit-user-on-64-bit-kernel) is available, and
on 64-bit archs where fewer than the full 64 bits are actually valid
in addresses, what the actual usable pointer size is. There is
currently no clean way of conveying this information to userspace.

Rich

^ permalink raw reply

* Re: [RFC PATCH v2 0/2] Randomization of address chosen by mmap.
From: Ilya Smith @ 2018-03-23 17:55 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: rth, ink, mattst88, vgupta, linux, tony.luck, fenghua.yu, ralf,
	jejb, Helge Deller, benh, paulus, mpe, schwidefsky,
	heiko.carstens, ysato, dalias, davem, tglx, mingo, hpa, x86, nyc,
	viro, arnd, gregkh, deepa.kernel, Michal Hocko, Hugh Dickins,
	kstewart, pombredanne, Andrew Morton, steve.capper, punit.agrawal,
	aneesh.kumar, npiggin, Kees Cook, bhsharma, riel, nitin.m.gupta,
	Kirill A. Shutemov, Dan Williams, Jan Kara, ross.zwisler,
	Jerome Glisse, Andrea Arcangeli, Oleg Nesterov, linux-alpha, LKML,
	linux-snps-arc, linux-ia64, linux-metag, linux-mips, linux-parisc,
	linuxppc-dev, linux-s390, linux-sh, sparclinux, Linux-MM
In-Reply-To: <20180323124806.GA5624@bombadil.infradead.org>


> On 23 Mar 2018, at 15:48, Matthew Wilcox <willy@infradead.org> wrote:
>=20
> On Thu, Mar 22, 2018 at 07:36:36PM +0300, Ilya Smith wrote:
>> Current implementation doesn't randomize address returned by mmap.
>> All the entropy ends with choosing mmap_base_addr at the process
>> creation. After that mmap build very predictable layout of address
>> space. It allows to bypass ASLR in many cases. This patch make
>> randomization of address on any mmap call.
>=20
> Why should this be done in the kernel rather than libc?  libc is =
perfectly
> capable of specifying random numbers in the first argument of mmap.
Well, there is following reasons:
1. It should be done in any libc implementation, what is not possible =
IMO;
2. User mode is not that layer which should be responsible for choosing
random address or handling entropy;
3. Memory fragmentation is unpredictable in this case

Off course user mode could use random =E2=80=98hint=E2=80=99 address, =
but kernel may
discard this address if it is occupied for example and allocate just =
before
closest vma. So this solution doesn=E2=80=99t give that much security =
like=20
randomization address inside kernel.=

^ permalink raw reply

* Re: [RFC PATCH v2 2/2] Architecture defined limit on memory region random shift.
From: Ilya Smith @ 2018-03-23 17:49 UTC (permalink / raw)
  To: Andrew Morton
  Cc: rth, ink, mattst88, vgupta, linux, tony.luck, fenghua.yu, jhogan,
	ralf, jejb, deller, benh, paulus, mpe, schwidefsky,
	heiko.carstens, ysato, dalias, davem, tglx, mingo, hpa, x86, nyc,
	viro, arnd, gregkh, deepa.kernel, mhocko, hughd, kstewart,
	pombredanne, steve.capper, punit.agrawal, paul.burton,
	aneesh.kumar, npiggin, keescook, bhsharma, riel, nitin.m.gupta,
	kirill.shutemov, dan.j.williams, jack, ross.zwisler, jglisse,
	willy, aarcange, oleg, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-ia64, linux-metag, linux-mips,
	linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux,
	linux-mm
In-Reply-To: <20180322135448.046ada120ecd1ab3dd8f94aa@linux-foundation.org>


> On 22 Mar 2018, at 23:54, Andrew Morton <akpm@linux-foundation.org> =
wrote:
>=20
>=20
> Please add changelogs.  An explanation of what a "limit on memory
> region random shift" is would be nice ;) Why does it exist, why are we
> doing this, etc.  Surely there's something to be said - at present =
this
> is just a lump of random code?
>=20
>=20
>=20
Sorry, my bad. The main idea of this limit is to decrease possible =
memory=20
fragmentation. This is not so big problem on 64bit process, but really =
big for=20
32 bit processes since may cause failure memory allocation. To control =
memory=20
fragmentation and protect 32 bit systems (or architectures) this limit =
was=20
introduce by this patch. It could be also moved to CONFIG_ as well.=

^ permalink raw reply

* Re: [RFC PATCH v2 2/2] Architecture defined limit on memory region random shift.
From: Ilya Smith @ 2018-03-23 17:48 UTC (permalink / raw)
  To: Andrew Morton
  Cc: rth, ink, mattst88, vgupta, linux, tony.luck, fenghua.yu, ralf,
	jejb, Helge Deller, benh, paulus, mpe, schwidefsky,
	heiko.carstens, ysato, dalias, davem, tglx, mingo, hpa, x86, nyc,
	viro, arnd, gregkh, deepa.kernel, Michal Hocko, Hugh Dickins,
	kstewart, pombredanne, steve.capper, punit.agrawal, aneesh.kumar,
	npiggin, Kees Cook, bhsharma, riel, nitin.m.gupta,
	Kirill A. Shutemov, Dan Williams, Jan Kara, ross.zwisler,
	Jerome Glisse, Matthew Wilcox, Andrea Arcangeli, Oleg Nesterov,
	linux-alpha, LKML, linux-snps-arc, linux-ia64, linux-metag,
	linux-mips, linux-parisc, linuxppc-dev, linux-s390, linux-sh,
	sparclinux, Linux-MM
In-Reply-To: <20180322135448.046ada120ecd1ab3dd8f94aa@linux-foundation.org>


[-- Attachment #1.1: Type: text/plain, Size: 727 bytes --]


> On 22 Mar 2018, at 23:54, Andrew Morton <akpm@linux-foundation.org> wrote:
> 
> 
> Please add changelogs.  An explanation of what a "limit on memory
> region random shift" is would be nice ;) Why does it exist, why are we
> doing this, etc.  Surely there's something to be said - at present this
> is just a lump of random code?
> 
Sorry, my bad. The main idea of this limit is to decrease possible memory
fragmentation. This is not so big problem on 64bit process, but really big for
32 bit processes since may cause failure memory allocation. To control memory
fragmentation and protect 32 bit systems (or architectures) this limit was
introduce by this patch. It could be also moved to CONFIG_ as well.



[-- Attachment #1.2: Type: text/html, Size: 2884 bytes --]

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* Re: [PATCH v2 13/38] cxlflash: Support adapter file descriptors for OCXL
From: Uma Krishnan @ 2018-03-23 17:45 UTC (permalink / raw)
  To: Frederic Barrat
  Cc: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
	Manoj N. Kumar, linuxppc-dev, Andrew Donnellan,
	Christophe Lombard
In-Reply-To: <5c799643-e957-79a4-8364-a444181c6f24@linux.vnet.ibm.com>



> On Mar 22, 2018, at 12:12 PM, Frederic Barrat =
<fbarrat@linux.vnet.ibm.com> wrote:
>=20
>=20
>=20
> Le 26/02/2018 =C3=A0 23:21, Uma Krishnan a =C3=A9crit :
>> Allocate a file descriptor for an adapter context when requested. In =
order
>> to allocate inodes for the file descriptors, a pseudo filesystem is =
created
>> and used.
>> Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
>> Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
>> ---
>=20
>=20
> We've touched the subject before, and I don't have a magic solution, =
but it feels like something could be shared here with cxl, or maybe even =
other drivers?
>=20
Yes, perhaps we could look at refactoring in a future series.

> I only took a quick read of the inode allocator.
>=20
>  Fred
>=20
>=20
>=20
>=20
>>  drivers/scsi/cxlflash/ocxl_hw.c | 200 =
++++++++++++++++++++++++++++++++++++++++
>>  drivers/scsi/cxlflash/ocxl_hw.h |   1 +
>>  2 files changed, 201 insertions(+)
>> diff --git a/drivers/scsi/cxlflash/ocxl_hw.c =
b/drivers/scsi/cxlflash/ocxl_hw.c
>> index 6472210..59e9003 100644
>> --- a/drivers/scsi/cxlflash/ocxl_hw.c
>> +++ b/drivers/scsi/cxlflash/ocxl_hw.c
>> @@ -12,13 +12,144 @@
>>   * 2 of the License, or (at your option) any later version.
>>   */
>> +#include <linux/file.h>
>>  #include <linux/idr.h>
>> +#include <linux/module.h>
>> +#include <linux/mount.h>
>>  #include <misc/ocxl.h>
>>  #include "backend.h"
>>  #include "ocxl_hw.h"
>> +/*
>> + * Pseudo-filesystem to allocate inodes.
>> + */
>> +
>> +#define OCXLFLASH_FS_MAGIC      0x1697698f
>> +
>> +static int ocxlflash_fs_cnt;
>> +static struct vfsmount *ocxlflash_vfs_mount;
>> +
>> +static const struct dentry_operations ocxlflash_fs_dops =3D {
>> +	.d_dname	=3D simple_dname,
>> +};
>> +
>> +/*
>> + * ocxlflash_fs_mount() - mount the pseudo-filesystem
>> + * @fs_type:	File system type.
>> + * @flags:	Flags for the filesystem.
>> + * @dev_name:	Device name associated with the filesystem.
>> + * @data:	Data pointer.
>> + *
>> + * Return: pointer to the directory entry structure
>> + */
>> +static struct dentry *ocxlflash_fs_mount(struct file_system_type =
*fs_type,
>> +					 int flags, const char =
*dev_name,
>> +					 void *data)
>> +{
>> +	return mount_pseudo(fs_type, "ocxlflash:", NULL, =
&ocxlflash_fs_dops,
>> +			    OCXLFLASH_FS_MAGIC);
>> +}
>> +
>> +static struct file_system_type ocxlflash_fs_type =3D {
>> +	.name		=3D "ocxlflash",
>> +	.owner		=3D THIS_MODULE,
>> +	.mount		=3D ocxlflash_fs_mount,
>> +	.kill_sb	=3D kill_anon_super,
>> +};
>> +
>> +/*
>> + * ocxlflash_release_mapping() - release the memory mapping
>> + * @ctx:	Context whose mapping is to be released.
>> + */
>> +static void ocxlflash_release_mapping(struct ocxlflash_context *ctx)
>> +{
>> +	if (ctx->mapping)
>> +		simple_release_fs(&ocxlflash_vfs_mount, =
&ocxlflash_fs_cnt);
>> +	ctx->mapping =3D NULL;
>> +}
>> +
>> +/*
>> + * ocxlflash_getfile() - allocate pseudo filesystem, inode, and the =
file
>> + * @dev:	Generic device of the host.
>> + * @name:	Name of the pseudo filesystem.
>> + * @fops:	File operations.
>> + * @priv:	Private data.
>> + * @flags:	Flags for the file.
>> + *
>> + * Return: pointer to the file on success, ERR_PTR on failure
>> + */
>> +static struct file *ocxlflash_getfile(struct device *dev, const char =
*name,
>> +				      const struct file_operations =
*fops,
>> +				      void *priv, int flags)
>> +{
>> +	struct qstr this;
>> +	struct path path;
>> +	struct file *file;
>> +	struct inode *inode =3D NULL;
>> +	int rc;
>> +
>> +	if (fops->owner && !try_module_get(fops->owner)) {
>> +		dev_err(dev, "%s: Owner does not exist\n", __func__);
>> +		rc =3D -ENOENT;
>> +		goto err1;
>> +	}
>> +
>> +	rc =3D simple_pin_fs(&ocxlflash_fs_type, &ocxlflash_vfs_mount,
>> +			   &ocxlflash_fs_cnt);
>> +	if (unlikely(rc < 0)) {
>> +		dev_err(dev, "%s: Cannot mount ocxlflash pseudofs =
rc=3D%d\n",
>> +			__func__, rc);
>> +		goto err2;
>> +	}
>> +
>> +	inode =3D alloc_anon_inode(ocxlflash_vfs_mount->mnt_sb);
>> +	if (IS_ERR(inode)) {
>> +		rc =3D PTR_ERR(inode);
>> +		dev_err(dev, "%s: alloc_anon_inode failed rc=3D%d\n",
>> +			__func__, rc);
>> +		goto err3;
>> +	}
>> +
>> +	this.name =3D name;
>> +	this.len =3D strlen(name);
>> +	this.hash =3D 0;
>> +	path.dentry =3D d_alloc_pseudo(ocxlflash_vfs_mount->mnt_sb, =
&this);
>> +	if (!path.dentry) {
>> +		dev_err(dev, "%s: d_alloc_pseudo failed\n", __func__);
>> +		rc =3D -ENOMEM;
>> +		goto err4;
>> +	}
>> +
>> +	path.mnt =3D mntget(ocxlflash_vfs_mount);
>> +	d_instantiate(path.dentry, inode);
>> +
>> +	file =3D alloc_file(&path, OPEN_FMODE(flags), fops);
>> +	if (IS_ERR(file)) {
>> +		rc =3D PTR_ERR(file);
>> +		dev_err(dev, "%s: alloc_file failed rc=3D%d\n",
>> +			__func__, rc);
>> +		goto err5;
>> +	}
>> +
>> +	file->f_flags =3D flags & (O_ACCMODE | O_NONBLOCK);
>> +	file->private_data =3D priv;
>> +out:
>> +	return file;
>> +err5:
>> +	path_put(&path);
>> +err4:
>> +	iput(inode);
>> +err3:
>> +	simple_release_fs(&ocxlflash_vfs_mount, &ocxlflash_fs_cnt);
>> +err2:
>> +	module_put(fops->owner);
>> +err1:
>> +	file =3D ERR_PTR(rc);
>> +	goto out;
>> +}
>> +
>>  /**
>>   * ocxlflash_set_master() - sets the context as master
>>   * @ctx_cookie:	Adapter context to set as master.
>> @@ -75,6 +206,7 @@ static void *ocxlflash_dev_context_init(struct =
pci_dev *pdev, void *afu_cookie)
>>  	ctx->pe =3D rc;
>>  	ctx->master =3D false;
>> +	ctx->mapping =3D NULL;
>>  	ctx->hw_afu =3D afu;
>>  out:
>>  	return ctx;
>> @@ -100,6 +232,7 @@ static int ocxlflash_release_context(void =
*ctx_cookie)
>>  		goto out;
>>  	idr_remove(&ctx->hw_afu->idr, ctx->pe);
>> +	ocxlflash_release_mapping(ctx);
>>  	kfree(ctx);
>>  out:
>>  	return rc;
>> @@ -262,6 +395,72 @@ static void *ocxlflash_create_afu(struct pci_dev =
*pdev)
>>  	goto out;
>>  }
>> +static const struct file_operations ocxl_afu_fops =3D {
>> +	.owner		=3D THIS_MODULE,
>> +};
>> +
>> +/**
>> + * ocxlflash_get_fd() - get file descriptor for an adapter context
>> + * @ctx_cookie:	Adapter context.
>> + * @fops:	File operations to be associated.
>> + * @fd:		File descriptor to be returned back.
>> + *
>> + * Return: pointer to the file on success, ERR_PTR on failure
>> + */
>> +static struct file *ocxlflash_get_fd(void *ctx_cookie,
>> +				     struct file_operations *fops, int =
*fd)
>> +{
>> +	struct ocxlflash_context *ctx =3D ctx_cookie;
>> +	struct device *dev =3D ctx->hw_afu->dev;
>> +	struct file *file;
>> +	int flags, fdtmp;
>> +	int rc =3D 0;
>> +	char *name =3D NULL;
>> +
>> +	/* Only allow one fd per context */
>> +	if (ctx->mapping) {
>> +		dev_err(dev, "%s: Context is already mapped to an fd\n",
>> +			__func__);
>> +		rc =3D -EEXIST;
>> +		goto err1;
>> +	}
>> +
>> +	flags =3D O_RDWR | O_CLOEXEC;
>> +
>> +	/* This code is similar to anon_inode_getfd() */
>> +	rc =3D get_unused_fd_flags(flags);
>> +	if (unlikely(rc < 0)) {
>> +		dev_err(dev, "%s: get_unused_fd_flags failed rc=3D%d\n",
>> +			__func__, rc);
>> +		goto err1;
>> +	}
>> +	fdtmp =3D rc;
>> +
>> +	/* Use default ops if there is no fops */
>> +	if (!fops)
>> +		fops =3D (struct file_operations *)&ocxl_afu_fops;
>> +
>> +	name =3D kasprintf(GFP_KERNEL, "ocxlflash:%d", ctx->pe);
>> +	file =3D ocxlflash_getfile(dev, name, fops, ctx, flags);
>> +	kfree(name);
>> +	if (IS_ERR(file)) {
>> +		rc =3D PTR_ERR(file);
>> +		dev_err(dev, "%s: ocxlflash_getfile failed rc=3D%d\n",
>> +			__func__, rc);
>> +		goto err2;
>> +	}
>> +
>> +	ctx->mapping =3D file->f_mapping;
>> +	*fd =3D fdtmp;
>> +out:
>> +	return file;
>> +err2:
>> +	put_unused_fd(fdtmp);
>> +err1:
>> +	file =3D ERR_PTR(rc);
>> +	goto out;
>> +}
>> +
>>  /* Backend ops to ocxlflash services */
>>  const struct cxlflash_backend_ops cxlflash_ocxl_ops =3D {
>>  	.module			=3D THIS_MODULE,
>> @@ -271,4 +470,5 @@ const struct cxlflash_backend_ops =
cxlflash_ocxl_ops =3D {
>>  	.release_context	=3D ocxlflash_release_context,
>>  	.create_afu		=3D ocxlflash_create_afu,
>>  	.destroy_afu		=3D ocxlflash_destroy_afu,
>> +	.get_fd			=3D ocxlflash_get_fd,
>>  };
>> diff --git a/drivers/scsi/cxlflash/ocxl_hw.h =
b/drivers/scsi/cxlflash/ocxl_hw.h
>> index 0381682..7abc532 100644
>> --- a/drivers/scsi/cxlflash/ocxl_hw.h
>> +++ b/drivers/scsi/cxlflash/ocxl_hw.h
>> @@ -32,6 +32,7 @@ struct ocxl_hw_afu {
>>  struct ocxlflash_context {
>>  	struct ocxl_hw_afu *hw_afu;	/* HW AFU back pointer */
>> +	struct address_space *mapping;	/* Mapping for pseudo filesystem =
*/
>>  	bool master;			/* Whether this is a master =
context */
>>  	int pe;				/* Process element */
>>  };

^ permalink raw reply

* Re: [RFC PATCH v2 1/2] Randomization of address chosen by mmap.
From: Ilya Smith @ 2018-03-23 17:43 UTC (permalink / raw)
  To: Andrew Morton
  Cc: rth, ink, mattst88, vgupta, linux, tony.luck, fenghua.yu, ralf,
	jejb, Helge Deller, benh, paulus, mpe, schwidefsky,
	heiko.carstens, ysato, dalias, davem, tglx, mingo, hpa, x86, nyc,
	viro, arnd, gregkh, deepa.kernel, Michal Hocko, Hugh Dickins,
	kstewart, pombredanne, steve.capper, punit.agrawal, aneesh.kumar,
	npiggin, Kees Cook, bhsharma, riel, nitin.m.gupta,
	Kirill A. Shutemov, Dan Williams, Jan Kara, ross.zwisler,
	Jerome Glisse, Matthew Wilcox, Andrea Arcangeli, Oleg Nesterov,
	linux-alpha, LKML, linux-snps-arc, linux-ia64, linux-metag,
	linux-mips, linux-parisc, linuxppc-dev, linux-s390, linux-sh,
	sparclinux, Linux-MM
In-Reply-To: <20180322135314.61efce938293e051e118fa46@linux-foundation.org>


> On 22 Mar 2018, at 23:53, Andrew Morton <akpm@linux-foundation.org> =
wrote:
>=20
> On Thu, 22 Mar 2018 19:36:37 +0300 Ilya Smith <blackzert@gmail.com> =
wrote:
>=20
>> include/linux/mm.h |  16 ++++--
>> mm/mmap.c          | 164 =
+++++++++++++++++++++++++++++++++++++++++++++++++++++
>=20
> You'll be wanting to update the documentation.=20
> Documentation/sysctl/kernel.txt and
> Documentation/admin-guide/kernel-parameters.txt.
>=20

Sure, thanks for pointing there. I will add few lines there after =
discussion them
here.

>> ...
>>=20
>> @@ -2268,6 +2276,9 @@ extern unsigned long =
unmapped_area_topdown(struct vm_unmapped_area_info *info);
>> static inline unsigned long
>> vm_unmapped_area(struct vm_unmapped_area_info *info)
>> {
>> +	/* How about 32 bit process?? */
>> +	if ((current->flags & PF_RANDOMIZE) && randomize_va_space > 3)
>> +		return unmapped_area_random(info);
>=20
> The handling of randomize_va_space is peculiar.  Rather than being a
> bitfield which independently selects different modes, it is treated as
> a scalar: the larger the value, the more stuff we randomize.
>=20
> I can see the sense in that (and I wonder what randomize_va_space=3D5
> will do).  But it is...  odd.
>=20
> Why did you select randomize_va_space=3D4 for this?  Is there a mode 3
> already and we forgot to document it?  Or did you leave a gap for
> something?  If the former, please feel free to fix the documentation
> (in a separate, preceding patch) while you're in there ;)
>=20

Yes, I was not sure about correct value so leaved some gap for future. =
Also
according to current implementation this value used like a scalar. But =
I=E2=80=99m
agree bitfield looks more flexible for the future. I think right now I =
can leave
3 as value for my patch and it could be fixed any time in the future. =
What
do you think about it?

>> 	if (info->flags & VM_UNMAPPED_AREA_TOPDOWN)
>> 		return unmapped_area_topdown(info);
>> 	else
>> @@ -2529,11 +2540,6 @@ int drop_caches_sysctl_handler(struct =
ctl_table *, int,
>> void drop_slab(void);
>> void drop_slab_node(int nid);
>>=20
>>=20
>> ...
>>=20
>> @@ -1780,6 +1781,169 @@ unsigned long mmap_region(struct file *file, =
unsigned long addr,
>> 	return error;
>> }
>>=20
>> +unsigned long unmapped_area_random(struct vm_unmapped_area_info =
*info)
>> +{
>=20
> This function is just dead code if CONFIG_MMU=3Dn, yes?  Let's add the
> ifdefs to make it go away in that case.
>=20

Thanks, I missed that case. I will fix it.

>> +	struct mm_struct *mm =3D current->mm;
>> +	struct vm_area_struct *vma =3D NULL;
>> +	struct vm_area_struct *visited_vma =3D NULL;
>> +	unsigned long entropy[2];
>> +	unsigned long length, low_limit, high_limit, gap_start, gap_end;
>> +	unsigned long addr =3D 0;
>> +
>> +	/* get entropy with prng */
>> +	prandom_bytes(&entropy, sizeof(entropy));
>> +	/* small hack to prevent EPERM result */
>> +	info->low_limit =3D max(info->low_limit, mmap_min_addr);
>> +
>>=20
>> ...
>>=20
>> +found:
>> +	/* We found a suitable gap. Clip it with the original =
high_limit. */
>> +	if (gap_end > info->high_limit)
>> +		gap_end =3D info->high_limit;
>> +	gap_end -=3D info->length;
>> +	gap_end -=3D (gap_end - info->align_offset) & info->align_mask;
>> +	/* only one suitable page */
>> +	if (gap_end =3D=3D  gap_start)
>> +		return gap_start;
>> +	addr =3D entropy[1] % (min((gap_end - gap_start) >> PAGE_SHIFT,
>> +							 0x10000UL));
>=20
> What does the magic 10000 mean?  Isn't a comment needed explaining =
this?
>=20
>> +	addr =3D gap_end - (addr << PAGE_SHIFT);
>> +	addr +=3D (info->align_offset - addr) & info->align_mask;
>> +	return addr;
>> +}
>>=20
>> ...
>>=20
>=20

This one what I fix by next patch. I was trying to make patches separate =
to make
it easier to understand them. This constant came from last version =
discussion=20
and honestly doesn=E2=80=99t means much. I replaced it with Architecture =
depended limit
that as I plan would be CONFIG value as well.

This value means maximum number of pages we can move away from the next
vma. The less value means less security but less memory fragmentation. =
Any way
on 64bit systems memory fragmentation is not such a big problem.

^ permalink raw reply

* Re: [RFC PATCH v2 0/2] Randomization of address chosen by mmap.
From: Ilya Smith @ 2018-03-23 17:25 UTC (permalink / raw)
  To: Andrew Morton
  Cc: rth, ink, mattst88, vgupta, linux, tony.luck, fenghua.yu, jhogan,
	ralf, jejb, Helge Deller, benh, paulus, mpe, schwidefsky,
	heiko.carstens, ysato, dalias, davem, tglx, mingo, hpa, x86, nyc,
	viro, arnd, gregkh, deepa.kernel, mhocko, hughd, kstewart,
	pombredanne, steve.capper, punit.agrawal, paul.burton,
	aneesh.kumar, npiggin, keescook, bhsharma, riel, nitin.m.gupta,
	kirill.shutemov, dan.j.williams, jack, ross.zwisler, jglisse,
	willy, aarcange, oleg, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-ia64, linux-metag, linux-mips,
	linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux,
	linux-mm
In-Reply-To: <20180322135729.dbfd3575819c92c0f88c5c21@linux-foundation.org>

Hello, Andrew

Thanks for reading this patch.

> On 22 Mar 2018, at 23:57, Andrew Morton <akpm@linux-foundation.org> =
wrote:
>=20
> On Thu, 22 Mar 2018 19:36:36 +0300 Ilya Smith <blackzert@gmail.com> =
wrote:
>=20
>> Current implementation doesn't randomize address returned by mmap.
>> All the entropy ends with choosing mmap_base_addr at the process
>> creation. After that mmap build very predictable layout of address
>> space. It allows to bypass ASLR in many cases.
>=20
> Perhaps some more effort on the problem description would help.  *Are*
> people predicting layouts at present?  What problems does this cause?=20=

> How are they doing this and are there other approaches to solving the
> problem?
>=20
Sorry, I=E2=80=99ve lost it in first version. In short - memory layout =
could be easily=20
repaired by single leakage. Also any Out of Bounds error may easily be=20=

exploited according to current implementation. All because mmap choose =
address=20
just before previously allocated segment. You can read more about it =
here:=20
http://www.openwall.com/lists/oss-security/2018/02/27/5
Some test are available here https://github.com/blackzert/aslur.=20
To solve the problem Kernel should randomize address on any mmap so
attacker could never easily gain needed addresses.

> Mainly: what value does this patchset have to our users?  This reader
> is unable to determine that from the information which you have
> provided.  Full details, please.

The value of this patch is to decrease successful rate of exploitation
vulnerable applications.These could be either remote or local vectors.

^ permalink raw reply

* Re: [PATCH 4/6] libnvdimm/of: Symlink platform and region devices
From: Dan Williams @ 2018-03-23 17:08 UTC (permalink / raw)
  To: Oliver O'Halloran; +Cc: linux-nvdimm, Device Tree, linuxppc-dev
In-Reply-To: <20180323081209.31387-4-oohall@gmail.com>

On Fri, Mar 23, 2018 at 1:12 AM, Oliver O'Halloran <oohall@gmail.com> wrote:
> Add a way direct link between the region and the platform device that
> creates the region.
>

This linking would not be needed if of_nd_regions each lived on their own bus.

^ permalink raw reply

* Re: [PATCH 3/6] libnvdimm: Add device-tree based driver
From: Dan Williams @ 2018-03-23 17:07 UTC (permalink / raw)
  To: Oliver O'Halloran; +Cc: linux-nvdimm, Device Tree, linuxppc-dev
In-Reply-To: <20180323081209.31387-3-oohall@gmail.com>

On Fri, Mar 23, 2018 at 1:12 AM, Oliver O'Halloran <oohall@gmail.com> wrote:
> This patch adds peliminary device-tree bindings for the NVDIMM driver.

*preliminary

> Currently this only supports one bus (created at probe time) which all
> regions are added to with individual regions being created by a platform
> device driver.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
> I suspect the platform driver should be holding a reference to the
> created region. I left that out here since previously Dan has said
> he'd rather keep the struct device internal to libnvdimm and the only
> other way a region device can disappear is when the bus is unregistered.

Hmm, but this still seems broken if bus teardown races region
teardown. I think the more natural model, given the way libnvdimm is
structured, to have each of these of_nd_region instances create their
own nvdimm bus. Thoughts?

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox