slub: register slabinfo to procfs

2008-01-02 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=6b6adc22a01941165d5af9a3e69e28e948b28f47
Commit: 6b6adc22a01941165d5af9a3e69e28e948b28f47
Parent: dc512814b5f8b7b80c74d6170b93a606ae4f36c5
Author: Pekka Enberg [EMAIL PROTECTED]
AuthorDate: Wed Jan 2 13:07:25 2008 +0200
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Wed Jan 2 10:42:39 2008 -0800

slub: register slabinfo to procfs

We need to register slabinfo to procfs when CONFIG_SLUB is enabled to
make the file actually visible to user-space.

Signed-off-by: Pekka Enberg [EMAIL PROTECTED]
Acked-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 fs/proc/proc_misc.c |   17 +
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index e0d064e..a11968b 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -451,6 +451,20 @@ static const struct file_operations 
proc_slabstats_operations = {
 #endif
 #endif
 
+#ifdef CONFIG_SLUB
+static int slabinfo_open(struct inode *inode, struct file *file)
+{
+   return seq_open(file, slabinfo_op);
+}
+
+static const struct file_operations proc_slabinfo_operations = {
+   .open   = slabinfo_open,
+   .read   = seq_read,
+   .llseek = seq_lseek,
+   .release= seq_release,
+};
+#endif
+
 static int show_stat(struct seq_file *p, void *v)
 {
int i;
@@ -734,6 +748,9 @@ void __init proc_misc_init(void)
create_seq_entry(slab_allocators, 0 ,proc_slabstats_operations);
 #endif
 #endif
+#ifdef CONFIG_SLUB
+   create_seq_entry(slabinfo, S_IWUSR|S_IRUGO, 
proc_slabinfo_operations);
+#endif
create_seq_entry(buddyinfo,S_IRUGO, fragmentation_file_operations);
create_seq_entry(pagetypeinfo, S_IRUGO, pagetypeinfo_file_ops);
create_seq_entry(vmstat,S_IRUGO, proc_vmstat_file_operations);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Unify /proc/slabinfo configuration

2008-01-02 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=158a962422e4a54dc256b6a9b9562f3d30d34d9c
Commit: 158a962422e4a54dc256b6a9b9562f3d30d34d9c
Parent: 6b6adc22a01941165d5af9a3e69e28e948b28f47
Author: Linus Torvalds [EMAIL PROTECTED]
AuthorDate: Wed Jan 2 13:04:48 2008 -0800
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Wed Jan 2 13:04:48 2008 -0800

Unify /proc/slabinfo configuration

Both SLUB and SLAB really did almost exactly the same thing for
/proc/slabinfo setup, using duplicate code and per-allocator #ifdef's.

This just creates a common CONFIG_SLABINFO that is enabled by both SLUB
and SLAB, and shares all the setup code.  Maybe SLOB will want this some
day too.

Reviewed-by: Pekka Enberg [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 fs/proc/proc_misc.c  |   21 ++---
 include/linux/slab.h |5 +
 include/linux/slab_def.h |3 ---
 include/linux/slub_def.h |2 --
 init/Kconfig |6 ++
 mm/slab.c|2 +-
 mm/slub.c|   11 +--
 7 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index a11968b..3462bfd 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -410,7 +410,7 @@ static const struct file_operations proc_modules_operations 
= {
 };
 #endif
 
-#ifdef CONFIG_SLAB
+#ifdef CONFIG_SLABINFO
 static int slabinfo_open(struct inode *inode, struct file *file)
 {
return seq_open(file, slabinfo_op);
@@ -451,20 +451,6 @@ static const struct file_operations 
proc_slabstats_operations = {
 #endif
 #endif
 
-#ifdef CONFIG_SLUB
-static int slabinfo_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, slabinfo_op);
-}
-
-static const struct file_operations proc_slabinfo_operations = {
-   .open   = slabinfo_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-#endif
-
 static int show_stat(struct seq_file *p, void *v)
 {
int i;
@@ -742,15 +728,12 @@ void __init proc_misc_init(void)
 #endif
create_seq_entry(stat, 0, proc_stat_operations);
create_seq_entry(interrupts, 0, proc_interrupts_operations);
-#ifdef CONFIG_SLAB
+#ifdef CONFIG_SLABINFO
create_seq_entry(slabinfo,S_IWUSR|S_IRUGO,proc_slabinfo_operations);
 #ifdef CONFIG_DEBUG_SLAB_LEAK
create_seq_entry(slab_allocators, 0 ,proc_slabstats_operations);
 #endif
 #endif
-#ifdef CONFIG_SLUB
-   create_seq_entry(slabinfo, S_IWUSR|S_IRUGO, 
proc_slabinfo_operations);
-#endif
create_seq_entry(buddyinfo,S_IRUGO, fragmentation_file_operations);
create_seq_entry(pagetypeinfo, S_IRUGO, pagetypeinfo_file_ops);
create_seq_entry(vmstat,S_IRUGO, proc_vmstat_file_operations);
diff --git a/include/linux/slab.h b/include/linux/slab.h
index f3a8eec..f62caaa 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -271,5 +271,10 @@ static inline void *kzalloc(size_t size, gfp_t flags)
return kmalloc(size, flags | __GFP_ZERO);
 }
 
+#ifdef CONFIG_SLABINFO
+extern const struct seq_operations slabinfo_op;
+ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *);
+#endif
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_SLAB_H */
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index 32bdc2f..fcc4809 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -95,7 +95,4 @@ found:
 
 #endif /* CONFIG_NUMA */
 
-extern const struct seq_operations slabinfo_op;
-ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *);
-
 #endif /* _LINUX_SLAB_DEF_H */
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index b7d9408..40801e7 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -200,6 +200,4 @@ static __always_inline void *kmalloc_node(size_t size, 
gfp_t flags, int node)
 }
 #endif
 
-extern const struct seq_operations slabinfo_op;
-
 #endif /* _LINUX_SLUB_DEF_H */
diff --git a/init/Kconfig b/init/Kconfig
index 404bbf3..b9d11a8 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -658,6 +658,12 @@ endchoice
 
 endmenu# General setup
 
+config SLABINFO
+   bool
+   depends on PROC_FS
+   depends on SLAB || SLUB
+   default y
+
 config RT_MUTEXES
boolean
select PLIST
diff --git a/mm/slab.c b/mm/slab.c
index 2e338a5..aebb9f6 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4105,7 +4105,7 @@ out:
schedule_delayed_work(work, round_jiffies_relative(REAPTIMEOUT_CPUC));
 }
 
-#ifdef CONFIG_PROC_FS
+#ifdef CONFIG_SLABINFO
 
 static void print_slabinfo_header(struct seq_file *m)
 {
diff --git a/mm/slub.c b/mm/slub.c
index 903dabd..474945e 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4127,7 +4127,14 @@ __initcall(slab_sysfs_init);
 /*
  * The /proc/slabinfo ABI
  */
-#ifdef 

scsi: revert [SCSI] Get rid of scsi_cmnd-done

2008-01-02 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ac40532ef0b8649e6f7f83859ea0de1c4ed08a19
Commit: ac40532ef0b8649e6f7f83859ea0de1c4ed08a19
Parent: 158a962422e4a54dc256b6a9b9562f3d30d34d9c
Author: Ingo Molnar [EMAIL PROTECTED]
AuthorDate: Wed Jan 2 17:25:34 2008 +0100
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Wed Jan 2 13:11:06 2008 -0800

scsi: revert [SCSI] Get rid of scsi_cmnd-done

This reverts commit 6f5391c283d7fdcf24bf40786ea79061919d1e1d ([SCSI]
Get rid of scsi_cmnd-done) that was supposed to be a cleanup commit,
but apparently it causes regressions:

  Bug 9370 - v2.6.24-rc2-409-g9418d5d: attempt to access beyond end of 
device
  http://bugzilla.kernel.org/show_bug.cgi?id=9370

this patch should be reintroduced in a more split-up form to make
testing of it easier.

Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Acked-by: Matthew Wilcox [EMAIL PROTECTED]
Cc: James Bottomley [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 drivers/scsi/scsi.c|   20 +++-
 drivers/scsi/scsi_error.c  |1 +
 drivers/scsi/scsi_lib.c|   14 ++
 drivers/scsi/scsi_priv.h   |1 -
 drivers/scsi/sd.c  |   28 ++--
 drivers/scsi/sr.c  |   21 +++--
 include/scsi/scsi_cmnd.h   |2 ++
 include/scsi/scsi_driver.h |1 -
 include/scsi/sd.h  |   13 +
 9 files changed, 58 insertions(+), 43 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 0fb1709..7ceb820 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -59,7 +59,6 @@
 #include scsi/scsi_cmnd.h
 #include scsi/scsi_dbg.h
 #include scsi/scsi_device.h
-#include scsi/scsi_driver.h
 #include scsi/scsi_eh.h
 #include scsi/scsi_host.h
 #include scsi/scsi_tcq.h
@@ -368,8 +367,9 @@ void scsi_log_send(struct scsi_cmnd *cmd)
scsi_print_command(cmd);
if (level  3) {
printk(KERN_INFO buffer = 0x%p, bufflen = %d,
-   queuecommand 0x%p\n,
+   done = 0x%p, queuecommand 0x%p\n,
scsi_sglist(cmd), scsi_bufflen(cmd),
+   cmd-done,
cmd-device-host-hostt-queuecommand);
 
}
@@ -654,12 +654,6 @@ void __scsi_done(struct scsi_cmnd *cmd)
blk_complete_request(rq);
 }
 
-/* Move this to a header if it becomes more generally useful */
-static struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
-{
-   return *(struct scsi_driver **)cmd-request-rq_disk-private_data;
-}
-
 /*
  * Function:scsi_finish_command
  *
@@ -671,8 +665,6 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
 {
struct scsi_device *sdev = cmd-device;
struct Scsi_Host *shost = sdev-host;
-   struct scsi_driver *drv;
-   unsigned int good_bytes;
 
scsi_device_unbusy(sdev);
 
@@ -698,13 +690,7 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
Notifying upper driver of completion 
(result %x)\n, cmd-result));
 
-   good_bytes = cmd-request_bufflen;
-if (cmd-request-cmd_type != REQ_TYPE_BLOCK_PC) {
-   drv = scsi_cmd_to_driver(cmd);
-   if (drv-done)
-   good_bytes = drv-done(cmd);
-   }
-   scsi_io_completion(cmd, good_bytes);
+   cmd-done(cmd);
 }
 EXPORT_SYMBOL(scsi_finish_command);
 
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index ebaca4c..70700b9 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1699,6 +1699,7 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
memset(scmd-cmnd, '\0', sizeof(scmd-cmnd));
 
scmd-scsi_done = scsi_reset_provider_done_command;
+   scmd-done  = NULL;
scmd-request_buffer= NULL;
scmd-request_bufflen   = 0;
 
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0e81e4c..8df8267 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1092,6 +1092,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned 
int good_bytes)
}
scsi_end_request(cmd, 0, this_count, !result);
 }
+EXPORT_SYMBOL(scsi_io_completion);
 
 /*
  * Function:scsi_init_io()
@@ -1170,6 +1171,18 @@ static struct scsi_cmnd *scsi_get_cmd_from_req(struct 
scsi_device *sdev,
return cmd;
 }
 
+static void scsi_blk_pc_done(struct scsi_cmnd *cmd)
+{
+   BUG_ON(!blk_pc_request(cmd-request));
+   /*
+* This will complete the whole command with uptodate=1 so
+* as far as the block layer is concerned the command completed
+* successfully. Since this 

restrict reading from /proc/pid/maps to those who share -mm or can ptrace pid

2008-01-02 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=831830b5a2b5d413407adf380ef62fe17d6fcbf2
Commit: 831830b5a2b5d413407adf380ef62fe17d6fcbf2
Parent: ac40532ef0b8649e6f7f83859ea0de1c4ed08a19
Author: Al Viro [EMAIL PROTECTED]
AuthorDate: Wed Jan 2 14:09:57 2008 +
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Wed Jan 2 13:13:27 2008 -0800

restrict reading from /proc/pid/maps to those who share -mm or can 
ptrace pid

Contents of /proc/*/maps is sensitive and may become sensitive after
open() (e.g.  if target originally shares our -mm and later does exec
on suid-root binary).

Check at read() (actually, -start() of iterator) time that mm_struct
we'd grabbed and locked is
 - still the -mm of target
 - equal to reader's -mm or the target is ptracable by reader.

Signed-off-by: Al Viro [EMAIL PROTECTED]
Acked-by: Rik van Riel [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 fs/proc/base.c |   20 
 fs/proc/internal.h |2 ++
 fs/proc/task_mmu.c |3 +--
 fs/proc/task_nommu.c   |4 +---
 include/linux/ptrace.h |1 +
 kernel/ptrace.c|4 ++--
 6 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 02a63ac..7411bfb 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -202,6 +202,26 @@ static int proc_root_link(struct inode *inode, struct 
dentry **dentry, struct vf
 (task-state == TASK_STOPPED || task-state == TASK_TRACED)  \
 security_ptrace(current,task) == 0))
 
+struct mm_struct *mm_for_maps(struct task_struct *task)
+{
+   struct mm_struct *mm = get_task_mm(task);
+   if (!mm)
+   return NULL;
+   down_read(mm-mmap_sem);
+   task_lock(task);
+   if (task-mm != mm)
+   goto out;
+   if (task-mm != current-mm  __ptrace_may_attach(task)  0)
+   goto out;
+   task_unlock(task);
+   return mm;
+out:
+   task_unlock(task);
+   up_read(mm-mmap_sem);
+   mmput(mm);
+   return NULL;
+}
+
 static int proc_pid_cmdline(struct task_struct *task, char * buffer)
 {
int res = 0;
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 1820eb2..05b3e90 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -27,6 +27,8 @@ struct vmalloc_info {
unsigned long   largest_chunk;
 };
 
+extern struct mm_struct *mm_for_maps(struct task_struct *);
+
 #ifdef CONFIG_MMU
 #define VMALLOC_TOTAL (VMALLOC_END - VMALLOC_START)
 extern void get_vmalloc_info(struct vmalloc_info *vmi);
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index c24d81a..8043a3e 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -397,12 +397,11 @@ static void *m_start(struct seq_file *m, loff_t *pos)
if (!priv-task)
return NULL;
 
-   mm = get_task_mm(priv-task);
+   mm = mm_for_maps(priv-task);
if (!mm)
return NULL;
 
priv-tail_vma = tail_vma = get_gate_vma(priv-task);
-   down_read(mm-mmap_sem);
 
/* Start with last addr hint */
if (last_addr  (vma = find_vma(mm, last_addr))) {
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index d8b8c71..1932c2c 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -165,15 +165,13 @@ static void *m_start(struct seq_file *m, loff_t *pos)
if (!priv-task)
return NULL;
 
-   mm = get_task_mm(priv-task);
+   mm = mm_for_maps(priv-task);
if (!mm) {
put_task_struct(priv-task);
priv-task = NULL;
return NULL;
}
 
-   down_read(mm-mmap_sem);
-
/* start from the Nth VMA */
for (vml = mm-context.vmlist; vml; vml = vml-next)
if (n-- == 0)
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index ae8146a..3ea5750 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -97,6 +97,7 @@ extern void __ptrace_link(struct task_struct *child,
 extern void __ptrace_unlink(struct task_struct *child);
 extern void ptrace_untrace(struct task_struct *child);
 extern int ptrace_may_attach(struct task_struct *task);
+extern int __ptrace_may_attach(struct task_struct *task);
 
 static inline void ptrace_link(struct task_struct *child,
   struct task_struct *new_parent)
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 7c76f2f..0c65d30 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -120,7 +120,7 @@ int ptrace_check_attach(struct task_struct *child, int kill)
return ret;
 }
 
-static int may_attach(struct task_struct *task)
+int __ptrace_may_attach(struct task_struct *task)
 {
/* May we inspect the given task?
 * This check is used both for attaching with ptrace
@@ -154,7 +154,7 @@ int ptrace_may_attach(struct task_struct *task)
 {
int err;
task_lock(task);

Fix kernel/ptrace.c compile problem (missing may_attach())

2008-01-02 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b8c9a18712f7b617fda66d878ce3759c9e575ba0
Commit: b8c9a18712f7b617fda66d878ce3759c9e575ba0
Parent: 831830b5a2b5d413407adf380ef62fe17d6fcbf2
Author: Linus Torvalds [EMAIL PROTECTED]
AuthorDate: Wed Jan 2 13:48:27 2008 -0800
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Wed Jan 2 13:48:27 2008 -0800

Fix kernel/ptrace.c compile problem (missing may_attach())

The previous commit missed one use of may_attach() that had been
renamed to __ptrace_may_attach().  Tssk, tssk, Al.

Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 kernel/ptrace.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 0c65d30..c25db86 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -196,7 +196,7 @@ repeat:
/* the same process cannot be attached many times */
if (task-ptrace  PT_PTRACED)
goto bad;
-   retval = may_attach(task);
+   retval = __ptrace_may_attach(task);
if (retval)
goto bad;
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html