All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olaf Kirch <okir@suse.de>
To: netdev@oss.sgi.com
Cc: meissner@suse.de
Subject: [PATCH 2.6] compat_sys_[gs]etsockopt need to check for level
Date: Mon, 24 May 2004 13:33:31 +0200	[thread overview]
Message-ID: <20040524113331.GF23568@suse.de> (raw)

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

The 32bit emulation functions for setsockopt/getsockopt try
to catch a few special cases by looking at the option name,
without checking for the option level. This breaks IPV6_V6ONLY
and probably a few others.

The bug was found by Marcus Meissner.

I hope I got the level for IPT_SO_SET_REPLACE right (I think it's SOL_IP).
I would appreciate if someone could double-check.

Cheers,
Olaf
-- 
Olaf Kirch     |  The Hardware Gods hate me.
okir@suse.de   |
---------------+ 

[-- Attachment #2: setsockopt-compat --]
[-- Type: text/plain, Size: 1278 bytes --]

--- linux-2.6.5/net/compat.c.orig	2004-04-04 05:37:24.000000000 +0200
+++ linux-2.6.5/net/compat.c	2004-05-24 13:32:27.000000000 +0200
@@ -457,13 +457,14 @@
 asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
 				char *optval, int optlen)
 {
-	if (optname == IPT_SO_SET_REPLACE)
+	if (level == SOL_IP && optname == IPT_SO_SET_REPLACE)
 		return do_netfilter_replace(fd, level, optname,
 					    optval, optlen);
-	if (optname == SO_ATTACH_FILTER)
+	if (level == SOL_SOCKET && optname == SO_ATTACH_FILTER)
 		return do_set_attach_filter(fd, level, optname,
 					    optval, optlen);
-	if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)
+	if (level == SOL_SOCKET && 
+	    (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO))
 		return do_set_sock_timeout(fd, level, optname, optval, optlen);
 
 	return sys_setsockopt(fd, level, optname, optval, optlen);
@@ -500,7 +501,8 @@
 asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
 				char *optval, int *optlen)
 {
-	if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)
+	if (level == SOL_SOCKET &&
+	    (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO))
 		return do_get_sock_timeout(fd, level, optname, optval, optlen);
 	return sys_getsockopt(fd, level, optname, optval, optlen);
 }

                 reply	other threads:[~2004-05-24 11:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040524113331.GF23568@suse.de \
    --to=okir@suse.de \
    --cc=meissner@suse.de \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.