Netdev List
 help / color / mirror / Atom feed
* Re: [net-next 2/8] maintainers: update with official intel support link, new maintainer
From: Joe Perches @ 2012-10-23 13:25 UTC (permalink / raw)
  To: Jeff Kirsher, Tushar Dave
  Cc: davem, Jesse Brandeburg, netdev, gospo, sassmann
In-Reply-To: <1350987887-16161-3-git-send-email-jeffrey.t.kirsher@intel.com>

On Tue, 2012-10-23 at 03:24 -0700, Jeff Kirsher wrote:
> From: Jesse Brandeburg <jesse.brandeburg@intel.com>
> 
> Add an official link which is designed to guide the user to the appropriate
> support resource (be it community, OEM, Intel phone, Intel email, etc)
> 
> Add the current e1000 maintainer to the list of Intel maintainers.

Hi Jeff.

I think it's unwise to have 10 named maintainers for all
the intel ethernet drivers if there are specialists
maintainers.

Maybe it'd be better to break out these sub-maintainers
into specific driver sections with you as the overall
maintainer.

Maybe add an internal exploder to get all the various
maintainers on a list if everyone really looks at all
patches to intel drivers.

Something like:

INTEL ETHERNET DRIVERS
M:	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
M:	Intel Linux Support <linux.drivers@intel.com>
T:	git git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net.git
T:	git git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next.git
S:	Supported
F:	drivers/net/ethernet/intel/

INTEL ETHERNET E1000 DRIVER
M:	Tushar Dave <tushar.n.dave@intel.com>
S:	Supported
F:	drivers/net/ethernet/intel/e1000/
F:	Documentation/networking/e1000.txt

etc...

^ permalink raw reply

* Re: [Pv-drivers] 3.7-rc2 regression : file copied to CIFS-mounted directory corrupted
From: Eric Dumazet @ 2012-10-23 13:50 UTC (permalink / raw)
  To: Shreyas Bhatewara
  Cc: VMware, Inc., netdev, edumazet, linux-kernel, jongman heo
In-Reply-To: <1103939870.6550404.1350986530909.JavaMail.root@vmware.com>

On Tue, 2012-10-23 at 03:02 -0700, Shreyas Bhatewara wrote:

Please dont top post on netdev or lkml

> Well, actually the driver does split large frags into frags of VMXNET3_MAX_TX_BUF_SIZE bytes each.
> 
> vmxnet3_drv.c
>  711         while (len) {
>  712                 u32 buf_size;
>  713
>  714                 if (len < VMXNET3_MAX_TX_BUF_SIZE) {
>  715                         buf_size = len;
>  716                         dw2 |= len;
>  717                 } else {
>  718                         buf_size = VMXNET3_MAX_TX_BUF_SIZE;
>  719                         /* spec says that for TxDesc.len, 0 == 2^14 */
>  720                 }
>  721
> ....
>  743
>  744                 len -= buf_size;
>  745                 buf_offset += buf_size;
>  746         }

Only the skb head is handled in the code you copy/pasted.

You need to generalize that to code in lines ~754


Then, the number of estimated descriptors is bad :

/* conservatively estimate # of descriptors to use */
count = VMXNET3_TXD_NEEDED(skb_headlen(skb)) +
	skb_shinfo(skb)->nr_frags + 1;


Yes, you need a more precise estimation and vmxnet3_map_pkt() should
eventually split too big frags.

^ permalink raw reply

* [PATCH net-next] sockopt: Introduce the SO_BINDTOIFINDEX
From: Pavel Emelyanov @ 2012-10-23 14:21 UTC (permalink / raw)
  To: Brian Haley, Ben Hutchings, Eric Dumazet, Linux Netdev List

Gentlemen,

here's how the symmetrical sk_bound_dev set/get would look like. If it's OK
for you, I would ask David for inclusion.



It was noted that it was not good to have the non-symmetrical SO_BINDTODEVICE
sockoption (set works with name, get reports index) and we'd rather implement
another option to set and get socket bound device that work on ifindex.

The SO_BINDTONETDEV get-er is removed, as getting a device name is tricky and
having one doesn't worth that pain.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>

---
 include/uapi/asm-generic/socket.h |    2 +
 net/core/sock.c                   |   41 ++++++++++++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/include/uapi/asm-generic/socket.h b/include/uapi/asm-generic/socket.h
index b1bea03..c99c843 100644
--- a/include/uapi/asm-generic/socket.h
+++ b/include/uapi/asm-generic/socket.h
@@ -72,4 +72,6 @@
 /* Instruct lower device to use last 4-bytes of skb data as FCS */
 #define SO_NOFCS		43
 
+#define SO_BINDTOIFINDEX	44
+
 #endif /* __ASM_GENERIC_SOCKET_H */
diff --git a/net/core/sock.c b/net/core/sock.c
index c49412c..c4f56e9 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -505,6 +505,39 @@ struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie)
 }
 EXPORT_SYMBOL(sk_dst_check);
 
+static void sock_set_bound_dev(struct sock *sk, int idx)
+{
+	sk->sk_bound_dev_if = idx;
+	sk_dst_reset(sk);
+}
+
+static int sock_bindtoindex(struct sock *sk, int idx)
+{
+	int ret = -ENOPROTOOPT;
+#ifdef CONFIG_NETDEVICES
+	struct net *net = sock_net(sk);
+
+	if (!capable(CAP_NET_RAW))
+		return -EPERM;
+
+	if (idx != 0) {
+		struct net_device *dev;
+
+		rcu_read_lock();
+		dev = dev_get_by_index_rcu(net, idx);
+		rcu_read_unlock();
+		ret = -ENODEV;
+		if (!dev)
+			goto out;
+	}
+
+	sock_set_bound_dev(sk, idx);
+	ret = 0;
+out:
+#endif
+	return ret;
+}
+
 static int sock_bindtodevice(struct sock *sk, char __user *optval, int optlen)
 {
 	int ret = -ENOPROTOOPT;
@@ -550,8 +583,7 @@ static int sock_bindtodevice(struct sock *sk, char __user *optval, int optlen)
 	}
 
 	lock_sock(sk);
-	sk->sk_bound_dev_if = index;
-	sk_dst_reset(sk);
+	sock_set_bound_dev(sk, index);
 	release_sock(sk);
 
 	ret = 0;
@@ -839,6 +871,9 @@ set_rcvbuf:
 	case SO_NOFCS:
 		sock_valbool_flag(sk, SOCK_NOFCS, valbool);
 		break;
+	case SO_BINDTOIFINDEX:
+		ret = sock_bindtoindex(sk, val);
+		break;
 
 	default:
 		ret = -ENOPROTOOPT;
@@ -1074,7 +1109,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
 	case SO_NOFCS:
 		v.val = sock_flag(sk, SOCK_NOFCS);
 		break;
-	case SO_BINDTODEVICE:
+	case SO_BINDTOIFINDEX:
 		v.val = sk->sk_bound_dev_if;
 		break;
 	default:
-- 
1.7.6.5

^ permalink raw reply related

* Re: [RFC PATCH v2 2/6] PM / Runtime: introduce pm_runtime_set_memalloc_noio()
From: Alan Stern @ 2012-10-23 14:46 UTC (permalink / raw)
  To: Ming Lei
  Cc: linux-kernel, Oliver Neukum, Minchan Kim, Greg Kroah-Hartman,
	Rafael J. Wysocki, Jens Axboe, David S. Miller, Andrew Morton,
	netdev, linux-usb, linux-pm, linux-mm
In-Reply-To: <CACVXFVMmszZWHaeNS6LSG4nHR4wWBLwM_BvynRwUW8X=nO+JWA@mail.gmail.com>

On Tue, 23 Oct 2012, Ming Lei wrote:

> On Mon, Oct 22, 2012 at 10:33 PM, Alan Stern <stern@rowland.harvard.edu> wrote:
> >
> > Tail recursion should be implemented as a loop, not as an explicit
> > recursion.  That is, the function should be:
> >
> > void pm_runtime_set_memalloc_noio(struct device *dev, bool enable)
> > {
> >         do {
> >                 dev->power.memalloc_noio_resume = enable;
> >
> >                 if (!enable) {
> >                         /*
> >                          * Don't clear the parent's flag if any of the
> >                          * parent's children have their flag set.
> >                          */
> >                         if (device_for_each_child(dev->parent, NULL,
> >                                           dev_memalloc_noio))
> >                                 return;
> >                 }
> >                 dev = dev->parent;
> >         } while (dev);
> > }
> 
> OK, will take the non-recursion implementation for saving kernel
> stack space.
> 
> >
> > except that you need to add locking, for two reasons:
> >
> >         There's a race.  What happens if another child sets the flag
> >         between the time device_for_each_child() runs and the next loop
> >         iteration?
> 
> Yes, I know the race, and not adding a lock because the function
> is mostly called in .probe() or .remove() callback and its parent's device
> lock is held to avoid this race.
> 
> Considered that it may be called in async probe() (scsi disk), one lock
> is needed, the simplest way is to add a global lock. Any suggestion?

No.  Because of where you put the new flag, it must be protected by
dev->power.lock.  And this means the iterative implementation shown
above can't be used as is.  It will have to be more like this:

void pm_runtime_set_memalloc_noio(struct device *dev, bool enable)
{
	spin_lock_irq(&dev->power.lock);
	dev->power.memalloc_noio_resume = enable;

	while (dev->parent) {
		spin_unlock_irq(&dev->power.lock);
		dev = dev->parent;

		spin_lock_irq(&dev->power.lock);
		/*
		 * Don't clear the parent's flag if any of the
		 * parent's children have their flag set.
		 */
		if (!enable && device_for_each_child(dev->parent, NULL,
				dev_memalloc_noio))
			break;
		dev->power.memalloc_noio_resume = enable;
	}
	spin_unlock_irq(&dev->power.lock);
}

> >         Even without a race, access to bitfields is not SMP-safe
> >         without locking.
> 
> You mean one ancestor device might not be in active when
> one of its descendants is being probed or removed?

No.  Consider this example:

	struct foo {
		int a:1;
		int b:1;
	} x;

Consider what happens if CPU 0 does "x.a = 1" at the same time as 
another CPU 1 does "x.b = 1".  The compiler might produce object code 
looking like this for CPU 0:

	move	x, reg1
	or	0x1, reg1
	move	reg1, x

and this for CPU 1:

	move	x, reg2
	or	0x2, reg2
	move	reg2, x

With no locking, the two "or" instructions could execute 
simultaneously.  What will the final value of x be?

The two CPUs will interfere, even though they are touching different 
bitfields.

Alan Stern

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply

* Re: [PATCH net-next 06/15] 6lowpan: fix first fragment (FRAG1)  handling
From: Tony Cheneau @ 2012-10-23 14:50 UTC (permalink / raw)
  To: Jan Ceuleers
  Cc: David S. Miller, netdev, linux-zigbee-devel, Alan Ott,
	Alexander Smirnov
In-Reply-To: <5086450A.9050506@computer.org>

Hello Jan,

Thank you for all your comments. See my answer inline.

Le 23.10.2012 09:19, Jan Ceuleers a écrit :
> On 10/23/2012 06:09 AM, Tony Cheneau wrote:
>> The first fragment, FRAG1, must contain some payload according to 
>> the
>> specs. However, as it is currently written, the first fragment will
>> remain empty and only contain the 6lowpan headers.
>>
>> This patch also extract the transport layer information from the 
>> first
>> fragment. This information is later on use when uncompressing UDP
>> header.
>>
>> Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org>
>> ---
>>  net/ieee802154/6lowpan.c |   54 
>> +++++++++++++++++++++++++++++++++++----------
>>  1 files changed, 42 insertions(+), 12 deletions(-)
>>
>> diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
>> index 8a2ee95..38cecaf 100644
>> --- a/net/ieee802154/6lowpan.c
>> +++ b/net/ieee802154/6lowpan.c
>> @@ -654,7 +654,7 @@ static void 
>> lowpan_fragment_timer_expired(unsigned long entry_addr)
>>  }
>>
>>  static struct lowpan_fragment *
>> -lowpan_alloc_new_frame(struct sk_buff *skb, u8 len, u16 tag)
>> +lowpan_alloc_new_frame(struct sk_buff *skb, u16 len, u16 tag)
>>  {
>>  	struct lowpan_fragment *frame;
>>
>> @@ -735,6 +735,18 @@ lowpan_process_data(struct sk_buff *skb)
>>  		/* adds the 3 MSB to the 8 LSB to retrieve the 11 bits length */
>>  		len = ((iphc0 & 7) << 8) | slen;
>>
>> +		if ((iphc0 & LOWPAN_DISPATCH_MASK) == LOWPAN_DISPATCH_FRAG1) {
>> +			pr_debug("%s received a FRAG1 packet (tag: %d, "
>> +				 "size of the entire IP packet: %d)"
>> +				 , __func__, tag, len);
>
> There are several schools of thought on the relative importance of
> observing the 80-character line limit versus breaking up string
> constants (in an attempt to maintain grepability). I think the above 
> is
> fine but others (whose opinion matters more than mine) may or may not
> agree. Whatever you decide here, please apply consistently 
> throughout.
Yes, I've seen that particular issues when running checkpatch.pl. I 
decided to break down line, but I can easily be convinced to do things 
differently. Anyway, I'll make sure that all my patches are consistent 
in breaking up string after 80 characters the same way.

> However, the comma ahead of the __func__ should be at the end of the
> previous line.
Will do.

>
>> -	/* if payload length is zero, therefore it's a first fragment */
>> -	hlen = (plen == 0 ? LOWPAN_FRAG1_HEAD_SIZE :  
>> LOWPAN_FRAGN_HEAD_SIZE);
>> +	hlen = (type == LOWPAN_DISPATCH_FRAG1 ? LOWPAN_FRAG1_HEAD_SIZE :
>> +			LOWPAN_FRAGN_HEAD_SIZE);
>
> The second line of this statement should be aligned as follows:
>
> +	hlen = (type == LOWPAN_DISPATCH_FRAG1 ? LOWPAN_FRAG1_HEAD_SIZE :
> +		LOWPAN_FRAGN_HEAD_SIZE);
>
> So the L for LOWPAN_FRAGN_HEAD_SIZE should be underneath the t for 
> type.
Will do as well.

Again, thank you for all your detailed comments.

Regards,
Tony

^ permalink raw reply

* [PATCH] pch_gbe: fix error handling in pch_gbe_up()
From: Veaceslav Falico @ 2012-10-23 14:54 UTC (permalink / raw)
  To: netdev; +Cc: davem, richardcochran, tshimizu818, andy.cress, erwan.velu

If we fail to allocate rx buffers pool by any reason, we'll just return
with an error, however we've previously successfully requested an irq. Fix
this by releasing the irq before returning the error.

Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index b2a94d0..876ea9f 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -1971,12 +1971,12 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
 	struct net_device *netdev = adapter->netdev;
 	struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring;
 	struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring;
-	int err;
+	int err = -EINVAL;
 
 	/* Ensure we have a valid MAC */
 	if (!is_valid_ether_addr(adapter->hw.mac.addr)) {
 		pr_err("Error: Invalid MAC address\n");
-		return -EINVAL;
+		goto out;
 	}
 
 	/* hardware has been reset, we need to reload some things */
@@ -1989,13 +1989,13 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
 
 	err = pch_gbe_request_irq(adapter);
 	if (err) {
-		pr_err("Error: can't bring device up\n");
-		return err;
+		pr_err("Error: can't bring device up - irq request failed\n");
+		goto out;
 	}
 	err = pch_gbe_alloc_rx_buffers_pool(adapter, rx_ring, rx_ring->count);
 	if (err) {
-		pr_err("Error: can't bring device up\n");
-		return err;
+		pr_err("Error: can't bring device up - alloc rx buffers pool failed\n");
+		goto freeirq;
 	}
 	pch_gbe_alloc_tx_buffers(adapter, tx_ring);
 	pch_gbe_alloc_rx_buffers(adapter, rx_ring, rx_ring->count);
@@ -2009,6 +2009,11 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
 	netif_start_queue(adapter->netdev);
 
 	return 0;
+
+freeirq:
+	pch_gbe_free_irq(adapter);
+out:
+	return err;
 }
 
 /**
-- 
1.7.1

^ permalink raw reply related

* Re: [PATCH net-next 01/15] 6lowpan: lowpan_is_iid_16_bit_compressable() does not detect compressable address correctly
From: Tony Cheneau @ 2012-10-23 14:57 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-zigbee-devel, alan, alex.bluesman.smirnov
In-Reply-To: <20121023.024945.1428104116658345802.davem@davemloft.net>

Hello David,

Le 23.10.2012 08:49, David Miller a écrit :
[...]
>
> It's really demoralizing to sit down to read a large 15 entry
> patch series and this is the first thing I see:
>
>>  /*
>> - * check whether we can compress the IID to 16 bits,
>> - * it's possible for unicast adresses with first 49 bits are zero 
>> only.
>> - */
>> +* check whether we can compress the IID to 16 bits,
>> +* it's possible for unicast adresses with first 49 bits are zero 
>> only.
>> +*/
>
> Don't break the comment indentation, it was perfectly fine.
>
> I'm not reviewing the rest of the series, you'll need to repost
> the entire thing after you fix this.
>
> And if you're smart you'll make sure there aren't similar coding
> style issues in the rest of your patches, else it's going to take
> a long time to merge this crap into the tree.

Sorry about that, I failed to catch that mistake of mine (and several 
other ones that Jan spotted). I'll rework my patchset and resubmit. 
Thank you for pointing out this issue.

Regards,
Tony

^ permalink raw reply

* Re: [PATCH net-next 06/15] 6lowpan: fix first fragment (FRAG1) handling
From: Eric Dumazet @ 2012-10-23 15:03 UTC (permalink / raw)
  To: Tony Cheneau
  Cc: Jan Ceuleers, David S. Miller, netdev, linux-zigbee-devel,
	Alan Ott, Alexander Smirnov
In-Reply-To: <1bf85bdd4343fe738d15ee74a65578d5@amnesiak.org>

On Tue, 2012-10-23 at 16:50 +0200, Tony Cheneau wrote:

> >
> > +	hlen = (type == LOWPAN_DISPATCH_FRAG1 ? LOWPAN_FRAG1_HEAD_SIZE :
> > +		LOWPAN_FRAGN_HEAD_SIZE);
> >
> > So the L for LOWPAN_FRAGN_HEAD_SIZE should be underneath the t for 
> > type.
> Will do as well.

By the way parens are not needed, or better like that :

	hlen = (type == LOWPAN_DISPATCH_FRAG1) ?
			LOWPAN_FRAG1_HEAD_SIZE : LOWPAN_FRAGN_HEAD_SIZE;

^ permalink raw reply

* Re: [RFC PATCH v2 2/6] PM / Runtime: introduce pm_runtime_set_memalloc_noio()
From: Ming Lei @ 2012-10-23 15:18 UTC (permalink / raw)
  To: Alan Stern
  Cc: linux-kernel, Oliver Neukum, Minchan Kim, Greg Kroah-Hartman,
	Rafael J. Wysocki, Jens Axboe, David S. Miller, Andrew Morton,
	netdev, linux-usb, linux-pm, linux-mm
In-Reply-To: <Pine.LNX.4.44L0.1210231022230.1635-100000@iolanthe.rowland.org>

On Tue, Oct 23, 2012 at 10:46 PM, Alan Stern <stern@rowland.harvard.edu> wrote:
> On Tue, 23 Oct 2012, Ming Lei wrote:
>
>> On Mon, Oct 22, 2012 at 10:33 PM, Alan Stern <stern@rowland.harvard.edu> wrote:
>> >
>> > Tail recursion should be implemented as a loop, not as an explicit
>> > recursion.  That is, the function should be:
>> >
>> > void pm_runtime_set_memalloc_noio(struct device *dev, bool enable)
>> > {
>> >         do {
>> >                 dev->power.memalloc_noio_resume = enable;
>> >
>> >                 if (!enable) {
>> >                         /*
>> >                          * Don't clear the parent's flag if any of the
>> >                          * parent's children have their flag set.
>> >                          */
>> >                         if (device_for_each_child(dev->parent, NULL,
>> >                                           dev_memalloc_noio))
>> >                                 return;
>> >                 }
>> >                 dev = dev->parent;
>> >         } while (dev);
>> > }
>>
>> OK, will take the non-recursion implementation for saving kernel
>> stack space.
>>
>> >
>> > except that you need to add locking, for two reasons:
>> >
>> >         There's a race.  What happens if another child sets the flag
>> >         between the time device_for_each_child() runs and the next loop
>> >         iteration?
>>
>> Yes, I know the race, and not adding a lock because the function
>> is mostly called in .probe() or .remove() callback and its parent's device
>> lock is held to avoid this race.
>>
>> Considered that it may be called in async probe() (scsi disk), one lock
>> is needed, the simplest way is to add a global lock. Any suggestion?
>
> No.  Because of where you put the new flag, it must be protected by
> dev->power.lock.  And this means the iterative implementation shown
> above can't be used as is.  It will have to be more like this:
>
> void pm_runtime_set_memalloc_noio(struct device *dev, bool enable)
> {
>         spin_lock_irq(&dev->power.lock);
>         dev->power.memalloc_noio_resume = enable;
>
>         while (dev->parent) {
>                 spin_unlock_irq(&dev->power.lock);
>                 dev = dev->parent;
>
>                 spin_lock_irq(&dev->power.lock);
>                 /*
>                  * Don't clear the parent's flag if any of the
>                  * parent's children have their flag set.
>                  */
>                 if (!enable && device_for_each_child(dev->parent, NULL,

s/dev->parent/dev

>                                 dev_memalloc_noio))
>                         break;
>                 dev->power.memalloc_noio_resume = enable;
>         }
>         spin_unlock_irq(&dev->power.lock);
> }

With the problem of non-SMP-safe bitfields access, the power.lock should
be held, but that is not enough to prevent children from being probed or
disconnected. Looks another lock is still needed. I think a global lock
is OK in the infrequent path.

>
>> >         Even without a race, access to bitfields is not SMP-safe
>> >         without locking.
>>
>> You mean one ancestor device might not be in active when
>> one of its descendants is being probed or removed?
>
> No.  Consider this example:
>
>         struct foo {
>                 int a:1;
>                 int b:1;
>         } x;
>
> Consider what happens if CPU 0 does "x.a = 1" at the same time as
> another CPU 1 does "x.b = 1".  The compiler might produce object code
> looking like this for CPU 0:
>
>         move    x, reg1
>         or      0x1, reg1
>         move    reg1, x
>
> and this for CPU 1:
>
>         move    x, reg2
>         or      0x2, reg2
>         move    reg2, x
>
> With no locking, the two "or" instructions could execute
> simultaneously.  What will the final value of x be?
>
> The two CPUs will interfere, even though they are touching different
> bitfields.

Got it, thanks for your detailed explanation.

Looks the problem is worse than above, not only bitfields are affected, the
adjacent fields might be involved too, see:

           http://lwn.net/Articles/478657/


Thanks,
--
Ming Lei

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply

* [PATCH]ipv6: Add an ICMP error handler icmpv6_err
From: Duan Jiong @ 2012-10-23 15:24 UTC (permalink / raw)
  To: davem; +Cc: netdev


Add an ICMP error handler icmpv6_err to deal with ICMPV6 Error
Messages and Redirect Message, when we do not have a socket
context.

Signed-off-by: Duan Jiong <djduanjiong@gmail.com>
---
 net/ipv6/icmp.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 24d69db..d3cb61d 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -82,9 +82,12 @@ static inline struct sock *icmpv6_sk(struct net *net)
 }
 
 static int icmpv6_rcv(struct sk_buff *skb);
+static void icmpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
+			u8 type, u8 code, int offset, __be32 info);
 
 static const struct inet6_protocol icmpv6_protocol = {
 	.handler	=	icmpv6_rcv,
+	.err_handler	=	icmpv6_err,
 	.flags		=	INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
 };
 
@@ -782,6 +785,26 @@ drop_no_count:
 	return 0;
 }
 
+static void icmpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
+			u8 type, u8 code, int offset, __be32 info)
+{
+	struct net *net = dev_net(skb->dev);
+	struct icmp6hdr *hdr = icmp6_hdr(skb);
+
+	switch (hdr->icmp6_type) {
+	case ICMPV6_PKT_TOOBIG:
+		ip6_update_pmtu(skb, net, info, 0, 0);
+		break;
+
+	case NDISC_REDIRECT:
+		ip6_redirect(skb, net, 0, 0);
+		break;
+
+	default:
+		break;
+	}
+}
+
 void icmpv6_flow_init(struct sock *sk, struct flowi6 *fl6,
 		      u8 type,
 		      const struct in6_addr *saddr,
-- 
1.7.11.4

^ permalink raw reply related

* [PATCH] ipv6: fix the bug when propagating Redirect Message
From: Duan Jiong @ 2012-10-23 15:26 UTC (permalink / raw)
  To: davem; +Cc: netdev


Before using icmpv6_notify() to propagate redirect, change skb->data
to poing the IP packet that triggered the sending of the Redirect.

Signed-off-by: Duan Jiong <djduanjiong@gmail.com>
---
 net/ipv6/ndisc.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index ff36194..0f73303 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1334,6 +1334,11 @@ out:
 
 static void ndisc_redirect_rcv(struct sk_buff *skb)
 {
+	int opt_len;
+	int opt_offset;
+	int ndisc_head_len;
+	struct nd_opt_hdr *nd_opt;
+	
 #ifdef CONFIG_IPV6_NDISC_NODETYPE
 	switch (skb->ndisc_nodetype) {
 	case NDISC_NODETYPE_HOST:
@@ -1350,6 +1355,40 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 		return;
 	}
 
+	ndisc_head_len = sizeof(struct icmp6hdr) + 2*sizeof(struct in6_addr);
+	if (!pskb_may_pull(skb, ndisc_head_len)) {
+		return;
+	}
+
+	nd_opt = (struct nd_opt_hdr *)(skb->data + ndisc_head_len);
+
+	opt_len = skb->tail - skb->transport_header - ndisc_head_len;
+	if (opt_len < 0) {
+		return;
+	}
+	while (opt_len) {
+		int l;
+	
+		if (opt_len < sizeof(struct nd_opt_hdr)) {
+			return;
+		}
+		l = nd_opt->nd_opt_len << 3;
+		if (opt_len < l || l == 0) {
+			return;
+		}
+		if (nd_opt->nd_opt_type == ND_OPT_REDIRECT_HDR) {
+			__skb_pull(skb, ndisc_head_len + opt_offset + 8);
+			break;
+		}
+		opt_len -= l;
+		nd_opt = ((void *)nd_opt) + 1;
+		opt_offset += 1;
+	}
+	
+	if (opt_len == 0) {
+		return;
+	}	
+
 	icmpv6_notify(skb, NDISC_REDIRECT, 0, 0);
 }
 
-- 
1.7.4.4

^ permalink raw reply related

* [PATCH net-next] tcp: fix rcv_ssthresh regression for medium-sized initial packets
From: Neal Cardwell @ 2012-10-23 15:35 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Eric Dumazet, Neal Cardwell

The recent skb truesize fixes caused a slight regression in that
moderately-sized initial incoming packets (eg ~1000 bytes) can now
lead to smaller rcv_ssthresh increments than in 2.6.

The mitigation b49960a05e32121d ("tcp: change tcp_adv_win_scale and
tcp_rmem[2]") compensates for the truesize fixes by fixing the
ultimate value to which receive window converges. But this commit did
not mitigate the impact for the initial cwnd growth phase for
connetions with moderately-sized initial incoming packets. Such
connections still hit the __tcp_grow_window() code path, where the
increment to rcv_sssthresh was by rcv_mss, and not the generally
larger advmss.

We should not handicap this initial growth rate of the receive
window. That way short connections are not penalized in cases where
they wouldn't lead to receive buffer memory consumption issues.

Signed-off-by: Neal Cardwell <ncardwell@google.com>
CC: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp_input.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 60cf836..e5981a3 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -316,7 +316,7 @@ static int __tcp_grow_window(const struct sock *sk, const struct sk_buff *skb)
 
 	while (tp->rcv_ssthresh <= window) {
 		if (truesize <= skb->len)
-			return 2 * inet_csk(sk)->icsk_ack.rcv_mss;
+			return 2 * tp->advmss;
 
 		truesize >>= 1;
 		window >>= 1;
-- 
1.7.7.3

^ permalink raw reply related

* RE: [net-next 1/8] e1000e: Minimum packet size must be 17 bytes
From: David Laight @ 2012-10-23 15:25 UTC (permalink / raw)
  To: Jeff Kirsher, davem; +Cc: Tushar Dave, netdev, gospo, sassmann
In-Reply-To: <1350987887-16161-2-git-send-email-jeffrey.t.kirsher@intel.com>

> This is a HW requirement. Although a buffer as short as 1 byte is allowed,
> the total length of packet before, padding and CRC insertion, must be at
> least 17 bytes.  So pad all small packets manually up to 17 bytes before
> delivering them to HW.

Where do such very short packets come from?
The shortest one I know of have:
 6 bytes dest-mac
 6 bytes src-mac
 2 bytes length
 3 bytes llc header (eg reflect request).
17 bytes total.

	David

^ permalink raw reply

* Re: [PATCH v6 01/10] ipc: remove forced assignment of selected message
From: Serge Hallyn @ 2012-10-23 15:54 UTC (permalink / raw)
  To: Stanislav Kinsbursky
  Cc: akpm, catalin.marinas, will.deacon, dhowells, manfred, hughd,
	jmorris, mtk.manpages, kosaki.motohiro, paulmck, sds, devel,
	a.p.zijlstra, cmetcalf, linux-driver, ron.mercer, viro, eparis,
	tglx, jitendra.kalsaria, netdev, linux-kernel,
	linux-security-module, ebiederm, casey
In-Reply-To: <20121015155941.28348.88481.stgit@localhost.localdomain>

Quoting Stanislav Kinsbursky (skinsbursky@parallels.com):
> This is a cleanup patch. The assignment is redundant.
> 
> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>

Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

> ---
>  ipc/msg.c |    5 +----
>  1 files changed, 1 insertions(+), 4 deletions(-)
> 
> diff --git a/ipc/msg.c b/ipc/msg.c
> index a71af5a..2f272fa 100644
> --- a/ipc/msg.c
> +++ b/ipc/msg.c
> @@ -793,12 +793,9 @@ long do_msgrcv(int msqid, long *pmtype, void __user *mtext,
>  				msg = walk_msg;
>  				if (mode == SEARCH_LESSEQUAL &&
>  						walk_msg->m_type != 1) {
> -					msg = walk_msg;
>  					msgtyp = walk_msg->m_type - 1;
> -				} else {
> -					msg = walk_msg;
> +				} else
>  					break;
> -				}
>  			}
>  			tmp = tmp->next;
>  		}
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH net-next] tcp: fix rcv_ssthresh regression for medium-sized initial packets
From: Eric Dumazet @ 2012-10-23 15:57 UTC (permalink / raw)
  To: Neal Cardwell; +Cc: David Miller, netdev, Eric Dumazet
In-Reply-To: <1351006545-12556-1-git-send-email-ncardwell@google.com>

On Tue, 2012-10-23 at 11:35 -0400, Neal Cardwell wrote:
> The recent skb truesize fixes caused a slight regression in that
> moderately-sized initial incoming packets (eg ~1000 bytes) can now
> lead to smaller rcv_ssthresh increments than in 2.6.
> 
> The mitigation b49960a05e32121d ("tcp: change tcp_adv_win_scale and
> tcp_rmem[2]") compensates for the truesize fixes by fixing the
> ultimate value to which receive window converges. But this commit did
> not mitigate the impact for the initial cwnd growth phase for
> connetions with moderately-sized initial incoming packets. Such
> connections still hit the __tcp_grow_window() code path, where the
> increment to rcv_sssthresh was by rcv_mss, and not the generally
> larger advmss.
> 
> We should not handicap this initial growth rate of the receive
> window. That way short connections are not penalized in cases where
> they wouldn't lead to receive buffer memory consumption issues.
> 
> Signed-off-by: Neal Cardwell <ncardwell@google.com>
> CC: Eric Dumazet <edumazet@google.com>
> ---
>  net/ipv4/tcp_input.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 60cf836..e5981a3 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -316,7 +316,7 @@ static int __tcp_grow_window(const struct sock *sk, const struct sk_buff *skb)
>  
>  	while (tp->rcv_ssthresh <= window) {
>  		if (truesize <= skb->len)
> -			return 2 * inet_csk(sk)->icsk_ack.rcv_mss;
> +			return 2 * tp->advmss;
>  
>  		truesize >>= 1;
>  		window >>= 1;

But this defeats whole point of having a small initial window and
increase it if packets are 'good citizens' ?

Are you sure we wont drop packets later because we hit sk->sk_rcvbuf
limit ?

This brings back the receiver initial window we discussed lately.

Because if we had an initial window of 32KB or 64KB instead of 10*1460,
I am pretty sure we would not have to change this code ?

Thanks

^ permalink raw reply

* Re: [PATCH] vlan: set sysfs device_type to 'vlan'
From: Ben Greear @ 2012-10-23 16:14 UTC (permalink / raw)
  To: David Miller; +Cc: cardoe, kaber, netdev, systemd-devel, linux-kernel
In-Reply-To: <20121023.023647.2164665243829038911.davem@davemloft.net>

On 10/22/2012 11:36 PM, David Miller wrote:
> From: Doug Goldstein <cardoe@cardoe.com>
> Date: Mon, 22 Oct 2012 00:53:57 -0500
>
>> Sets the sysfs device_type to 'vlan' for udev. This makes it easier for
>> applications that query network information via udev to identify vlans
>> instead of using strrchr().
>>
>> Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
>
> You're extremely misguided.  This change, in fact, makes it ten times
> harder for such applications to query such devices.

If the application doesn't care, it can use the old way (which at least
for me, involves string-comparing the driver name ethtool returns, which
sucks at best).

And applications that care might suddenly have more features, or be more
efficient when running on newer kernels..

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply

* [PATCH net-next 0/3] Report socket shutdown state via sock-diag
From: Pavel Emelyanov @ 2012-10-23 16:18 UTC (permalink / raw)
  To: Linux Netdev List, David Miller

The sk->sk_shutdown mask (set by sys_shutdown) cannot be read from
the user space. I suppose that the best API to report it is the
recently added sock-diag one (as we can use it not only in the
checkpoint-restore project, but also enhance the ss output with the
shutdown info).

However, there's one issue with the inet-diag part of it -- we've
run out of bits on the extension flags of dump request. This one is
addressed in the patch #2.

Thanks,
Pavel

^ permalink raw reply

* Re: [PATCH v6 03/10] ipc: segment key change helper introduced
From: Serge Hallyn @ 2012-10-23 16:19 UTC (permalink / raw)
  To: Stanislav Kinsbursky
  Cc: akpm, catalin.marinas, will.deacon, dhowells, manfred, hughd,
	jmorris, mtk.manpages, kosaki.motohiro, paulmck, sds, devel,
	a.p.zijlstra, cmetcalf, linux-driver, ron.mercer, viro, eparis,
	tglx, jitendra.kalsaria, netdev, linux-kernel,
	linux-security-module, ebiederm, casey
In-Reply-To: <20121015155951.28348.65427.stgit@localhost.localdomain>

Quoting Stanislav Kinsbursky (skinsbursky@parallels.com):
> This patch introduces existent segment key changing infrastructure.
> New function ipc_update_key() can be used change segment key, cuid, cgid
> values. It checks for that new key is not used (except IPC_PRIVATE) prior to
> set it on existent.
> To make this possible, added copying of this fields from user-space in
> __get_compat_ipc_perm() and __get_compat_ipc64_perm() functions. Also segment
> search by key and lock were splitted into different functions, because
> ipc_update_key() doesn't need to lock the segment during check that new key is
> not used.
> 
> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>

Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

> ---
>  ipc/compat.c |    6 ++++++
>  ipc/util.c   |   51 ++++++++++++++++++++++++++++++++++++++++++++++++---
>  ipc/util.h   |    2 ++
>  3 files changed, 56 insertions(+), 3 deletions(-)
> 
> diff --git a/ipc/compat.c b/ipc/compat.c
> index ad9518e..af30d13 100644
> --- a/ipc/compat.c
> +++ b/ipc/compat.c
> @@ -144,6 +144,9 @@ static inline int __get_compat_ipc64_perm(struct ipc64_perm *p64,
>  	err  = __get_user(p64->uid, &up64->uid);
>  	err |= __get_user(p64->gid, &up64->gid);
>  	err |= __get_user(p64->mode, &up64->mode);
> +	err |= __get_user(p64->cuid, &up64->cuid);
> +	err |= __get_user(p64->cgid, &up64->cgid);
> +	err |= __get_user(p64->key, &up64->key);
>  	return err;
>  }
>  
> @@ -155,6 +158,9 @@ static inline int __get_compat_ipc_perm(struct ipc64_perm *p,
>  	err  = __get_user(p->uid, &up->uid);
>  	err |= __get_user(p->gid, &up->gid);
>  	err |= __get_user(p->mode, &up->mode);
> +	err |= __get_user(p->cuid, &up->cuid);
> +	err |= __get_user(p->cgid, &up->cgid);
> +	err |= __get_user(p->key, &up->key);
>  	return err;
>  }
>  
> diff --git a/ipc/util.c b/ipc/util.c
> index 503946e..faae296 100644
> --- a/ipc/util.c
> +++ b/ipc/util.c
> @@ -173,7 +173,7 @@ void __init ipc_init_proc_interface(const char *path, const char *header,
>   *	@key: The key to find
>   *	
>   *	Requires ipc_ids.rw_mutex locked.
> - *	Returns the LOCKED pointer to the ipc structure if found or NULL
> + *	Returns the UNLOCKED pointer to the ipc structure if found or NULL
>   *	if not.
>   *	If key is found ipc points to the owning ipc structure
>   */
> @@ -195,7 +195,6 @@ static struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key)
>  			continue;
>  		}
>  
> -		ipc_lock_by_ptr(ipc);
>  		return ipc;
>  	}
>  
> @@ -203,6 +202,27 @@ static struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key)
>  }
>  
>  /**
> + *	ipc_findkey_locked	-	find and lock a key in an ipc identifier set
> + *	@ids: Identifier set
> + *	@key: The key to find
> + *
> + *	Requires ipc_ids.rw_mutex locked.
> + *	Returns the LOCKED pointer to the ipc structure if found or NULL
> + *	if not.
> + *	If key is found ipc points to the owning ipc structure
> + */
> +
> +static struct kern_ipc_perm *ipc_findkey_locked(struct ipc_ids *ids, key_t key)
> +{
> +	struct kern_ipc_perm *ipc;
> +
> +	ipc = ipc_findkey(ids, key);
> +	if (ipc)
> +		ipc_lock_by_ptr(ipc);
> +	return ipc;
> +}
> +
> +/**
>   *	ipc_get_maxid 	-	get the last assigned id
>   *	@ids: IPC identifier set
>   *
> @@ -388,7 +408,7 @@ retry:
>  	 * a new entry + read locks are not "upgradable"
>  	 */
>  	down_write(&ids->rw_mutex);
> -	ipcp = ipc_findkey(ids, params->key);
> +	ipcp = ipc_findkey_locked(ids, params->key);
>  	if (ipcp == NULL) {
>  		/* key not used */
>  		if (!(flg & IPC_CREAT))
> @@ -755,6 +775,31 @@ int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids,
>  }
>  
>  /**
> + * ipc_update_key - update the key of an IPC.
> + * @in:  the permission given as input.
> + * @out: the permission of the ipc to set.
> + *
> + * Common routine called by sys_shmctl(), sys_semctl(). sys_msgctl().
> + */
> +int ipc_update_key(struct ipc_ids *ids, struct ipc64_perm *in,
> +		    struct kern_ipc_perm *out)
> +{
> +
> +	if (in->key && out->key != in->key) {
> +		/*
> +		 * Check for existent segment with the same key.
> +		 * Note: ipc_ids.rw_mutex is taken for write already.
> +		 */
> +		if (ipc_findkey(ids, in->key))
> +			return -EEXIST;
> +	}
> +	out->cuid = in->cuid;
> +	out->cgid = in->cgid;
> +	out->key = in->key;
> +	return 0;
> +}
> +
> +/**
>   * ipc_update_perm - update the permissions of an IPC.
>   * @in:  the permission given as input.
>   * @out: the permission of the ipc to set.
> diff --git a/ipc/util.h b/ipc/util.h
> index 3a9e558..271bded 100644
> --- a/ipc/util.h
> +++ b/ipc/util.h
> @@ -126,6 +126,8 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *, int);
>  
>  void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out);
>  void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out);
> +int ipc_update_key(struct ipc_ids *ids, struct ipc64_perm *in,
> +		   struct kern_ipc_perm *out);
>  int ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out);
>  struct kern_ipc_perm *ipcctl_pre_down(struct ipc_namespace *ns,
>  				      struct ipc_ids *ids, int id, int cmd,
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 1/3] sk: Introduce the shutdown user-to-mask routine
From: Pavel Emelyanov @ 2012-10-23 16:22 UTC (permalink / raw)
  To: Linux Netdev List, David Miller
In-Reply-To: <5086C36B.6060508@parallels.com>

The sys_shutdown "how" argument is converted into kernel-side mask
with a trick -- the "how++" does proper bits conversion. And since
this is a trick, it's commented in the respective places.

When there will be sk_shutdown reporting mechanism it will be natural
to report not the kernel-side mask, but the values known by userspace
(this "how" thing), i.e. we'll have to do the reciprocal trick.

I propose to encapsulate both tricks in helpers, here's the user to
kernel one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
---
 include/net/sock.h |   18 ++++++++++++++++++
 net/ipv4/af_inet.c |    7 +++----
 net/iucv/af_iucv.c |    5 ++---
 net/unix/af_unix.c |    9 ++-------
 4 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index c945fba..c42c115 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1265,6 +1265,24 @@ void sk_prot_clear_portaddr_nulls(struct sock *sk, int size);
 #define RCV_SHUTDOWN	1
 #define SEND_SHUTDOWN	2
 
+static inline int shutdown_u2mask(int uhow)
+{
+	/*
+	 * map
+	 * 	SHUT_RD -> RCV_SHUTDOWN
+	 * 	SHUT_WR -> SEND_SHUTDOWN
+	 * 	SHUT_RDWR -> SHUTDOWN_MASK
+	 *
+	 * or report 0 on error
+	 */
+
+	uhow++;
+	if (uhow & ~SHUTDOWN_MASK)
+		uhow = 0;
+
+	return uhow;
+}
+
 #define SOCK_SNDBUF_LOCK	1
 #define SOCK_RCVBUF_LOCK	2
 #define SOCK_BINDADDR_LOCK	4
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 766c596..3b3940c 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -825,10 +825,9 @@ int inet_shutdown(struct socket *sock, int how)
 	/* This should really check to make sure
 	 * the socket is a TCP socket. (WHY AC...)
 	 */
-	how++; /* maps 0->1 has the advantage of making bit 1 rcvs and
-		       1->2 bit 2 snds.
-		       2->3 */
-	if ((how & ~SHUTDOWN_MASK) || !how)	/* MAXINT->0 */
+
+	how = shutdown_u2mask(how);
+	if (!how)
 		return -EINVAL;
 
 	lock_sock(sk);
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index cd6f7a9..308024c 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1497,9 +1497,8 @@ static int iucv_sock_shutdown(struct socket *sock, int how)
 	struct iucv_message txmsg;
 	int err = 0;
 
-	how++;
-
-	if ((how & ~SHUTDOWN_MASK) || !how)
+	how = shutdown_u2mask(how);
+	if (!how)
 		return -EINVAL;
 
 	lock_sock(sk);
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 5b5c876..14543f2 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2057,14 +2057,9 @@ static int unix_shutdown(struct socket *sock, int mode)
 	struct sock *sk = sock->sk;
 	struct sock *other;
 
-	if (mode < SHUT_RD || mode > SHUT_RDWR)
+	mode = shutdown_u2mask(mode);
+	if (!mode)
 		return -EINVAL;
-	/* This maps:
-	 * SHUT_RD   (0) -> RCV_SHUTDOWN  (1)
-	 * SHUT_WR   (1) -> SEND_SHUTDOWN (2)
-	 * SHUT_RDWR (2) -> SHUTDOWN_MASK (3)
-	 */
-	++mode;
 
 	unix_state_lock(sk);
 	sk->sk_shutdown |= mode;
-- 
1.7.6.5

^ permalink raw reply related

* [PATCH 2/3] inet-diag: Get more bits for extension flag
From: Pavel Emelyanov @ 2012-10-23 16:26 UTC (permalink / raw)
  To: Linux Netdev List, David Miller
In-Reply-To: <5086C36B.6060508@parallels.com>

The inet-diag dumping request carries 8-bit ext value which denotes what
additional info we want to see. Unfortunately there's only one bit left
on it and occupying one with the "I want shutdown" is unwanted.

However, there are 8 more bits in the request and this "pad" field is
currently unused. I propose to make the 8th bit of the existing ext flag
mean "this unused space contains more ext bits".

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
---
 include/uapi/linux/inet_diag.h |    3 ++-
 net/ipv4/inet_diag.c           |    3 +++
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h
index 8c469af..c5e14f6 100644
--- a/include/uapi/linux/inet_diag.h
+++ b/include/uapi/linux/inet_diag.h
@@ -38,7 +38,7 @@ struct inet_diag_req_v2 {
 	__u8	sdiag_family;
 	__u8	sdiag_protocol;
 	__u8	idiag_ext;
-	__u8	pad;
+	__u8	idiag_ext2;
 	__u32	idiag_states;
 	struct inet_diag_sockid id;
 };
@@ -109,6 +109,7 @@ enum {
 	INET_DIAG_TOS,
 	INET_DIAG_TCLASS,
 	INET_DIAG_SKMEMINFO,
+	__INET_DIAG_EXT2,
 };
 
 #define INET_DIAG_MAX INET_DIAG_SKMEMINFO
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 535584c..52db768 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -81,6 +81,9 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
 	const struct inet_diag_handler *handler;
 	int ext = req->idiag_ext;
 
+	if (ext & (1 << (__INET_DIAG_EXT2 - 1)))
+		ext |= req->idiag_ext2 << __INET_DIAG_EXT2;
+
 	handler = inet_diag_table[req->sdiag_protocol];
 	BUG_ON(handler == NULL);
 
-- 
1.7.6.5

^ permalink raw reply related

* Re: [PATCH v6 04/10] ipc: add new SHM_SET command for sys_shmctl() call
From: Serge Hallyn @ 2012-10-23 16:27 UTC (permalink / raw)
  To: Stanislav Kinsbursky
  Cc: akpm, catalin.marinas, will.deacon, dhowells, manfred, hughd,
	jmorris, mtk.manpages, kosaki.motohiro, paulmck, sds, devel,
	a.p.zijlstra, cmetcalf, linux-driver, ron.mercer, viro, eparis,
	tglx, jitendra.kalsaria, netdev, linux-kernel,
	linux-security-module, ebiederm, casey
In-Reply-To: <20121015155956.28348.36765.stgit@localhost.localdomain>

Quoting Stanislav Kinsbursky (skinsbursky@parallels.com):
> New SHM_SET command will be interpreted exactly as IPC_SET, but also will
> update key, cuid and cgid values. IOW, it allows to change existent key value.
> The fact, that key is not used is checked before update. Otherwise -EEXIST is
> returned.
> 
> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>

Looks sane (modulo 'fallsthrough' comment already requested)

Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

> ---
>  include/uapi/linux/shm.h   |    1 +
>  ipc/compat.c               |    1 +
>  ipc/shm.c                  |   13 +++++++++++--
>  security/selinux/hooks.c   |    1 +
>  security/smack/smack_lsm.c |    1 +
>  5 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/include/uapi/linux/shm.h b/include/uapi/linux/shm.h
> index ec36fa1..d7413fd 100644
> --- a/include/uapi/linux/shm.h
> +++ b/include/uapi/linux/shm.h
> @@ -56,6 +56,7 @@ struct shmid_ds {
>  /* ipcs ctl commands */
>  #define SHM_STAT 	13
>  #define SHM_INFO 	14
> +#define SHM_SET		15
>  
>  /* Obsolete, used only for backwards compatibility */
>  struct	shminfo {
> diff --git a/ipc/compat.c b/ipc/compat.c
> index af30d13..35c750d 100644
> --- a/ipc/compat.c
> +++ b/ipc/compat.c
> @@ -692,6 +692,7 @@ long compat_sys_shmctl(int first, int second, void __user *uptr)
>  
>  
>  	case IPC_SET:
> +	case SHM_SET:
>  		if (version == IPC_64) {
>  			err = get_compat_shmid64_ds(&s64, uptr);
>  		} else {
> diff --git a/ipc/shm.c b/ipc/shm.c
> index 80b0046..aebc50d 100644
> --- a/ipc/shm.c
> +++ b/ipc/shm.c
> @@ -636,6 +636,9 @@ copy_shmid_from_user(struct shmid64_ds *out, void __user *buf, int version)
>  		out->shm_perm.uid	= tbuf_old.shm_perm.uid;
>  		out->shm_perm.gid	= tbuf_old.shm_perm.gid;
>  		out->shm_perm.mode	= tbuf_old.shm_perm.mode;
> +		out->shm_perm.cuid	= tbuf_old.shm_perm.cuid;
> +		out->shm_perm.cgid	= tbuf_old.shm_perm.cgid;
> +		out->shm_perm.key	= tbuf_old.shm_perm.key;
>  
>  		return 0;
>  	    }
> @@ -740,12 +743,13 @@ static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd,
>  	struct shmid_kernel *shp;
>  	int err;
>  
> -	if (cmd == IPC_SET) {
> +	if (cmd == IPC_SET || cmd == SHM_SET) {
>  		if (copy_shmid_from_user(&shmid64, buf, version))
>  			return -EFAULT;
>  	}
>  
> -	ipcp = ipcctl_pre_down(ns, &shm_ids(ns), shmid, cmd,
> +	ipcp = ipcctl_pre_down(ns, &shm_ids(ns), shmid,
> +			       (cmd != SHM_SET) ? cmd : IPC_SET,
>  			       &shmid64.shm_perm, 0);
>  	if (IS_ERR(ipcp))
>  		return PTR_ERR(ipcp);
> @@ -759,6 +763,10 @@ static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd,
>  	case IPC_RMID:
>  		do_shm_rmid(ns, ipcp);
>  		goto out_up;
> +	case SHM_SET:
> +		err = ipc_update_key(&shm_ids(ns), &shmid64.shm_perm, ipcp);
> +		if (err)
> +			break;
>  	case IPC_SET:
>  		err = ipc_update_perm(&shmid64.shm_perm, ipcp);
>  		if (err)
> @@ -938,6 +946,7 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf)
>  	}
>  	case IPC_RMID:
>  	case IPC_SET:
> +	case SHM_SET:
>  		err = shmctl_down(ns, shmid, cmd, buf, version);
>  		return err;
>  	default:
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 24ab414..62b2447 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -5027,6 +5027,7 @@ static int selinux_shm_shmctl(struct shmid_kernel *shp, int cmd)
>  		perms = SHM__GETATTR | SHM__ASSOCIATE;
>  		break;
>  	case IPC_SET:
> +	case SHM_SET:
>  		perms = SHM__SETATTR;
>  		break;
>  	case SHM_LOCK:
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 38be92c..c7eabc9 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -2121,6 +2121,7 @@ static int smack_shm_shmctl(struct shmid_kernel *shp, int cmd)
>  		may = MAY_READ;
>  		break;
>  	case IPC_SET:
> +	case SHM_SET:
>  	case SHM_LOCK:
>  	case SHM_UNLOCK:
>  	case IPC_RMID:
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 3/3] sock-diag: Report shutdown for inet and unix sockets
From: Pavel Emelyanov @ 2012-10-23 16:28 UTC (permalink / raw)
  To: Linux Netdev List, David Miller
In-Reply-To: <5086C36B.6060508@parallels.com>

Add ext bits for inet-diag and unix-diag and report sk_shutdown state.

When it's zero (i.e. -- no shutdown on a socket) diag reports nothing
for this request. Otherwise report user-space known values using the
proper mask-to-user conversion trick.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>

---
 include/linux/sock_diag.h      |    1 +
 include/net/sock.h             |   12 ++++++++++++
 include/uapi/linux/inet_diag.h |    3 ++-
 include/uapi/linux/unix_diag.h |    2 ++
 net/core/sock_diag.c           |    9 +++++++++
 net/ipv4/inet_diag.c           |    4 ++++
 net/unix/diag.c                |    4 ++++
 7 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
index e8d702e..df4b20f 100644
--- a/include/linux/sock_diag.h
+++ b/include/linux/sock_diag.h
@@ -22,5 +22,6 @@ int sock_diag_check_cookie(void *sk, __u32 *cookie);
 void sock_diag_save_cookie(void *sk, __u32 *cookie);
 
 int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attr);
+int sock_diag_put_shutdown(struct sock *sk, struct sk_buff *skb, int attr);
 
 #endif
diff --git a/include/net/sock.h b/include/net/sock.h
index c42c115..8b64048 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1283,6 +1283,18 @@ static inline int shutdown_u2mask(int uhow)
 	return uhow;
 }
 
+static inline int shutdown_mask2u(int mask)
+{
+	/*
+	 * map
+	 * 	RCV_SHUTDOWN -> SHUT_RD
+	 * 	SEND_SHUTDOWN -> SHUT_WR
+	 * 	SHUTDOWN_MASK -> SHUT_RDWR
+	 */
+
+	return mask - 1;
+}
+
 #define SOCK_SNDBUF_LOCK	1
 #define SOCK_RCVBUF_LOCK	2
 #define SOCK_BINDADDR_LOCK	4
diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h
index c5e14f6..ace76b5 100644
--- a/include/uapi/linux/inet_diag.h
+++ b/include/uapi/linux/inet_diag.h
@@ -110,9 +110,10 @@ enum {
 	INET_DIAG_TCLASS,
 	INET_DIAG_SKMEMINFO,
 	__INET_DIAG_EXT2,
+	INET_DIAG_SHUTDOWN,
 };
 
-#define INET_DIAG_MAX INET_DIAG_SKMEMINFO
+#define INET_DIAG_MAX INET_DIAG_SHUTDOWN
 
 
 /* INET_DIAG_MEM */
diff --git a/include/uapi/linux/unix_diag.h b/include/uapi/linux/unix_diag.h
index b1d2bf1..2113d90 100644
--- a/include/uapi/linux/unix_diag.h
+++ b/include/uapi/linux/unix_diag.h
@@ -19,6 +19,7 @@ struct unix_diag_req {
 #define UDIAG_SHOW_ICONS	0x00000008	/* show pending connections */
 #define UDIAG_SHOW_RQLEN	0x00000010	/* show skb receive queue len */
 #define UDIAG_SHOW_MEMINFO	0x00000020	/* show memory info of a socket */
+#define UDIAG_SHOW_SHUTDOWN	0x00000040	/* show shutdown state */
 
 struct unix_diag_msg {
 	__u8	udiag_family;
@@ -37,6 +38,7 @@ enum {
 	UNIX_DIAG_ICONS,
 	UNIX_DIAG_RQLEN,
 	UNIX_DIAG_MEMINFO,
+	UNIX_DIAG_SHUTDOWN,
 
 	UNIX_DIAG_MAX,
 };
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index 602cd63..152db24 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -49,6 +49,15 @@ int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attrtype)
 }
 EXPORT_SYMBOL_GPL(sock_diag_put_meminfo);
 
+int sock_diag_put_shutdown(struct sock *sk, struct sk_buff *skb, int attrtype)
+{
+	if (!sk->sk_shutdown)
+		return 0;
+
+	return nla_put_u32(skb, attrtype, shutdown_mask2u(sk->sk_shutdown));
+}
+EXPORT_SYMBOL_GPL(sock_diag_put_shutdown);
+
 void sock_diag_register_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh))
 {
 	mutex_lock(&sock_diag_table_mutex);
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 52db768..3b91f86 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -115,6 +115,10 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
 		if (nla_put_u8(skb, INET_DIAG_TOS, inet->tos) < 0)
 			goto errout;
 
+	if (ext & (1 << (INET_DIAG_SHUTDOWN - 1)))
+		if (sock_diag_put_shutdown(sk, skb, INET_DIAG_SHUTDOWN))
+			goto errout;
+
 #if IS_ENABLED(CONFIG_IPV6)
 	if (r->idiag_family == AF_INET6) {
 		const struct ipv6_pinfo *np = inet6_sk(sk);
diff --git a/net/unix/diag.c b/net/unix/diag.c
index 06748f1..e41308c 100644
--- a/net/unix/diag.c
+++ b/net/unix/diag.c
@@ -151,6 +151,10 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
 	    sock_diag_put_meminfo(sk, skb, UNIX_DIAG_MEMINFO))
 		goto out_nlmsg_trim;
 
+	if ((req->udiag_show & UDIAG_SHOW_SHUTDOWN) &&
+	    sock_diag_put_shutdown(sk, skb, UNIX_DIAG_SHUTDOWN))
+		goto out_nlmsg_trim;
+
 	return nlmsg_end(skb, nlh);
 
 out_nlmsg_trim:
-- 
1.7.6.5

^ permalink raw reply related

* Re: [PATCH v6 05/10] ipc: add new MSG_SET command for sys_msgctl() call
From: Serge Hallyn @ 2012-10-23 16:29 UTC (permalink / raw)
  To: Stanislav Kinsbursky
  Cc: akpm, catalin.marinas, will.deacon, dhowells, manfred, hughd,
	jmorris, mtk.manpages, kosaki.motohiro, paulmck, sds, devel,
	a.p.zijlstra, cmetcalf, linux-driver, ron.mercer, viro, eparis,
	tglx, jitendra.kalsaria, netdev, linux-kernel,
	linux-security-module, ebiederm, casey
In-Reply-To: <20121015160001.28348.36871.stgit@localhost.localdomain>

Quoting Stanislav Kinsbursky (skinsbursky@parallels.com):
> New MSG_SET command will be interpreted exactly as IPC_SET, but also will
> update key, cuid and cgid values. IOW, it allows to change existent key value.
> The fact, that key is not used is checked before update. Otherwise -EEXIST is
> returned.
> 
> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>

Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

> ---
>  include/uapi/linux/msg.h   |    1 +
>  ipc/compat.c               |    1 +
>  ipc/msg.c                  |   13 +++++++++++--
>  security/selinux/hooks.c   |    1 +
>  security/smack/smack_lsm.c |    1 +
>  5 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/include/uapi/linux/msg.h b/include/uapi/linux/msg.h
> index 78dbd2f..76999c9 100644
> --- a/include/uapi/linux/msg.h
> +++ b/include/uapi/linux/msg.h
> @@ -6,6 +6,7 @@
>  /* ipcs ctl commands */
>  #define MSG_STAT 11
>  #define MSG_INFO 12
> +#define MSG_SET  13
>  
>  /* msgrcv options */
>  #define MSG_NOERROR     010000  /* no error if message is too big */
> diff --git a/ipc/compat.c b/ipc/compat.c
> index 35c750d..9c70f9a 100644
> --- a/ipc/compat.c
> +++ b/ipc/compat.c
> @@ -483,6 +483,7 @@ long compat_sys_msgctl(int first, int second, void __user *uptr)
>  		break;
>  
>  	case IPC_SET:
> +	case MSG_SET:
>  		if (version == IPC_64) {
>  			err = get_compat_msqid64(&m64, uptr);
>  		} else {
> diff --git a/ipc/msg.c b/ipc/msg.c
> index 2f44946..68515dc 100644
> --- a/ipc/msg.c
> +++ b/ipc/msg.c
> @@ -392,6 +392,9 @@ copy_msqid_from_user(struct msqid64_ds *out, void __user *buf, int version)
>  		out->msg_perm.uid      	= tbuf_old.msg_perm.uid;
>  		out->msg_perm.gid      	= tbuf_old.msg_perm.gid;
>  		out->msg_perm.mode     	= tbuf_old.msg_perm.mode;
> +		out->msg_perm.cuid	= tbuf_old.msg_perm.cuid;
> +		out->msg_perm.cgid	= tbuf_old.msg_perm.cgid;
> +		out->msg_perm.key	= tbuf_old.msg_perm.key;
>  
>  		if (tbuf_old.msg_qbytes == 0)
>  			out->msg_qbytes	= tbuf_old.msg_lqbytes;
> @@ -418,12 +421,13 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
>  	struct msg_queue *msq;
>  	int err;
>  
> -	if (cmd == IPC_SET) {
> +	if (cmd == IPC_SET || cmd == MSG_SET) {
>  		if (copy_msqid_from_user(&msqid64, buf, version))
>  			return -EFAULT;
>  	}
>  
> -	ipcp = ipcctl_pre_down(ns, &msg_ids(ns), msqid, cmd,
> +	ipcp = ipcctl_pre_down(ns, &msg_ids(ns), msqid,
> +			       (cmd != MSG_SET) ? cmd : IPC_SET,
>  			       &msqid64.msg_perm, msqid64.msg_qbytes);
>  	if (IS_ERR(ipcp))
>  		return PTR_ERR(ipcp);
> @@ -439,6 +443,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
>  		freeque(ns, ipcp);
>  		goto out_up;
>  	case IPC_SET:
> +	case MSG_SET:
>  		if (msqid64.msg_qbytes > ns->msg_ctlmnb &&
>  		    !capable(CAP_SYS_RESOURCE)) {
>  			err = -EPERM;
> @@ -451,6 +456,9 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
>  
>  		msq->q_qbytes = msqid64.msg_qbytes;
>  
> +		if (cmd == MSG_SET)
> +			ipc_update_key(&msg_ids(ns), &msqid64.msg_perm, ipcp);
> +
>  		msq->q_ctime = get_seconds();
>  		/* sleeping receivers might be excluded by
>  		 * stricter permissions.
> @@ -569,6 +577,7 @@ SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf)
>  	}
>  	case IPC_SET:
>  	case IPC_RMID:
> +	case MSG_SET:
>  		err = msgctl_down(ns, msqid, cmd, buf, version);
>  		return err;
>  	default:
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 62b2447..78b77ac 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -4885,6 +4885,7 @@ static int selinux_msg_queue_msgctl(struct msg_queue *msq, int cmd)
>  		perms = MSGQ__GETATTR | MSGQ__ASSOCIATE;
>  		break;
>  	case IPC_SET:
> +	case MSG_SET:
>  		perms = MSGQ__SETATTR;
>  		break;
>  	case IPC_RMID:
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index c7eabc9..d51a8da 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -2374,6 +2374,7 @@ static int smack_msg_queue_msgctl(struct msg_queue *msq, int cmd)
>  		may = MAY_READ;
>  		break;
>  	case IPC_SET:
> +	case MSG_SET:
>  	case IPC_RMID:
>  		may = MAY_READWRITE;
>  		break;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH v6 06/10] glge driver: rename internal SEM_SET macro to SEM_INIT
From: Serge Hallyn @ 2012-10-23 16:32 UTC (permalink / raw)
  To: Stanislav Kinsbursky
  Cc: akpm, catalin.marinas, will.deacon, dhowells, manfred, hughd,
	jmorris, mtk.manpages, kosaki.motohiro, paulmck, sds, devel,
	a.p.zijlstra, cmetcalf, linux-driver, ron.mercer, viro, eparis,
	tglx, jitendra.kalsaria, netdev, linux-kernel,
	linux-security-module, ebiederm, casey
In-Reply-To: <20121015160006.28348.79520.stgit@localhost.localdomain>

Quoting Stanislav Kinsbursky (skinsbursky@parallels.com):
> The reason for shit patch is that SET_SET is desired to be a part of new part
> of API of IPC sys_semctl() system call.
> The name itself for IPC is quite natural, because all linux-specific commands
> names for IPC system calls are originally created by replacing "IPC_" part by
> "SEM_"("MSG_", "SHM_") part.
> So, I'm hoping, that this change doesn't really matters for "QLogic qlge NIC

Can't speak for the driver maintainer, but it does look sane.

Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

> HBA Driver" developers, since it's just an internal define.
> ---
>  drivers/net/ethernet/qlogic/qlge/qlge.h      |    4 ++--
>  drivers/net/ethernet/qlogic/qlge/qlge_main.c |   16 ++++++++--------
>  2 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/ethernet/qlogic/qlge/qlge.h b/drivers/net/ethernet/qlogic/qlge/qlge.h
> index a131d7b..6f46ea5 100644
> --- a/drivers/net/ethernet/qlogic/qlge/qlge.h
> +++ b/drivers/net/ethernet/qlogic/qlge/qlge.h
> @@ -347,10 +347,10 @@ enum {
>  enum {
>  	/*
>  	 * Example:
> -	 * reg = SEM_XGMAC0_MASK | (SEM_SET << SEM_XGMAC0_SHIFT)
> +	 * reg = SEM_XGMAC0_MASK | (SEM_INIT << SEM_XGMAC0_SHIFT)
>  	 */
>  	SEM_CLEAR = 0,
> -	SEM_SET = 1,
> +	SEM_INIT = 1,
>  	SEM_FORCE = 3,
>  	SEM_XGMAC0_SHIFT = 0,
>  	SEM_XGMAC1_SHIFT = 2,
> diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
> index b262d61..cfb0f62 100644
> --- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c
> +++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
> @@ -109,28 +109,28 @@ static int ql_sem_trylock(struct ql_adapter *qdev, u32 sem_mask)
>  
>  	switch (sem_mask) {
>  	case SEM_XGMAC0_MASK:
> -		sem_bits = SEM_SET << SEM_XGMAC0_SHIFT;
> +		sem_bits = SEM_INIT << SEM_XGMAC0_SHIFT;
>  		break;
>  	case SEM_XGMAC1_MASK:
> -		sem_bits = SEM_SET << SEM_XGMAC1_SHIFT;
> +		sem_bits = SEM_INIT << SEM_XGMAC1_SHIFT;
>  		break;
>  	case SEM_ICB_MASK:
> -		sem_bits = SEM_SET << SEM_ICB_SHIFT;
> +		sem_bits = SEM_INIT << SEM_ICB_SHIFT;
>  		break;
>  	case SEM_MAC_ADDR_MASK:
> -		sem_bits = SEM_SET << SEM_MAC_ADDR_SHIFT;
> +		sem_bits = SEM_INIT << SEM_MAC_ADDR_SHIFT;
>  		break;
>  	case SEM_FLASH_MASK:
> -		sem_bits = SEM_SET << SEM_FLASH_SHIFT;
> +		sem_bits = SEM_INIT << SEM_FLASH_SHIFT;
>  		break;
>  	case SEM_PROBE_MASK:
> -		sem_bits = SEM_SET << SEM_PROBE_SHIFT;
> +		sem_bits = SEM_INIT << SEM_PROBE_SHIFT;
>  		break;
>  	case SEM_RT_IDX_MASK:
> -		sem_bits = SEM_SET << SEM_RT_IDX_SHIFT;
> +		sem_bits = SEM_INIT << SEM_RT_IDX_SHIFT;
>  		break;
>  	case SEM_PROC_REG_MASK:
> -		sem_bits = SEM_SET << SEM_PROC_REG_SHIFT;
> +		sem_bits = SEM_INIT << SEM_PROC_REG_SHIFT;
>  		break;
>  	default:
>  		netif_alert(qdev, probe, qdev->ndev, "bad Semaphore mask!.\n");
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH v6 07/10] ipc: add new SEM_SET command for sys_semctl() call
From: Serge Hallyn @ 2012-10-23 16:34 UTC (permalink / raw)
  To: Stanislav Kinsbursky
  Cc: akpm, catalin.marinas, will.deacon, dhowells, manfred, hughd,
	jmorris, mtk.manpages, kosaki.motohiro, paulmck, sds, devel,
	a.p.zijlstra, cmetcalf, linux-driver, ron.mercer, viro, eparis,
	tglx, jitendra.kalsaria, netdev, linux-kernel,
	linux-security-module, ebiederm, casey
In-Reply-To: <20121015160011.28348.39915.stgit@localhost.localdomain>

Quoting Stanislav Kinsbursky (skinsbursky@parallels.com):
> New SEM_SET command will be interpreted exactly as IPC_SET, but also will
> update key, cuid and cgid values. IOW, it allows to change existent key value.
> The fact, that key is not used is checked before update. Otherwise -EEXIST is
> returned.
> 
> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>

Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

(again, modulo requested /* fallthrough */ comment )

> ---
>  include/uapi/linux/sem.h   |    1 +
>  ipc/compat.c               |    1 +
>  ipc/sem.c                  |   10 ++++++++--
>  security/selinux/hooks.c   |    1 +
>  security/smack/smack_lsm.c |    1 +
>  5 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/include/uapi/linux/sem.h b/include/uapi/linux/sem.h
> index 541fce0..b6ae374 100644
> --- a/include/uapi/linux/sem.h
> +++ b/include/uapi/linux/sem.h
> @@ -18,6 +18,7 @@
>  /* ipcs ctl cmds */
>  #define SEM_STAT 18
>  #define SEM_INFO 19
> +#define SEM_SET  20
>  
>  /* Obsolete, used only for backwards compatibility and libc5 compiles */
>  struct semid_ds {
> diff --git a/ipc/compat.c b/ipc/compat.c
> index 9c70f9a..84d8efd 100644
> --- a/ipc/compat.c
> +++ b/ipc/compat.c
> @@ -290,6 +290,7 @@ static long do_compat_semctl(int first, int second, int third, u32 pad)
>  		break;
>  
>  	case IPC_SET:
> +	case SEM_SET:
>  		if (version == IPC_64) {
>  			err = get_compat_semid64_ds(&s64, compat_ptr(pad));
>  		} else {
> diff --git a/ipc/sem.c b/ipc/sem.c
> index 10e9085..3eac885 100644
> --- a/ipc/sem.c
> +++ b/ipc/sem.c
> @@ -1085,12 +1085,13 @@ static int semctl_down(struct ipc_namespace *ns, int semid,
>  	struct semid64_ds semid64;
>  	struct kern_ipc_perm *ipcp;
>  
> -	if(cmd == IPC_SET) {
> +	if (cmd == IPC_SET || cmd == SEM_SET) {
>  		if (copy_semid_from_user(&semid64, arg.buf, version))
>  			return -EFAULT;
>  	}
>  
> -	ipcp = ipcctl_pre_down(ns, &sem_ids(ns), semid, cmd,
> +	ipcp = ipcctl_pre_down(ns, &sem_ids(ns), semid,
> +			       (cmd != SEM_SET) ? cmd : IPC_SET,
>  			       &semid64.sem_perm, 0);
>  	if (IS_ERR(ipcp))
>  		return PTR_ERR(ipcp);
> @@ -1105,6 +1106,10 @@ static int semctl_down(struct ipc_namespace *ns, int semid,
>  	case IPC_RMID:
>  		freeary(ns, ipcp);
>  		goto out_up;
> +	case SEM_SET:
> +		err = ipc_update_key(&sem_ids(ns), &semid64.sem_perm, ipcp);
> +		if (err)
> +			break;
>  	case IPC_SET:
>  		err = ipc_update_perm(&semid64.sem_perm, ipcp);
>  		if (err)
> @@ -1152,6 +1157,7 @@ SYSCALL_DEFINE(semctl)(int semid, int semnum, int cmd, union semun arg)
>  		return err;
>  	case IPC_RMID:
>  	case IPC_SET:
> +	case SEM_SET:
>  		err = semctl_down(ns, semid, cmd, version, arg);
>  		return err;
>  	default:
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 78b77ac..02b037d 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -5133,6 +5133,7 @@ static int selinux_sem_semctl(struct sem_array *sma, int cmd)
>  		perms = SEM__DESTROY;
>  		break;
>  	case IPC_SET:
> +	case SEM_SET:
>  		perms = SEM__SETATTR;
>  		break;
>  	case IPC_STAT:
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index d51a8da..b4135ed 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -2253,6 +2253,7 @@ static int smack_sem_semctl(struct sem_array *sma, int cmd)
>  	case SETALL:
>  	case IPC_RMID:
>  	case IPC_SET:
> +	case SEM_SET:
>  		may = MAY_READWRITE;
>  		break;
>  	case IPC_INFO:
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ 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